4 * Created on: Apr 17, 2014
8 #ifndef CONFIG_COMMON_H_
9 #define CONFIG_COMMON_H_
11 #include "Config_def.h"
17 //>> Forward declaration of xmlNodePtr.
18 typedef struct _xmlNode xmlNode;
19 typedef xmlNode *xmlNodePtr;
23 //>> Forward declaration of xmlDocPtr.
24 typedef struct _xmlDoc xmlDoc;
25 typedef xmlDoc *xmlDocPtr;
30 * Returns true if theNode is XML ELEMENT node (not a "text" node ie).
32 CONFIG_EXPORT bool isElementNode(xmlNodePtr theNode);
35 * Returns true if theNode is XML node with a given name.
37 * Please note that this function should be called with NULL last argument.
38 * In example: isNode(aNode, "type1", ["type2", ...], NULL);
39 * ", NULL" is required to use unlimited number of arguments.
40 * TODO(sbh): find a way to simplify calling this method.
42 CONFIG_EXPORT bool isNode(xmlNodePtr theNode, const char* theNodeName, ...);
45 * Checks is the given node is attribute (widget) node.
47 CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
50 * Every xml node has child. Even if there is no explicit
51 * child nodes libxml gives the "Text node" as child.
53 * This method checks if real child nodes exist in the
56 CONFIG_EXPORT bool hasChild(xmlNodePtr theNode);
61 CONFIG_EXPORT bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,
62 std::list<std::string>& outValidatorParameters);
65 \brief Convert the given parameter to the platform-specific library name.
67 The function appends platform-specific prefix (lib) and suffix (.dll/.so)
68 to the library file name.
69 For example, if \a str = "mylib", "libmylib.so" is returned for Linux and
70 mylib.dll for Windows.
72 \param str short library name
73 \return full library name
75 CONFIG_EXPORT std::string library(const std::string& theLibName);
78 * Returns named property for a given node as std::string.
80 CONFIG_EXPORT std::string getProperty(xmlNodePtr theNode, const char* thePropName);
83 * Checks if the given XML node has the given attribute,
84 * if yes - returns it's bool value, if no, or if the value can not
85 * be converted to bool - returns theDefault value.
86 * \param theAttributeName attribute to check
87 * \param theDefault default value on bad data
88 * \return the boolean result
90 CONFIG_EXPORT bool getBooleanAttribute(xmlNodePtr theNode,
91 const char* theAttributeName,