Factory helper to create a MappingConfiguration out of a XML based description. This factory uses a template type DomNodeType which is design to follow the a concept class type definition of the a_util::DOMElement.
More...
#include <datamodel_xml_configurationfromxml_base.h>
|
| template<typename T> |
| static utility::Optional< T > | getAttribute (const DomNodeType &dom_node, const std::string &attribute_name, const utility::Optional< T > &default_value={}, bool is_mandatory=false, const std::string &parse_error_message={}, const std::string &mapping_reading_version={}) |
| | Get the Attribute from the dom_node. Return a valid Optional<T> if set, otherwise return default_value or throw.
|
| |
| template<typename T> |
| static utility::Optional< T > | getData (const DomNodeType &dom_node, const utility::Optional< T > &default_value={}, bool is_mandatory=false, const std::string &parse_error_message="", const std::string &mapping_reading_version={}) |
| | Get the data content of a subnode of dom_node. Return a valid Optional<T> if set, otherwise return default_value or throw.
|
| |
| template<typename T> |
| static utility::Optional< T > | getDataSubNode (const DomNodeType &dom_node, const std::string &sub_node_name, const utility::Optional< T > &default_value={}, bool is_mandatory=false, const std::string &parse_error_message={}, const std::string &mapping_reading_version={}) |
| | Get the data content of a subnode of dom_node. Return a valid Optional<T> if set, otherwise return default_value or throw.
|
| |
| static void | attributesToString (const std::map< std::string, std::string > &attributes, std::stringstream &property_stream) |
| | Helper function to serialize xml attributes to a string.
|
| |
| static void | nodeToString (const DomNodeType &dom_node, std::stringstream &property_stream, size_t level=0) |
| | Helper function to serialize a xml node to a string.
|
| |
| template<typename PropertiesType> |
| static void | setDataOrSubNodesAsProperty (const DomNodeType &dom_node, const std::string &property_name, PropertiesType &properties_target) |
| | Set the Data Or Sub Nodes As Property.
|
| |
template<typename DomNodeType>
struct ddl::mapping::MappingConfigurationFromXMLFactoryBase< DomNodeType >
Factory helper to create a MappingConfiguration out of a XML based description. This factory uses a template type DomNodeType which is design to follow the a concept class type definition of the a_util::DOMElement.
- Template Parameters
-
| DomNodeType | a DOMElement class must implement following funtions:
- std::string getAttribute(const std::string& name) const;
- std::map<std::string, std::string> getAttributes() const;
- std::string getData() const;
- bool findNode(const std::string& node_name, DomNodeType& result_node)
- bool findNodes(const std::string& xpath search,
std::list<DomNodeType>& result_nodes) const;
- bool findNodes(const std::string& node_names,
std::list<DomNodeType>& result_nodes) const;
|
◆ attributesToString()
template<typename DomNodeType>
Helper function to serialize xml attributes to a string.
- Parameters
-
| attributes | the attributes to parse |
| property_stream | the stream to serialize to |
◆ getAttribute()
template<typename DomNodeType>
template<typename T>
Get the Attribute from the dom_node. Return a valid Optional<T> if set, otherwise return default_value or throw.
- Template Parameters
-
| T | the value type of the returned Optional |
- Parameters
-
| dom_node | the dom node if type DomNodeType |
| attribute_name | the attribute name |
| default_value | the default value if the attribute was not set. (this will be only used if is_mandatory is false) |
| is_mandatory | if set to true this function will throw if the attribute is not set in DOM |
| parse_error_message | the message in the thrown exception if is_mandatory was set to true |
| mapping_reading_version | addition error information for beautifying error messages |
- Returns
- utility::Optional<T>
- Exceptions
-
| utility::Error | The function will throw only if is_mandatory is set to true. |
◆ getData()
template<typename DomNodeType>
template<typename T>
Get the data content of a subnode of dom_node. Return a valid Optional<T> if set, otherwise return default_value or throw.
- Template Parameters
-
| T | the value type of the returned Optional |
- Parameters
-
| dom_node | the dom node |
| default_value | the default value if the attribute was not set. (this will be only used if is_mandatory is false) |
| is_mandatory | if set to true this function will throw if the data area is not set in sub node |
| parse_error_message | the message in the thrown exception if is_mandatory was set to true |
| mapping_reading_version | addition error information for beautifying error messages |
- Returns
- utility::Optional<T>
- Exceptions
-
| utility::Error | The function will throw only if is_mandatory is set to true. |
◆ getDataSubNode()
template<typename DomNodeType>
template<typename T>
Get the data content of a subnode of dom_node. Return a valid Optional<T> if set, otherwise return default_value or throw.
- Template Parameters
-
| T | the value type of the returned Optional |
- Parameters
-
| dom_node | the dom node |
| sub_node_name | the sub node name |
| default_value | the default value if the attribute was not set. (this will be only used if is_mandatory is false) |
| is_mandatory | if set to true this function will throw if the data area is not set in sub node |
| parse_error_message | the message in the thrown exception if is_mandatory was set to true |
| mapping_reading_version | addition error information for beautifying error messages |
- Returns
- utility::Optional<T>
- Exceptions
-
| utility::Error | The function will throw only if is_mandatory is set to true. |
◆ nodeToString()
template<typename DomNodeType>
Helper function to serialize a xml node to a string.
- Parameters
-
| dom_node | the node to serialize |
| property_stream | the stream to serialize to |
| level | the level of tabs for beautifying |
◆ setDataOrSubNodesAsProperty()
template<typename DomNodeType>
template<typename PropertiesType>
Set the Data Or Sub Nodes As Property.
- Template Parameters
-
| PropertiesType | the type of properties_target |
- Parameters
-
| dom_node | the node to serialize to a property value |
| property_name | the name of the property to set the value to |
| properties_target | the properties type to set the property |
The documentation for this struct was generated from the following file: