ActiveLib
Loading...
Searching...
No Matches
Public Member Functions | List of all members
active::serialise::AnyValueWrap Class Reference

#include <AnyValueWrap.h>

Inheritance diagram for active::serialise::AnyValueWrap:
Inheritance graph
[legend]
Collaboration diagram for active::serialise::AnyValueWrap:
Collaboration graph
[legend]

Public Member Functions

 AnyValueWrap ()
 
 AnyValueWrap (const setting::Value &val)
 
virtual bool write (utility::String &dest) const override
 
setting::Value::Unique releaseIncoming ()
 
virtual bool read (const utility::String &source) override
 
virtual bool read (const setting::Value &source) override
 
virtual void setDefault () override
 
virtual std::optional< Item::Type > type () const override
 
- Public Member Functions inherited from active::serialise::Item
virtual bool fillInventory (Inventory &inventory) const
 
virtual Cargo::Unique getCargo (const Inventory::Item &item) const
 
- Public Member Functions inherited from active::serialise::Cargo
 Cargo ()
 
 Cargo (const Cargo &source)
 
virtual ~Cargo ()=default
 
virtual void clear ()
 
virtual bool validate ()
 

Additional Inherited Members

- Public Types inherited from active::serialise::Item
enum class  Type { text , number , boolean }
 
- 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)
 

Detailed Description

Interface for a lightweight wrapper for a serialisable value of a potentially unspecified type

This is primarily intended to support classes like XMLValueSetting, which may contain an array of values of different types. On export, the type of value is established by each outgoing value, but on import the value type may not be known until it is read, e.g. a JSON parser may detect text/number/bool/null. XML does not have an explicit format for value types, so this will need to be post-processed by the receiving package (if it has explicit type specifications)

Constructor & Destructor Documentation

◆ AnyValueWrap() [1/2]

active::serialise::AnyValueWrap::AnyValueWrap ( )
inline

Default constructor

◆ AnyValueWrap() [2/2]

active::serialise::AnyValueWrap::AnyValueWrap ( const setting::Value & val)
inline

Constructor

Parameters
valThe item value

Member Function Documentation

◆ read() [1/2]

bool AnyValueWrap::read ( const setting::Value & source)
overridevirtual

Read the cargo data from the specified setting

Parameters
sourceThe setting to read
Returns
True if the data was successfully read

Reimplemented from active::serialise::Item.

Here is the call graph for this function:

◆ read() [2/2]

bool AnyValueWrap::read ( const utility::String & source)
overridevirtual

Read the item from a string

Parameters
sourceThe string to read
Returns
True if the data was successfully read

Implements active::serialise::Item.

◆ releaseIncoming()

setting::Value::Unique active::serialise::AnyValueWrap::releaseIncoming ( )
inline

Release the incoming value held by this wrapper

Returns
The incoming value (nullptr if none received)

◆ setDefault()

void AnyValueWrap::setDefault ( )
overridevirtual

Set to the default package content

Implements active::serialise::Cargo.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ type()

std::optional< Item::Type > AnyValueWrap::type ( ) const
overridevirtual

Get the serialisation type for the item value

Returns
The item value serialisation type (nullopt = unspecified, i.e. a default is acceptable)

Reimplemented from active::serialise::Item.

◆ write()

bool AnyValueWrap::write ( utility::String & dest) const
overridevirtual

Write the item to a string

Parameters
destThe string to write the data to
Returns
True if the data was successfully written

Implements active::serialise::Item.


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