Convenience class to load and validate a Data Definition xml string.
More...
Convenience class to load and validate a Data Definition xml string.
This implementation can be used as follows:
"<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.
◆ fromXMLString() [1/2]
Read a string containing a data definiton in XML.
- Parameters
-
struct_name | The data defintion will determine if the struct_name extists or not. |
xml_string | The 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_version | if not set the parser will have a look, if the xml_string contains a header or it guesses. |
strict | set to true to load the datamodel exactly like defined (no mixture of DDL tag definitions allowed). |
- 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::Error | if the xml string is not valid against the xsd definition! (depending on the DDL Version). |
ddl::dd::Error | if the validation level of the created DataDefinition is not at least good_enough! |
ddl::dd::Error | if the given struct_name is not part of this description. |
- Returns
- dd::DataDefinition the valid Data Definiton of the string.
◆ fromXMLString() [2/2]
Read a string containing a data definiton in XML.
- Parameters
-
xml_string | The 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_version | if not set the parser will have a look, if the xml_string contains a header or it guesses. |
strict | set to true to load the datamodel exactly like defined (no mixture of DDL tag definitions allowed). |
- 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::Error | if the xml string is not valid against the xsd definition! (depending on the DDL Version). |
ddl::dd::Error | if 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]
This will write the given valid Data Definiton into a string as xml.
- Parameters
-
dd_to_write | the 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_name | name of the struct that is written into the string. |
dd_to_write | the DataDefinition where a StructType with the name struct_name is defined. |
- Returns
- std::string the string of the DataDefinition as xml