HashXmlSerializer
class HashXmlSerializer : public TextSerializer<karabo::data::Hash>
@brief The HashXmlSerializer provides an implementation of TextSerializer for the karabo::data::Hash
While a karabo::data::Hash can in principle hold arbitrary data types, Hash serialization is limited to data types known to the karabo::data::Types type system. Hashes containing other data types will lead to exceptions during serialization.
Functions
| Name | Description |
|---|---|
| readStrConvertibleAttrs | Reads all the hash attributes that are convertible from string from a given xml node. |
| extractNonStrConvertibleAttrs | Extracts all the hash attributes that are non convertible from string from a given xml node. |
| addNonStrConvertibleAttrs | Adds hash attributes non convertible from string to a given hash on a given path. |
Function Details
addNonStrConvertibleAttrs
void addNonStrConvertibleAttrs(karabo::data::Hash& hash, const std::string& hashPath, std::vector<karabo::data::Hash>& attrs) const
Adds hash attributes non convertible from string to a given hash on a given path. The hash attributes are stored in a vector of hashes argument.
hash
: the hash that will have the attributes added to.
hashPath
: the path in the hash where the attributes will be added.
attrs
: the vector with the attributes to be added. Each attribute is an element of this vector and
has a single key that corresponds to the attribute name and whose value is the attribute
value. This value will be 'moved away' to the attributes to avoid copies.
extractNonStrConvertibleAttrs
void extractNonStrConvertibleAttrs(std::vector<karabo::data::Hash>& nonStrAttrs, const pugi::xml_node& node) const
Extracts all the hash attributes that are non convertible from string from a given xml node.
node
: the xml node with the attributes to be read.
nonStrAttrs
: vector of hashes with each hash corresponding to a nonStringfiedAttr read from the
xml node. Each hash in the vector has one node with the attribute name for its key and the attribute
value for its value.
Note
: currently there are two types of attributes that are not convertible from string: VECTOR_HASH and SCHEMA.
readStrConvertibleAttrs
bool readStrConvertibleAttrs(karabo::data::Hash::Attributes& attrs, const pugi::xml_node& node) const
Reads all the hash attributes that are convertible from string from a given xml node.
attrs
: the set of attrs that are convertible from string.
node
: the xml node with the attributes to be read.
Return : true if all the attributes in the xml node have been read; false if there is at least one attribute that is not convertible from string that should still be processed.