ADTF  3.18.2
DDString

Convenience class to load and validate a Data Definition xml string. More...

Static Public Member Functions

static dd::DataDefinition fromXMLString (const std::string &xml_string, const dd::Version &ddl_language_version=dd::Version(0, 0), bool strict=false)
 Read a string containing a data definiton in XML. More...
 
static dd::DataDefinition fromXMLString (const std::string &struct_name, const std::string &xml_string, const dd::Version &ddl_language_version=dd::Version(0, 0), bool strict=false)
 Read a string containing a data definiton in XML. More...
 
static std::string toXMLString (const dd::DataDefinition &dd_to_write)
 This will write the given valid Data Definiton into a string as xml. More...
 
static std::string toXMLString (const std::string &struct_name, const dd::DataDefinition &dd_to_write)
 This will write the given valid Data Definiton into a string as xml, but only vith all depending Definition of the StructType with the name struct_name. More...
 

Detailed Description

Convenience class to load and validate a Data Definition xml string.


This implementation can be used as follows:

//(1) read the whole string and provide the contained DDL
// if there are validation errors, see @ref ddl::dd::Error::problems
auto my_dd_1 = DDString::fromXMLString("<struct name=\"mystruct\" version=\"1\"></struct>");
//(2) read the whole string and extract the contained DDL for a given struct.
// if there are validation errors, see @ref ddl::dd::Error::problems
auto my_dd_2 = DDString::fromXMLString("mystruct",
"<struct name=\"mystruct\" version=\"1\"></struct>");
static dd::DataDefinition fromXMLString(const std::string &xml_string, const dd::Version &ddl_language_version=dd::Version(0, 0), bool strict=false)
Read a string containing a data definiton in XML.
See also
DDString::fromXMLString, DDString::toXMLString

Definition at line 45 of file ddstring.h.

Member Function Documentation

◆ fromXMLString() [1/2]

static dd::DataDefinition fromXMLString ( const std::string &  struct_name,
const std::string &  xml_string,
const dd::Version ddl_language_version = dd::Version(0, 0),
bool  strict = false 
)
static

Read a string containing a data definiton in XML.

Parameters
struct_nameThe data defintion will determine if the struct_name extists or not.
xml_stringThe data defintion may contain a fully XML defined or parts of it. (struct tag only, structs tag only, datatype only ... etc. but valid!)
ddl_language_versionif not set the parser will have a look, if the xml_string contains a header or it guesses.
strictset to true to load the datamodel exactly like defined (no mixture of DDL tag definitions allowed).
Remarks
Usually, the xml string contains a header with a ddl version. If no header is found (yes this is possible), the default version for reading a DD with DDString is always the current latest ddl version (
See also
ddl::dd::Version::getLatestVersion), but the parser will detect the "struct" layout and will set the "ddl_version" of the struct!
You may force a version with the help of ddl_language_version, which is taken into account if no header and so no ddl version is set within the string.
Exceptions
ddl::dd::Errorif the xml string is not valid against the xsd definition! (depending on the DDL Version).
ddl::dd::Errorif the validation level of the created DataDefinition is not at least good_enough!
ddl::dd::Errorif the given struct_name is not part of this description.
Returns
dd::DataDefinition the valid Data Definiton of the string.

◆ fromXMLString() [2/2]

static dd::DataDefinition fromXMLString ( const std::string &  xml_string,
const dd::Version ddl_language_version = dd::Version(0, 0),
bool  strict = false 
)
static

Read a string containing a data definiton in XML.

Parameters
xml_stringThe data defintion may contain a fully XML defined or parts of it. (struct tag only, structs tag only, datatype only ... etc. but valid!)
ddl_language_versionif not set the parser will have a look, if the xml_string contains a header or it guesses.
strictset to true to load the datamodel exactly like defined (no mixture of DDL tag definitions allowed).
Remarks
Usually, the xml string contains a header with a ddl version. If no header is found (yes this is possible), the default version for reading a DD with DDString is always the current latest ddl version (
See also
ddl::dd::Version::getLatestVersion), but the parser will detect the "struct" layout and will set the "ddl_version" of the struct!
You may force a version with the help of ddl_language_version, which is taken into account if no header and so no ddl version is set within the string.
Exceptions
ddl::dd::Errorif the xml string is not valid against the xsd definition! (depending on the DDL Version).
ddl::dd::Errorif the validation level of the created DataDefinition is not at least good_enough!
Returns
dd::DataDefinition the valid Data Definiton of the string.

◆ toXMLString() [1/2]

static std::string toXMLString ( const dd::DataDefinition dd_to_write)
static

This will write the given valid Data Definiton into a string as xml.

Parameters
dd_to_writethe DataDefinition to write into a string.
Returns
std::string the string of the DataDefinition as xml

◆ toXMLString() [2/2]

static std::string toXMLString ( const std::string &  struct_name,
const dd::DataDefinition dd_to_write 
)
static

This will write the given valid Data Definiton into a string as xml, but only vith all depending Definition of the StructType with the name struct_name.

Parameters
struct_namename of the struct that is written into the string.
dd_to_writethe DataDefinition where a StructType with the name struct_name is defined.
Returns
std::string the string of the DataDefinition as xml