ADTF  3.18.2
DDFromXMLFactory< DOM_NODE_TYPE >

Factory to create a DataDefinition out of a XML based description. More...

Static Public Member Functions

static bool isInteger (const std::string &string_to_check)
 Checks if the given string is an integer value. More...
 
static utility::Optional< int > toType (const std::string &from_string, const utility::Optional< int > &default_value={})
 specialized conversion to the Optional<int32_t> More...
 
static utility::Optional< size_t > toType (const std::string &from_string, const utility::Optional< size_t > &default_value={})
 specialized conversion to the Optional<size_t> More...
 
static utility::Optional< std::string > toType (const std::string &from_string, const utility::Optional< std::string > &default_value={})
 specialized function to convert a string to an optional string which is only valid if set. More...
 
template<typename T >
static utility::Optional< T > getAttribute (const DOM_NODE_TYPE &dom_node, const char *attribute_name, const utility::Optional< T > &default_value={}, bool is_mandatory=false, const std::string &parse_error_message={})
 Get the Attribute from the dom_node. More...
 
template<typename T >
static utility::Optional< T > getData (const DOM_NODE_TYPE &dom_node, const std::string &sub_node_name, const utility::Optional< T > &default_value={}, bool is_mandatory=false, const char *parse_error_message="")
 Get the data content of a subnode of dom_node. More...
 
static datamodel::Header::ExtDeclaration createHeaderExtDeclaration (const DOM_NODE_TYPE &dom_node)
 Create a Header Ext Declaration object. More...
 
static datamodel::Header createHeader (const DOM_NODE_TYPE &dom_node)
 Create a Header object. More...
 
static datamodel::BaseUnit createBaseUnit (const DOM_NODE_TYPE &dom_node)
 Create a Base Unit object. More...
 
static datamodel::UnitPrefix createUnitPrefix (const DOM_NODE_TYPE &dom_node)
 Create a Unit Prefix object. More...
 
static datamodel::Unit::RefUnit createRefUnit (const DOM_NODE_TYPE &dom_node)
 Create a Ref Unit object. More...
 
static datamodel::Unit createUnit (const DOM_NODE_TYPE &dom_node)
 Create a Unit object. More...
 
static datamodel::DataType createDataType (const DOM_NODE_TYPE &dom_node, const Version &file_ddl_version, bool strict)
 Create a Data Type object. More...
 
static datamodel::EnumType::Element createEnumTypeElement (const DOM_NODE_TYPE &dom_node)
 Create a Enum Type Element object. More...
 
static datamodel::EnumType createEnumType (const DOM_NODE_TYPE &dom_node)
 Create a Enum Type object. More...
 
static datamodel::StructType::Element createStructTypeElement (const DOM_NODE_TYPE &dom_node, const Version &file_ddl_version, bool strict)
 Create a Struct Type Element object. More...
 
static datamodel::StructType createStructType (const DOM_NODE_TYPE &dom_node, const Version &file_ddl_version, bool strict)
 Create a Struct Type object. More...
 
static datamodel::StreamMetaType::Property createStreamMetaTypeProperty (const DOM_NODE_TYPE &dom_node)
 Create a Stream Meta Type Property object. More...
 
static datamodel::StreamMetaType createStreamMetaType (const DOM_NODE_TYPE &dom_node)
 Create a Stream Meta Type object. More...
 
static datamodel::Stream::Struct createStreamStruct (const DOM_NODE_TYPE &dom_node)
 Create a Stream Struct object. More...
 
static datamodel::Stream createStream (const DOM_NODE_TYPE &dom_node)
 Create a Stream object. More...
 
static datamodel::DataDefinition createDD (const DOM_NODE_TYPE &dom_node, const dd::Version &language_version, bool strict)
 Creates a whole DataDefinition and read all sub node. More...
 

Detailed Description

template<typename DOM_NODE_TYPE>
struct ddl::dd::DDFromXMLFactory< DOM_NODE_TYPE >

Factory to create a DataDefinition out of a XML based description.

This factory uses a template type DOM_NODE_TYPE which is design to follow the a concept class type definition of the a_util::DOMElement.

Template Parameters
DOM_NODE_TYPEa DOMElement class must implement following funtions:
  • string getAttribute(const std::string& name) const;
  • string getData() const;
  • bool findNode(const std::string& node_name, DOM_NODE_TYPE& result_node) const;
  • bool findNodes(const std::string& node_names, std::list<DOM_NODE_TYPE>& result_nodes) const;

Definition at line 45 of file xml_ddfromxml_factory.h.

Member Function Documentation

◆ createBaseUnit()

