Passwordfile library: Io::Entry Class Reference

Passwordfile library 5.0.13 C++ library to read/write passwords from/to encrypted files

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Io::Entry Class Referenceabstract

Instances of the Entry class form a hierarchic data structure used to store account information. More...

`#include <entry.h>`

Inheritance diagram for Io::Entry:
[legend]
Collaboration diagram for Io::Entry:
[legend]

## Public Member Functions
virtual | ~Entry ()
| Destroys the entry.
Entry & | operator= (const Entry &other)=delete
virtual EntryType | type () const =0
| Returns the type of the entry.
const std::string & | label () const
| Returns the label.
void | setLabel (const std::string &label)
| Sets the label.
void | makeLabelUnique ()
| Internally called to make the entry's label unique within the parent.
NodeEntry * | parent () const
| Returns the parent entry.
void | setParent (NodeEntry *parent, int index=-1)
| Sets the parent for the entry.
int | index () const
| Returns the index of the entry within its parent.
bool | isIndirectChildOf (const NodeEntry *entry) const
| Returns an indication whether the instance is an indirect child of the specified entry.
std::list< std::string > | path () const
| Returns the path of the entry.
void | path (std::list< std::string > &res) const
| Stores to path of the entry in the specified list of string.
virtual void | make (std::ostream &stream) const =0
| Serializes the entry to the specified stream.
virtual Entry * | clone () const =0
| Clones the entry.
EntryStatistics | computeStatistics () const
| Computes statistics for this entry.
virtual void | accumulateStatistics (EntryStatistics &stats) const =0

## Static Public Member Functions
static Entry * | parse (std::istream &stream)
| Parses an entry from the specified stream.
static bool | denotesNodeEntry (std::uint8_t version)
static constexpr EntryType | denotedEntryType (std::uint8_t version)

## Protected Member Functions
| Entry (const std::string &label=std::string(), NodeEntry *parent=nullptr)
| Constructs a new entry with the specified label and parent.
| Entry (const Entry &other)
| Constructs a copy of another entry.

## Protected Attributes
std::string | m_extendedData

## Friends
class | NodeEntry

## Detailed Description

Instances of the Entry class form a hierarchic data structure used to store account information.

Entries can be serialized and deserialized using the parse() and make() methods.

Definition at line 30 of file entry.h.

## Constructor & Destructor Documentation

## ◆ ~Entry()

Io::Entry::~Entry | ( |  | ) |
| virtual

Destroys the entry.

Definition at line 52 of file entry.cpp.

## ◆ Entry() [1/2]

Io::Entry::Entry | ( | const std::string & | label = std::string(),
|  | NodeEntry * | parent = nullptr )
| protected

Constructs a new entry with the specified label and parent.

Definition at line 29 of file entry.cpp.

## ◆ Entry() [2/2]

Io::Entry::Entry | ( | const Entry & | other | ) |
| protected

Constructs a copy of another entry.

Remarks
  The copy will be parentless and thus not be embedded in the hierarchy of other. Child entries will be copied as well.

Definition at line 42 of file entry.cpp.

## Member Function Documentation

## ◆ accumulateStatistics()

virtual void Io::Entry::accumulateStatistics | ( | EntryStatistics & | stats | ) | const
| pure virtual

Implemented in Io::AccountEntry, and Io::NodeEntry.

## ◆ clone()

virtual Entry * Io::Entry::clone | ( |  | ) | const
| pure virtual

Clones the entry.

Remarks
  The copy will be parentless and thus not be embedded in the hierarchy of other. Child entries will be copied as well.

Implemented in Io::AccountEntry, and Io::NodeEntry.

## ◆ computeStatistics()

EntryStatistics Io::Entry::computeStatistics | ( |  | ) | const
| inline

Computes statistics for this entry.

Remarks
  Takes the current instance and children into account but not parents.

Definition at line 107 of file entry.h.

## ◆ denotedEntryType()

EntryType Io::Entry::denotedEntryType | ( | std::uint8_t | version | ) |
| staticconstexpr

Definition at line 165 of file entry.h.

## ◆ denotesNodeEntry()

bool Io::Entry::denotesNodeEntry | ( | std::uint8_t | version | ) |
| inlinestatic

Definition at line 160 of file entry.h.

## ◆ index()

int Io::Entry::index | ( |  | ) | const
| inline

Returns the index of the entry within its parent.

Returns -1 for parentless entries.

Definition at line 98 of file entry.h.

## ◆ isIndirectChildOf()

bool Io::Entry::isIndirectChildOf | ( | const NodeEntry * | entry | ) | const

Returns an indication whether the instance is an indirect child of the specified entry.

Definition at line 136 of file entry.cpp.

## ◆ label()

const std::string & Io::Entry::label | ( |  | ) | const
| inline

Returns the label.

Definition at line 70 of file entry.h.

## ◆ make()

virtual void Io::Entry::make | ( | std::ostream & | stream | ) | const
| pure virtual

Serializes the entry to the specified stream.

Implemented in Io::AccountEntry, and Io::NodeEntry.

## ◆ makeLabelUnique()

void Io::Entry::makeLabelUnique | ( |  | ) |

Internally called to make the entry's label unique within the parent.

See also
  setLabel()

Definition at line 61 of file entry.cpp.

## ◆ operator=()

Entry & Io::Entry::operator= | ( | const Entry & | other | ) |
| delete

## ◆ parent()

NodeEntry * Io::Entry::parent | ( |  | ) | const
| inline

Returns the parent entry.

Remarks
  Returns nullptr for top-level entries.

Definition at line 90 of file entry.h.

## ◆ parse()

Entry * Io::Entry::parse | ( | std::istream & | stream | ) |
| static

Parses an entry from the specified stream.

Exceptions

  Throws | ParsingException when a parsing exception occurs.

Definition at line 173 of file entry.cpp.

## ◆ path() [1/2]

std::list< string > Io::Entry::path | ( |  | ) | const

Returns the path of the entry.

Definition at line 151 of file entry.cpp.

## ◆ path() [2/2]

void Io::Entry::path | ( | std::list< std::string > & | res | ) | const

Stores to path of the entry in the specified list of string.

Definition at line 161 of file entry.cpp.

## ◆ setLabel()

void Io::Entry::setLabel | ( | const std::string & | label | ) |
| inline

Sets the label.

Remarks
  The label might be modified to ensure that each child entry within a certain parent has a unique label.

Definition at line 80 of file entry.h.

## ◆ setParent()

void Io::Entry::setParent | ( | NodeEntry * | parent,
|  | int | index = -1 )

Sets the parent for the entry.

If an index is specified the entry will be inserted as child at this position. If parent is nullptr, the entry will be parentless.

Remarks
  - The label might be adjusted to be unique within the new parent.
  - If the entry is just moved within its current parent (parent equals parent()), the specified index doesn't take the entry itself into account as it is removed from the children of parent and then re-inserted at index.

Definition at line 96 of file entry.cpp.

## ◆ type()

virtual EntryType Io::Entry::type | ( |  | ) | const
| pure virtual

Returns the type of the entry.

Implemented in Io::AccountEntry, and Io::NodeEntry.

## Friends And Related Symbol Documentation

## ◆ NodeEntry

friend class NodeEntry
| friend

Definition at line 31 of file entry.h.

## Member Data Documentation

## ◆ m_extendedData

std::string Io::Entry::m_extendedData
| protected

Definition at line 64 of file entry.h.

The documentation for this class was generated from the following files:

- io/entry.h
- io/entry.cpp