ActiveLib
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
active::serialise::ValueWrap< T > Class Template Reference

#include <ValueWrap.h>

Inheritance diagram for active::serialise::ValueWrap< T >:
Inheritance graph
[legend]
Collaboration diagram for active::serialise::ValueWrap< T >:
Collaboration graph
[legend]

Public Types

using base = std::reference_wrapper<T>
 Item reference base.
 
- 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)
 

Public Member Functions

 ValueWrap (T &val)
 
 ValueWrap (const T &val)
 
virtual bool write (utility::String &dest) const override
 
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
 
bool read (const utility::String &source)
 
bool write (utility::String &dest) const
 
std::optional< Item::Type > type () const
 
bool write (utility::String &dest) const
 
std::optional< Item::Type > type () const
 
bool read (const utility::String &source)
 
bool write (utility::String &dest) const
 
std::optional< Item::Type > type () const
 
- 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 ()
 

Detailed Description

template<class T>
class active::serialise::ValueWrap< T >

Interface for a lightweight wrapper for passing a reference to item data into (de)serialise functions

Template parameters are: T: Value native type

Constructor & Destructor Documentation

◆ ValueWrap() [1/2]

template<class T >
active::serialise::ValueWrap< T >::ValueWrap ( T & val)
inline

Constructor

Parameters
valThe item value

◆ ValueWrap() [2/2]

template<class T >
active::serialise::ValueWrap< T >::ValueWrap ( const T & val)
inline

Constructor

Parameters
valThe item value

Member Function Documentation

◆ read() [1/4]

template<class T >
virtual bool active::serialise::ValueWrap< T >::read ( const setting::Value & source)
inlineoverridevirtual

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/4]

bool active::serialise::ValueWrap< utility::TextEncoding >::read ( const utility::String & source)
inlinevirtual

Import the object from the specified string (specialisations for TextEncoding)

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

Implements active::serialise::Item.

◆ read() [3/4]

bool active::serialise::ValueWrap< bool >::read ( const utility::String & source)
inlinevirtual

Import the object from the specified string (specialisation for bool)

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

Implements active::serialise::Item.

Here is the call graph for this function:

◆ read() [4/4]

template<class T >
virtual bool active::serialise::ValueWrap< T >::read ( const utility::String & source)
inlineoverridevirtual

Read the item from a string

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

Implements active::serialise::Item.

Here is the caller graph for this function:

◆ setDefault()

template<class T >
virtual void active::serialise::ValueWrap< T >::setDefault ( )
inlineoverridevirtual

Set to the default package content

Implements active::serialise::Cargo.

◆ type() [1/4]

std::optional< Item::Type > active::serialise::ValueWrap< utility::String >::type ( ) const
inlinevirtual

Get the serialisation type for the item value (specialisation for string)

Returns
The item value serialisation type (JSON encoding requires specific type representations)

Reimplemented from active::serialise::Item.

◆ type() [2/4]

std::optional< Item::Type > active::serialise::ValueWrap< utility::Guid >::type ( ) const
inlinevirtual

Get the serialisation type for the item value (specialisation for guid)

Returns
The item value serialisation type (JSON encoding requires specific type representations)

Reimplemented from active::serialise::Item.

◆ type() [3/4]

std::optional< Item::Type > active::serialise::ValueWrap< bool >::type ( ) const
inlinevirtual

Get the serialisation type for the item value (specialisation for bool)

Returns
The item value serialisation type (JSON encoding requires specific type representations)

Reimplemented from active::serialise::Item.

◆ type() [4/4]

template<class T >
virtual std::optional< Item::Type > active::serialise::ValueWrap< T >::type ( ) const
inlineoverridevirtual

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() [1/4]

bool active::serialise::ValueWrap< utility::TextEncoding >::write ( utility::String & dest) const
inlinevirtual

Export the object to the specified string (specialisations for TextEncoding)

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

Implements active::serialise::Item.

Reimplemented in active::serialise::xml::XMLNumber.

◆ write() [2/4]

bool active::serialise::ValueWrap< utility::Guid >::write ( utility::String & dest) const
inlinevirtual

Write the item to a string (specialisation for guid)

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

Implements active::serialise::Item.

Reimplemented in active::serialise::xml::XMLNumber.

◆ write() [3/4]

bool active::serialise::ValueWrap< bool >::write ( utility::String & dest) const
inlinevirtual

Export the object to the specified string (specialisation for bool)

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

Implements active::serialise::Item.

Reimplemented in active::serialise::xml::XMLNumber.

◆ write() [4/4]

template<class T >
virtual bool active::serialise::ValueWrap< T >::write ( utility::String & dest) const
inlineoverridevirtual

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.

Reimplemented in active::serialise::xml::XMLNumber.


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