|
ActiveLib
|
#include <Pair.h>


Public Types | |
| enum | FieldIndex { key , value } |
| The indices of the default package items. | |
Public Types inherited from active::serialise::Package | |
| using | Unique = std::unique_ptr<Package> |
| Unique pointer. | |
| using | Shared = std::shared_ptr<Package> |
| Shared pointer. | |
Public Types inherited from active::serialise::Cargo | |
| using | Unique = std::unique_ptr<Cargo> |
| Unique pointer. | |
| using | Shared = std::shared_ptr<Cargo> |
| Shared pointer. | |
| using | size_type = std::string::size_type |
| Class size type. | |
| using | sizeOption = std::optional<size_type> |
| Optional size type (used to indicate an unspecified or non-existant position) | |
Public Member Functions | |
| Pair (Cargo::Unique key, Cargo::Unique value, utility::String::Option name=std::nullopt) | |
| Pair (const Pair &source)=delete | |
| No copy constructor. | |
| virtual | ~Pair ()=default |
| Destructor. | |
| Cargo * | getKey () const |
| Cargo * | getValue () const |
| virtual bool | fillInventory (Inventory &inventory) const |
| virtual const Inventory::Item & | keyItem () const |
| virtual const Inventory::Item & | valueItem () const |
| virtual Cargo::Unique | getCargo (const Inventory::Item &item) const |
| virtual void | setDefault () |
| virtual bool | validate () |
| auto | releaseKey () |
| auto | releaseData () |
Public Member Functions inherited from active::serialise::Package | |
| bool | isRoot () const |
| virtual bool | isAttributeFirst () const |
| virtual bool | insert (Cargo::Unique &&cargo, const Inventory::Item &item) |
| virtual bool | read (const utility::String &source) |
| void | setRoot (bool state) |
| virtual bool | finaliseAttributes () |
Public Member Functions inherited from active::serialise::Cargo | |
| Cargo () | |
| Cargo (const Cargo &source) | |
| virtual | ~Cargo ()=default |
| virtual void | clear () |
Static Public Attributes | |
| static Inventory::Item | keyEntry = Inventory::Item{ fieldID[key], key, attribute, true, &typeid(Pair)} |
| The default inventory item for the pair key. | |
| static Inventory::Item | valueEntry = Inventory::Item{ fieldID[value], value, attribute, true, &typeid(Pair)} |
| The default inventory item for the pair value. | |
A serialisable pair, e.g. key and value
Use this class as a simple wrapper for serialisable data that should be stored in pairs, e.g. dictionary items. The wrapper acts as an enclosing package for the key and value. Both the key and value can define an inventory or inventory items, but this wrapper will provide defaults if these are undefined.
| Pair::Pair | ( | Cargo::Unique | key, |
| Cargo::Unique | value, | ||
| utility::String::Option | name = std::nullopt ) |
Constructor
| key | The pair key |
| value | The pair value |
| name | Optional name for the key/value pair |
|
virtual |
Fill an inventory with the package items
| inventory | The inventory to receive the package items |
Implements active::serialise::Cargo.

|
virtual |
Get the specified cargo
| item | The inventory item to retrieve |
Implements active::serialise::Cargo.
|
inline |
Get the pair key
|
inline |
Get the pair value
|
inlinevirtual |
Get the default inventory item for the key

|
inline |
Release the pair value
|
inline |
Release the pair key
|
virtual |
Set to the default package content
Reimplemented from active::serialise::Package.
|
virtual |
Validate the cargo data
Reimplemented from active::serialise::Cargo.
|
inlinevirtual |
Get the default inventory item for the value
