LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SerializableKeyValueMap< T > Class Template Referencefinal

The SerializableKeyValueMap class provides an easy way to serialize and deserialize ordered key value pairs. More...

#include <serializablekeyvaluemap.h>

+ Inheritance diagram for SerializableKeyValueMap< T >:
+ Collaboration diagram for SerializableKeyValueMap< T >:

Public Member Functions

 SerializableKeyValueMap ()=delete
 
 SerializableKeyValueMap (const SerializableKeyValueMap< T > &other) noexcept
 
 SerializableKeyValueMap (const typename T::ValueType &defaultValue) noexcept
 
 SerializableKeyValueMap (const SExpression &node)
 
 ~SerializableKeyValueMap () noexcept
 
QStringList keys () const noexcept
 
const T::ValueType & getDefaultValue () const noexcept
 
bool contains (const QString &key) const noexcept
 
tl::optional< typename
T::ValueType > 
tryGet (const QString &key) const noexcept
 
const T::ValueType & value (const QStringList &keyOrder, QString *usedKey=nullptr) const noexcept
 
void setDefaultValue (const typename T::ValueType &value) noexcept
 
void insert (const QString &key, const typename T::ValueType &value) noexcept
 
void serialize (SExpression &root) const override
 Serialize the object into an existing S-Expression node. More...
 
SerializableKeyValueMap< T > & operator= (const SerializableKeyValueMap< T > &rhs) noexcept
 
bool operator== (const SerializableKeyValueMap< T > &rhs) const noexcept
 
bool operator!= (const SerializableKeyValueMap< T > &rhs) const noexcept
 
- Public Member Functions inherited from SerializableObject
 SerializableObject () noexcept
 
virtual ~SerializableObject () noexcept
 
SExpression serializeToDomElement (const QString &name) const
 Serialize the object to a new S-Expression node. More...
 

Private Attributes

QMap< QString, typename
T::ValueType > 
mValues
 

Additional Inherited Members

- Static Public Member Functions inherited from SerializableObject
template<typename T >
static void serializeObjectContainer (SExpression &root, const T &container, const QString &itemName)
 
template<typename T >
static void serializePointerContainer (SExpression &root, const T &container, const QString &itemName)
 
template<typename T >
static void serializePointerContainerUuidSorted (SExpression &root, const T &container, const QString &itemName)
 

Detailed Description

template<typename T>
class librepcb::SerializableKeyValueMap< T >

The SerializableKeyValueMap class provides an easy way to serialize and deserialize ordered key value pairs.

Note
This map guarantees to always contain a valid default value. A default value has an empty string as key and will be used as fallback for value().
Warning
When modifying this class, make sure that it still guarantees to always contain a valid default value! So, don't add a default constructor, a clear() method or similar!

Constructor & Destructor Documentation

SerializableKeyValueMap ( const SerializableKeyValueMap< T > &  other)
inlinenoexcept
SerializableKeyValueMap ( const typename T::ValueType &  defaultValue)
inlineexplicitnoexcept
SerializableKeyValueMap ( const SExpression node)
inlineexplicit
~SerializableKeyValueMap ( )
inlinenoexcept

Member Function Documentation

QStringList keys ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

const T::ValueType& getDefaultValue ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

bool contains ( const QString &  key) const
inlinenoexcept
tl::optional<typename T::ValueType> tryGet ( const QString &  key) const
inlinenoexcept

+ Here is the caller graph for this function:

const T::ValueType& value ( const QStringList &  keyOrder,
QString *  usedKey = nullptr 
) const
inlinenoexcept

+ Here is the caller graph for this function:

void setDefaultValue ( const typename T::ValueType &  value)
inlinenoexcept

+ Here is the caller graph for this function:

void insert ( const QString &  key,
const typename T::ValueType &  value 
)
inlinenoexcept

+ Here is the caller graph for this function:

void serialize ( SExpression root) const
inlineoverridevirtual

Serialize the object into an existing S-Expression node.

This method inserts/appends all attributes and childs of the object to an existing S-Expression node. The content which already exists in the given S-Expression node will not be removed.

Note
The generated S-Expression node has always the format of the application's major version (it's not possible to generate DOMs of older versions).
Parameters
rootThe target DOM root node
Exceptions
ExceptionThis method throws an exception if an error occurs.

Implements SerializableObject.

+ Here is the caller graph for this function:

SerializableKeyValueMap<T>& operator= ( const SerializableKeyValueMap< T > &  rhs)
inlinenoexcept
bool operator== ( const SerializableKeyValueMap< T > &  rhs) const
inlinenoexcept
bool operator!= ( const SerializableKeyValueMap< T > &  rhs) const
inlinenoexcept

Member Data Documentation

QMap<QString, typename T::ValueType> mValues
private

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