libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
keepass::VariantDictionary Class Referencefinal

A typed key-value store used in KDBX 4 header fields. More...

#include <variantdictionary.hh>

Classes

struct  Entry
 A single entry in the dictionary, holding a typed value. More...
 

Public Types

enum class  Type : uint8_t {
  kEnd = 0x00 , kUInt32 = 0x04 , kUInt64 = 0x05 , kBool = 0x08 ,
  kInt32 = 0x0c , kInt64 = 0x0d , kString = 0x18 , kByteArray = 0x42
}
 Type tags identifying the value kind stored in an entry. More...
 

Public Member Functions

void Parse (std::istream &src)
 Deserializes the dictionary from a binary stream.
 
void Write (std::ostream &dst) const
 Serializes the dictionary to a binary stream.
 
bool Has (const std::string &key) const
 Checks whether an entry with the given key exists.
 
const Entry & Get (const std::string &key) const
 Returns the entry associated with key.
 
void Set (const std::string &key, Type type, std::vector< uint8_t > &&value)
 Inserts or replaces an entry in the dictionary.
 
std::vector< uint8_t > GetBytes (const std::string &key) const
 Returns the raw value bytes of an entry.
 
uint32_t GetUInt32 (const std::string &key) const
 Returns the value of an entry interpreted as a uint32.
 
uint64_t GetUInt64 (const std::string &key) const
 Returns the value of an entry interpreted as a uint64.
 
std::map< std::string, Entry > entries () const
 Returns a copy of all entries in the dictionary.
 

Detailed Description

A typed key-value store used in KDBX 4 header fields.

Format reference: https://sseemayer.github.io/kdbx-compendium/

Member Enumeration Documentation

◆ Type

Type tags identifying the value kind stored in an entry.

Enumerator
kEnd 

End-of-dictionary sentinel.

kUInt32 

Unsigned 32-bit integer.

kUInt64 

Unsigned 64-bit integer.

kBool 

Boolean value.

kInt32 

Signed 32-bit integer.

kInt64 

Signed 64-bit integer.

kString 

UTF-8 string.

kByteArray 

Raw byte array.

Member Function Documentation

◆ entries()

std::map< std::string, Entry > keepass::VariantDictionary::entries ( ) const
inline

Returns a copy of all entries in the dictionary.

Returns
Map of key-value pairs.

◆ Get()

const Entry & keepass::VariantDictionary::Get ( const std::string &  key) const

Returns the entry associated with key.

Parameters
[in]keyEntry key to look up.
Returns
Const reference to the matching entry.

◆ GetBytes()

std::vector< uint8_t > keepass::VariantDictionary::GetBytes ( const std::string &  key) const

Returns the raw value bytes of an entry.

Parameters
[in]keyEntry key to look up.
Returns
Copy of the value byte vector.

◆ GetUInt32()

uint32_t keepass::VariantDictionary::GetUInt32 ( const std::string &  key) const

Returns the value of an entry interpreted as a uint32.

Parameters
[in]keyEntry key to look up.
Returns
The value as uint32_t.

◆ GetUInt64()

uint64_t keepass::VariantDictionary::GetUInt64 ( const std::string &  key) const

Returns the value of an entry interpreted as a uint64.

Parameters
[in]keyEntry key to look up.
Returns
The value as uint64_t.

◆ Has()

bool keepass::VariantDictionary::Has ( const std::string &  key) const

Checks whether an entry with the given key exists.

Parameters
[in]keyEntry key to look up.
Returns
true if the key is present, false otherwise.

◆ Parse()

void keepass::VariantDictionary::Parse ( std::istream &  src)

Deserializes the dictionary from a binary stream.

Parameters
[in,out]srcInput stream to read from.

◆ Set()

void keepass::VariantDictionary::Set ( const std::string &  key,
Type  type,
std::vector< uint8_t > &&  value 
)

Inserts or replaces an entry in the dictionary.

Parameters
[in]keyEntry key.
[in]typeData type of the value.
[in]valueRaw serialized value bytes (moved in).

◆ Write()

void keepass::VariantDictionary::Write ( std::ostream &  dst) const

Serializes the dictionary to a binary stream.

Parameters
[out]dstOutput stream to write to.

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