Dev Essential
Loading...
Searching...
No Matches
ddl::mapping::MappingConfigurationFromXMLFactoryBase< DomNodeType > Struct Template Reference

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>

Static Public Member Functions

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.
 

Detailed Description

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
DomNodeTypea 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;

Member Function Documentation

◆ attributesToString()

template<typename DomNodeType>
static void ddl::mapping::MappingConfigurationFromXMLFactoryBase< DomNodeType >::attributesToString ( const std::map< std::string, std::string > & attributes,
std::stringstream & property_stream )
inlinestatic

Helper function to serialize xml attributes to a string.

Parameters
attributesthe attributes to parse
property_streamthe stream to serialize to

◆ getAttribute()

template<typename DomNodeType>
template<typename T>
static utility::Optional< T > ddl::mapping::MappingConfigurationFromXMLFactoryBase< DomNodeType >::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 = {} )
inlinestatic

Get the Attribute from the dom_node. Return a valid Optional<T> if set, otherwise return default_value or throw.

Template Parameters
Tthe value type of the returned Optional
Parameters
dom_nodethe dom node if type DomNodeType
attribute_namethe attribute name
default_valuethe default value if the attribute was not set. (this will be only used if is_mandatory is false)
is_mandatoryif set to true this function will throw if the attribute is not set in DOM
parse_error_messagethe message in the thrown exception if is_mandatory was set to true
mapping_reading_versionaddition error information for beautifying error messages
Returns
utility::Optional<T>
Exceptions
utility::ErrorThe function will throw only if is_mandatory is set to true.

◆ getData()

template<typename DomNodeType>
template<typename T>
static utility::Optional< T > ddl::mapping::MappingConfigurationFromXMLFactoryBase< DomNodeType >::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 = {} )
inlinestatic

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
Tthe value type of the returned Optional
Parameters
dom_nodethe dom node
default_valuethe default value if the attribute was not set. (this will be only used if is_mandatory is false)
is_mandatoryif set to true this function will throw if the data area is not set in sub node
parse_error_messagethe message in the thrown exception if is_mandatory was set to true
mapping_reading_versionaddition error information for beautifying error messages
Returns
utility::Optional<T>
Exceptions
utility::ErrorThe function will throw only if is_mandatory is set to true.

◆ getDataSubNode()

template<typename DomNodeType>
template<typename T>
static utility::Optional< T > ddl::mapping::MappingConfigurationFromXMLFactoryBase< DomNodeType >::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 = {} )
inlinestatic

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
Tthe value type of the returned Optional
Parameters
dom_nodethe dom node
sub_node_namethe sub node name
default_valuethe default value if the attribute was not set. (this will be only used if is_mandatory is false)
is_mandatoryif set to true this function will throw if the data area is not set in sub node
parse_error_messagethe message in the thrown exception if is_mandatory was set to true
mapping_reading_versionaddition error information for beautifying error messages
Returns
utility::Optional<T>
Exceptions
utility::ErrorThe function will throw only if is_mandatory is set to true.

◆ nodeToString()

template<typename DomNodeType>
static void ddl::mapping::MappingConfigurationFromXMLFactoryBase< DomNodeType >::nodeToString ( const DomNodeType & dom_node,
std::stringstream & property_stream,
size_t level = 0 )
inlinestatic

Helper function to serialize a xml node to a string.

Parameters
dom_nodethe node to serialize
property_streamthe stream to serialize to
levelthe level of tabs for beautifying

◆ setDataOrSubNodesAsProperty()

template<typename DomNodeType>
template<typename PropertiesType>
static void ddl::mapping::MappingConfigurationFromXMLFactoryBase< DomNodeType >::setDataOrSubNodesAsProperty ( const DomNodeType & dom_node,
const std::string & property_name,
PropertiesType & properties_target )
inlinestatic

Set the Data Or Sub Nodes As Property.

Template Parameters
PropertiesTypethe type of properties_target
Parameters
dom_nodethe node to serialize to a property value
property_namethe name of the property to set the value to
properties_targetthe properties type to set the property

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