static datamodel::BaseUnit createBaseUnit ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Base Unit object.

Parameters
dom_nodethe node to create the BaseUnit from (should be "baseunit" tag name).
Returns
datamodel::BaseUnit

Definition at line 275 of file xml_ddfromxml_factory.h.

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createDD().

◆ createDataType()

static datamodel::DataType createDataType ( const DOM_NODE_TYPE &  dom_node,
const Version file_ddl_version,
bool  strict 
)
inlinestatic

Create a Data Type object.

Parameters
dom_nodethe node to create the DataType from (should be "datatype" tag name).
file_ddl_versionthe set filename language verion (from header)
strictset to true to load the datamodel exactly like defined (no mixture of DDL tag definitions allowed).
Returns
datamodel::DataType

Definition at line 354 of file xml_ddfromxml_factory.h.

References PredefinedDataTypes::getDefaultAlignment(), PredefinedDataTypes::getInstance(), and ddl::dd::unit.

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createDD().

◆ createDD()

◆ createEnumType()

static datamodel::EnumType createEnumType ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Enum Type object.

Parameters
dom_nodethe node to create the EnumType from (should be "enum" tag name).
Returns
datamodel::EnumType

Definition at line 446 of file xml_ddfromxml_factory.h.

References DDFromXMLFactory< DOM_NODE_TYPE >::createEnumTypeElement().

◆ createEnumTypeElement()

static datamodel::EnumType::Element createEnumTypeElement ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Enum Type Element object.

Parameters
dom_nodethe node to create the EnumType::Element from (should be "element" tag name).
Returns
datamodel::EnumType::Element

Definition at line 431 of file xml_ddfromxml_factory.h.

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createEnumType().

◆ createHeader()

static datamodel::Header createHeader ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Header object.

Parameters
dom_nodethe node to create the header from (should be "header" tag name).
Returns
datamodel::Header

Definition at line 232 of file xml_ddfromxml_factory.h.

References DDFromXMLFactory< DOM_NODE_TYPE >::createHeaderExtDeclaration(), VersionConversion::fromString(), and Header::setAuthor().

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createDD().

◆ createHeaderExtDeclaration()

static datamodel::Header::ExtDeclaration createHeaderExtDeclaration ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Header Ext Declaration object.

Parameters
dom_nodethe node to create the ExDeclaration from (should be "ext_declaration" tag name).
Returns
datamodel::Header::ExtDeclaration

Definition at line 208 of file xml_ddfromxml_factory.h.

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createHeader().

◆ createRefUnit()

static datamodel::Unit::RefUnit createRefUnit ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Ref Unit object.

Parameters
dom_nodethe node to create the RefUnit from (should be "refUnit" tag name).
Returns
datamodel::Unit::RefUnit

Definition at line 307 of file xml_ddfromxml_factory.h.

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createUnit().

◆ createStream()

static datamodel::Stream createStream ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Stream object.

Parameters
dom_nodenode to create the Stream from (should be "stream" tag name).
Returns
datamodel::Stream

Definition at line 809 of file xml_ddfromxml_factory.h.

References DDFromXMLFactory< DOM_NODE_TYPE >::createStreamStruct(), TypeAccessList< DDL_TYPE_TO_ACCESS, TYPE_VALIDATOR_CLASS >::emplace(), Stream::getStructs(), and Stream::setDescription().

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createDD().

◆ createStreamMetaType()

static datamodel::StreamMetaType createStreamMetaType ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Stream Meta Type object.

Parameters
dom_nodenode to create the StreamMetaType from (should be "streammetatype" tag name).
Returns
datamodel::StreamMetaType

Definition at line 759 of file xml_ddfromxml_factory.h.

References DDFromXMLFactory< DOM_NODE_TYPE >::createStreamMetaTypeProperty(), and StreamMetaType::setParent().

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createDD().

◆ createStreamMetaTypeProperty()

static datamodel::StreamMetaType::Property createStreamMetaTypeProperty ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Stream Meta Type Property object.

Parameters
dom_nodenode to create the StreamMetaType::Property from (should be "property" tag name).
Returns
datamodel::StreamMetaType::Property

Definition at line 735 of file xml_ddfromxml_factory.h.

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createStreamMetaType().

◆ createStreamStruct()

static datamodel::Stream::Struct createStreamStruct ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Stream Struct object.

Parameters
dom_nodenode to create the Stream::Struct from (should be "struct" tag name).
Returns
datamodel::Stream::Struct

Definition at line 794 of file xml_ddfromxml_factory.h.

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createStream().

◆ createStructType()

static datamodel::StructType createStructType ( const DOM_NODE_TYPE &  dom_node,
const Version file_ddl_version,
bool  strict 
)
inlinestatic

