LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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
 
std::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.
 
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

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

Member Enumeration Documentation

◆ Event

template<typename T >
enum class Event
strong
Enumerator
ElementAdded 
ElementRemoved 
ElementValueChanged 

Constructor & Destructor Documentation

◆ SerializableKeyValueMap() [1/4]

template<typename T >
SerializableKeyValueMap ( )
delete

◆ SerializableKeyValueMap() [2/4]

template<typename T >
SerializableKeyValueMap ( const SerializableKeyValueMap< T > &  other)
inlinenoexcept

◆ SerializableKeyValueMap() [3/4]

template<typename T >
SerializableKeyValueMap ( const typename T::ValueType &  defaultValue)
inlineexplicitnoexcept

◆ SerializableKeyValueMap() [4/4]

template<typename T >
SerializableKeyValueMap ( const SExpression node)
inlineexplicit
+ Here is the call graph for this function:

◆ ~SerializableKeyValueMap()

template<typename T >
~SerializableKeyValueMap ( )
inlinenoexcept

Member Function Documentation

◆ keys()

template<typename T >
QStringList keys ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ getDefaultValue()

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

◆ contains()

template<typename T >
bool contains ( const QString &  key) const
inlinenoexcept

◆ tryGet()

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

◆ value()

template<typename T >
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()

template<typename T >
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()

template<typename T >
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()

template<typename T >
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=()

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

◆ operator==()

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

◆ operator!=()

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

Member Data Documentation

◆ onEdited

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

◆ mValues

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

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