|
Open Model Railroad Network (OpenMRN)
|
Classes | |
| struct | CDINodeRep |
| struct | NodeInfo |
| Allocation data we hold about a Data Element in its userinfo structure. More... | |
| struct | SXmlStringDeleter |
| Helper class for deleting sxml strings. More... | |
| struct | XMLDocDeleter |
| Helper class for unique_ptr to delete an XML document correctly. More... | |
Public Types | |
| enum class | DataType { UNKNOWN = 0 , GROUP , INT , FLOAT , STRING , EVENTID } |
| Used to classify elements. More... | |
| typedef std::unique_ptr< XMLDoc, XMLDocDeleter > | xmldoc_ptr_t |
| Smart pointer class for holding XML documents. | |
| typedef std::unique_ptr< const SXML_CHAR, SXmlStringDeleter > | xmlstring_t |
| Smart pointer class for holding C strings from sxml. | |
Static Public Member Functions | |
| static XMLNode * | find_child_or_null (const XMLNode *parent, const char *tag) |
| Searches the list of children for the first child with a specific tag. | |
| static string | find_node_name (const XMLNode *node, const char *def) |
| Finds the name of a CDI element. | |
| static string | find_node_description (const XMLNode *node) |
| Find the description of a CDI element. | |
| static int | find_numeric_element (const XMLNode *parent, const char *tag, bool *found) |
| static int | find_node_min (const XMLNode *node, bool *found) |
| Finds the min value of the xml integer, if there isn't one it returns a null pointer. | |
| static int | find_node_max (const XMLNode *node, bool *found) |
| Finds the max value of the xml integer, if there isn't one it returns a null pointer. | |
| static int | find_node_default (const XMLNode *node, bool *found) |
| Finds the default value of the xml integer, if there isn't one it returns a null pointer. | |
| static void | prepare_doc (XMLDoc *doc) |
| Clears out all user info structure pointers. | |
| static void | cleanup_doc (XMLDoc *doc) |
| Deletes all userinfo structures allocated in a doc. | |
| template<class T , typename... Args> | |
| static void | new_userinfo (T **info, XMLNode *node, Args &&... args) |
| Allocates a new object of type T for the node as userinfo; calls T's constructor with args..., stores the resulting pointer in the userinfo pointer of node. | |
| template<class T > | |
| static void | get_userinfo (T **info, const XMLNode *node) |
| Retrieve the userinfo structure from an XML node. | |
| static int | get_numeric_attribute (const XMLNode *node, const char *attr_name, int def=0) |
| Helper function to find and convert an attribute to a number. | |
| static DataType | get_type_from_node (XMLNode *child) |
| Classifies XML elements to node types. | |
| static void | layout_segment (XMLNode *segment) |
| Allocates all userinfo structures within a segment and performs the offset layout algorithm. | |
| static int | get_replication (const XMLNode *group) |
Private Member Functions | |
| CDIUtils () | |
| Static class; never instantiated. | |
Definition at line 43 of file CDIUtils.hxx.
| typedef std::unique_ptr<XMLDoc, XMLDocDeleter> openlcb::CDIUtils::xmldoc_ptr_t |
Smart pointer class for holding XML documents.
Definition at line 61 of file CDIUtils.hxx.
| typedef std::unique_ptr<const SXML_CHAR, SXmlStringDeleter> openlcb::CDIUtils::xmlstring_t |
Smart pointer class for holding C strings from sxml.
Appropriately frees the string upon going out of scope.
Definition at line 74 of file CDIUtils.hxx.
|
strong |
Used to classify elements.
Definition at line 265 of file CDIUtils.hxx.
|
inlinestatic |
Deletes all userinfo structures allocated in a doc.
| doc | document to clean up. |
Definition at line 188 of file CDIUtils.hxx.
|
inlinestatic |
Searches the list of children for the first child with a specific tag.
| parent | is the node whose children to search. |
| tag | is which child to look for. |
Definition at line 81 of file CDIUtils.hxx.
|
inlinestatic |
Finds the default value of the xml integer, if there isn't one it returns a null pointer.
| node | is a CDI element (segment, group, or config element). |
| found | will be set to true if there was a defaultimum found, false if the XML did not contain the respective tag. |
Definition at line 167 of file CDIUtils.hxx.
|
inlinestatic |
Find the description of a CDI element.
| node | is a CDI element (segment, group, or config element). |
Definition at line 113 of file CDIUtils.hxx.
|
inlinestatic |
Finds the max value of the xml integer, if there isn't one it returns a null pointer.
| node | is a CDI element (segment, group, or config element). |
| found | will be set to true if there was a maximum found, false if the XML did not contain the respective tag. |
Definition at line 156 of file CDIUtils.hxx.
|
inlinestatic |
Finds the min value of the xml integer, if there isn't one it returns a null pointer.
| node | is a CDI element (segment, group, or config element). |
| found | will be set to true if there was a minimum found, false if the XML did not contain the respective tag. |
Definition at line 145 of file CDIUtils.hxx.
|
inlinestatic |
Finds the name of a CDI element.
| node | is a CDI element (segment, group, or config element). |
| def | is the default to return if no <name> element exists or if it has no text. |
Definition at line 100 of file CDIUtils.hxx.
|
inlinestatic |
Definition at line 125 of file CDIUtils.hxx.
|
inlinestatic |
Helper function to find and convert an attribute to a number.
| node | is the XML node of the element whose attribute we're looking for |
| attr_name | is a C-string for the attribute name we're looking for |
| def | is the default value that will be returned if the attribute is not found. |
def if not found, or zero if the attribute is found but the value is not convertible to an integer. Definition at line 250 of file CDIUtils.hxx.
|
inlinestatic |
| group | is the XML node of the <group> element to query. |
Definition at line 392 of file CDIUtils.hxx.
|
inlinestatic |
Classifies XML elements to node types.
| child | is an XML element under a group. |
Definition at line 277 of file CDIUtils.hxx.
|
inlinestatic |
Retrieve the userinfo structure from an XML node.
| info | will be set to the userinfo structure using an unchecked cast to T. This variable must be of the same (or compatible) type as what the userinfo has been allocated to. |
| node | is the XML element node whose userinfo we are trying to fetch |
Definition at line 223 of file CDIUtils.hxx.
|
inlinestatic |
Allocates all userinfo structures within a segment and performs the offset layout algorithm.
| segment | is the XML node of the <segment> element. |
Definition at line 305 of file CDIUtils.hxx.
|
inlinestatic |
Allocates a new object of type T for the node as userinfo; calls T's constructor with args..., stores the resulting pointer in the userinfo pointer of node.
| info | output argument for the userinfo structure pointer. |
| node | which XML node the userinfo should point at. |
| args... | forwarded as the constructor arguments for T (can be empty). |
Definition at line 207 of file CDIUtils.hxx.
|
inlinestatic |
Clears out all user info structure pointers.
This is necessary to use the new_userinfo call below. Call this after the XML has been successfully parsed.
| doc | document to prepare up. |
Definition at line 176 of file CDIUtils.hxx.