Create a Struct Type object.

Parameters
dom_nodenode to create the StructType from (should be "struct" tag name).
file_ddl_versionthe set filename language verion (from header)
strictset to true to load the datamodel exactly like defined (no mixture of DDL tag definitions allowed).
Returns
datamodel::StructType

Definition at line 675 of file xml_ddfromxml_factory.h.

References DDFromXMLFactory< DOM_NODE_TYPE >::createStructTypeElement(), AlignmentConversion::fromString(), VersionConversion::fromString(), and ddl::dd::struct_type.

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createDD().

◆ createStructTypeElement()

static datamodel::StructType::Element createStructTypeElement ( const DOM_NODE_TYPE &  dom_node,
const Version file_ddl_version,
bool  strict 
)
inlinestatic

Create a Struct Type Element object.

Parameters
dom_nodethe node to create the StructType::Element from (should be "element" tag name).
file_ddl_versionthe set filename language verion (from header)
strictset to true to load the datamodel exactly like defined (no mixture of DDL tag definitions allowed).
Returns
datamodel::StructType::Element

Definition at line 474 of file xml_ddfromxml_factory.h.

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createStructType().

◆ createUnit()

static datamodel::Unit createUnit ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Unit object.

Parameters
dom_nodethe node to create the Unit from (should be "unit" tag name).
Returns
datamodel::Unit

Definition at line 324 of file xml_ddfromxml_factory.h.

References DDFromXMLFactory< DOM_NODE_TYPE >::createRefUnit().

◆ createUnitPrefix()

static datamodel::UnitPrefix createUnitPrefix ( const DOM_NODE_TYPE &  dom_node)
inlinestatic

Create a Unit Prefix object.

Parameters
dom_nodethe node to create the UnitPrefix from (should be "prefixes" tag name).
Returns
datamodel::UnitPrefix

Definition at line 290 of file xml_ddfromxml_factory.h.

Referenced by DDFromXMLFactory< DOM_NODE_TYPE >::createDD().

◆ getAttribute()

static utility::Optional<T> getAttribute ( const DOM_NODE_TYPE &  dom_node,
const char *  attribute_name,
const utility::Optional< T > &  default_value = {},
bool  is_mandatory = false,
const std::string &  parse_error_message = {} 
)
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 (see also DDFromXMLFactory)
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
Returns
utility::Optional<T>
Exceptions
dd::ErrorThe function will throw only if is_mandatory is set to true.

Definition at line 142 of file xml_ddfromxml_factory.h.

◆ getData()

static utility::Optional<T> getData ( const DOM_NODE_TYPE &  dom_node,
const std::string &  sub_node_name,
const utility::Optional< T > &  default_value = {},
bool  is_mandatory = false,
const char *  parse_error_message = "" 
)
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 (see also DDFromXMLFactory)
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
Returns
utility::Optional<T>
Exceptions
dd::ErrorThe function will throw only if is_mandatory is set to true.

Definition at line 178 of file xml_ddfromxml_factory.h.

◆ isInteger()

static bool isInteger ( const std::string &  string_to_check)
inlinestatic

Checks if the given string is an integer value.

Parameters
[in]string_to_checkthe string to check
Returns
true/false

Definition at line 51 of file xml_ddfromxml_factory.h.

References ddl::dd::utility::isInteger().

◆ toType() [1/3]

static utility::Optional<int> toType ( const std::string &  from_string,
const utility::Optional< int > &  default_value = {} 
)
inlinestatic

specialized conversion to the Optional<int32_t>

Parameters
from_stringstring representation of the value
default_valuethe optional value to set if not set in from_string
Returns
utility::Optional<int>

Definition at line 63 of file xml_ddfromxml_factory.h.

◆ toType() [2/3]

static utility::Optional<size_t> toType ( const std::string &  from_string,
const utility::Optional< size_t > &  default_value = {} 
)
inlinestatic

specialized conversion to the Optional<size_t>

Parameters
from_stringstring representation of the value
default_valuethe optional value to set if not set in from_string
Returns
utility::Optional<size_t>

Definition at line 85 of file xml_ddfromxml_factory.h.

◆ toType() [3/3]

static utility::Optional<std::string> toType ( const std::string &  from_string,
const utility::Optional< std::string > &  default_value = {} 
)
inlinestatic

specialized function to convert a string to an optional string which is only valid if set.

Parameters
from_stringthe string to convert from
default_valuethe optional value to set if from_string is empty
Returns
utility::Optional<std::string>

Definition at line 114 of file xml_ddfromxml_factory.h.