LibrePCB Developers Documentation
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 Types

enum class  Event
 
typedef Slot< SerializableKeyValueMap< T >, const QString &, EventOnEditedSlot
 

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
 Serialize into librepcb::SExpression 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 Attributes

Signal< SerializableKeyValueMap< T >, const QString &, EventonEdited
 

Private Attributes

QMap< QString, typename T::ValueType > mValues
 

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!

Member Typedef Documentation

◆ OnEditedSlot

typedef Slot<SerializableKeyValueMap<T>, const QString&, Event> OnEditedSlot

Member Enumeration Documentation

◆ Event

enum class Event
strong
Enumerator
ElementAdded 
ElementRemoved 
ElementValueChanged 

Constructor & Destructor Documentation

◆ SerializableKeyValueMap() [1/4]

◆ SerializableKeyValueMap() [2/4]

SerializableKeyValueMap ( const SerializableKeyValueMap< T > &  other)
inlinenoexcept

◆ SerializableKeyValueMap() [3/4]

SerializableKeyValueMap ( const typename T::ValueType &  defaultValue)
inlineexplicitnoexcept

◆ SerializableKeyValueMap() [4/4]

SerializableKeyValueMap ( const SExpression node)
inlineexplicit
+ Here is the call graph for this function:

◆ ~SerializableKeyValueMap()

~SerializableKeyValueMap ( )
inlinenoexcept

Member Function Documentation

◆ keys()

QStringList keys ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getDefaultValue()

const T::ValueType & getDefaultValue ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ contains()

bool contains ( const QString &  key) const
inlinenoexcept

◆ tryGet()

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

◆ value()

const T::ValueType & value ( const QStringList &  keyOrder,
QString *  usedKey = nullptr 
) const
inlinenoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDefaultValue()

void setDefaultValue ( const typename T::ValueType &  value)
inlinenoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert()

void insert ( const QString &  key,
const typename T::ValueType &  value 
)
inlinenoexcept
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

void serialize ( SExpression root) const
inline

Serialize into librepcb::SExpression node.

Parameters
rootRoot node to serialize into.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

SerializableKeyValueMap< T > & operator= ( const SerializableKeyValueMap< T > &  rhs)
inlinenoexcept
+ Here is the call graph for this function:

◆ operator==()

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

◆ operator!=()

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

Member Data Documentation

◆ onEdited

Signal<SerializableKeyValueMap<T>, const QString&, Event> onEdited

◆ mValues

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

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