Salome HOME
The obligatory and concealment attribute's properties now registers in model by speci...
[modules/shaper.git] / src / Config / Config_Common.h
1 /*
2  * Config_Common.h
3  *
4  *  Created on: Apr 17, 2014
5  *      Author: sbh
6  */
7
8 #ifndef CONFIG_COMMON_H_
9 #define CONFIG_COMMON_H_
10
11 #include "Config_def.h"
12
13 #include <string>
14 #include <list>
15 #include <stdarg.h>
16
17 //>> Forward declaration of xmlNodePtr.
18 typedef struct _xmlNode xmlNode;
19 typedef xmlNode *xmlNodePtr;
20 struct _xmlNode;
21 //<<
22
23 //>> Forward declaration of xmlDocPtr.
24 typedef struct _xmlDoc xmlDoc;
25 typedef xmlDoc *xmlDocPtr;
26 struct _xmlDoc;
27 //<<
28
29 /*
30  * Returns true if theNode is XML ELEMENT node (not a "text" node ie).
31  */
32 CONFIG_EXPORT bool isElementNode(xmlNodePtr theNode);
33
34 /*
35  * Returns true if theNode is XML node with a given name.
36
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.
41  */
42 CONFIG_EXPORT bool isNode(xmlNodePtr theNode, const char* theNodeName, ...);
43
44 /*
45  * Checks is the given node is attribute (widget) node.
46  */
47 CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
48
49 /*
50  * Every xml node has child. Even if there is no explicit
51  * child nodes libxml gives the "Text node" as child.
52  *
53  * This method checks if real child nodes exist in the
54  * given node.
55  */
56 CONFIG_EXPORT bool hasChild(xmlNodePtr theNode);
57
58 /*
59  *
60  */
61 CONFIG_EXPORT bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,
62                                     std::list<std::string>& outValidatorParameters);
63
64 /*!
65  \brief Convert the given parameter to the platform-specific library name.
66
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.
71
72  \param str short library name
73  \return full library name
74  */
75 CONFIG_EXPORT std::string library(const std::string& theLibName);
76
77 /*
78  * Returns named property for a given node as std::string.
79  */
80 CONFIG_EXPORT std::string getProperty(xmlNodePtr theNode, const char* thePropName);
81
82 /*
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
89  */
90 CONFIG_EXPORT bool getBooleanAttribute(xmlNodePtr theNode,
91                                        const char* theAttributeName,
92                                        bool theDefault);
93
94 #endif