|
ActiveLib
|
#include <Object.h>


Public Types | |
| using | Unique = std::unique_ptr<Object> |
| Unique pointer. | |
| using | Shared = std::shared_ptr<Object> |
| Shared pointer. | |
| using | Option = std::optional<Object> |
| Optional. | |
| using | base = std::vector<Object> |
| Base container - supports an document object hierarchy. | |
| using | Values = std::vector<setting::ValueSetting> |
| Values container - holds all single-value variables from the original class. | |
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 | |
| Object () | |
| Object (const utility::String &type, utility::String::Option objTag=std::nullopt) | |
| Object (const Object &source)=default | |
| Use the default copy. | |
| Object (Object &&source) noexcept=default | |
| Use the default rvalue copy. | |
| Object & | operator= (Object &&source)=default |
| Use default assignment. | |
| Object & | operator<< (Object &object) |
| Object & | operator<< (Object &&object) |
| Object & | operator<< (setting::ValueSetting &&value) |
| const Object * | object (const utility::String &tag) const |
| template<typename T > | |
| std::unique_ptr< T > | object (const utility::String &tag=utility::String{}) const |
| const setting::ValueSetting::Option | value (const utility::String &name) const |
| virtual bool | fillInventory (serialise::Inventory &inventory) const override |
| virtual serialise::Cargo::Unique | getCargo (const serialise::Inventory::Item &item) const override |
| const Object & | usingHandler (std::shared_ptr< Handler > handler) const |
| virtual void | setDefault () override |
| virtual bool | validate () override |
| virtual bool | insert (Cargo::Unique &&cargo, const serialise::Inventory::Item &item) override |
| Object & | withType (const utility::String &newType) |
| Object & | withTag (const utility::String &newTag) |
Public Member Functions inherited from active::serialise::Package | |
| bool | isRoot () const |
| virtual bool | isAttributeFirst () const |
| 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 () |
Public Attributes | |
| utility::String | docType |
| The document object type - can be used to reconstruct the original object. | |
| utility::String | tag |
| A serialisation tag (identifying the object role) | |
| std::vector< Object > | objects |
| Child objects of this object. | |
| Values | values |
| Child values of this object, i.e. single-value variables in the original object. | |
Static Public Attributes | |
| static utility::String | defaultTag = "obj" |
| The Object tag. | |
A class to represent an object in a persisted document model (via serialisation)
This class forms the basis for a simple document storage model, e.g. a single Object can represent an entire document. Supporting transformations to/from doc::Object provides an easy way to (de)serialise domain-specific content without writing any code directly related to serialisation. This simple document model can be sent to/retrieved from JSON or XML
Refer to the Handler class for more information about defining domain-specific classes that can be deserialised from JSON/XML
|
inline |
Default constructor
| Object::Object | ( | const utility::String & | type, |
| utility::String::Option | objTag = std::nullopt ) |
Constructor
| type | The document object type - used to reconstruct the original object. NB: Can use type_info.name, but isn't consistent |
| objTag | An optional serialisation tag (differentiating the object role when there are many of the same type for different purposes) |
|
overridevirtual |
Fill an inventory with the package items
| inventory | The inventory to receive the package items |
Implements active::serialise::Cargo.

|
overridevirtual |
Get the specified cargo
| item | The inventory item to retrieve |
Implements active::serialise::Cargo.
|
overridevirtual |
Insert specified cargo into the reconstruct objects - used for cargo with many instances sharing the same ID (e.g. from an array/map)
| cargo | The cargo to insert |
| item | The inventory item linked with the cargo |
Reimplemented from active::serialise::Package.

| const Object * Object::object | ( | const utility::String & | tag | ) | const |
Get an object by tag
| tag | The required object tag |
|
inline |
Make an object from this object
| tag | The required object tag (empty to retrieve this object as an object |
Write operator
| object | A object to move to the object |
Write operator
| object | A object to move to the object |
|
inline |
Write operator
| value | A value to move to the object |

|
overridevirtual |
Set to the default package content
Reimplemented from active::serialise::Package.

Define the handler to reconstruct objects
| handler | The handler to reconstruct objects |
|
overridevirtual |
Validate the cargo data
Reimplemented from active::serialise::Cargo.

| const ValueSetting::Option Object::value | ( | const utility::String & | name | ) | const |
Get an object value by name
| name | The value name |


|
inline |
Set the object tag
| newTag | The object tag |
|
inline |
Set the object type
| newType | The document object type |