Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom.git into Dev_0.6.1
[modules/shaper.git] / src / Config / Config_Common.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * Config_Common.h
5  *
6  *  Created on: Apr 17, 2014
7  *      Author: sbh
8  */
9
10 #ifndef CONFIG_COMMON_H_
11 #define CONFIG_COMMON_H_
12
13 #include "Config_def.h"
14
15 #include <string>
16 #include <list>
17 #include <stdarg.h>
18
19 //>> Forward declaration of xmlNodePtr.
20 typedef struct _xmlNode xmlNode;
21 typedef xmlNode *xmlNodePtr;
22 struct _xmlNode;
23 //<<
24
25 //>> Forward declaration of xmlDocPtr.
26 typedef struct _xmlDoc xmlDoc;
27 typedef xmlDoc *xmlDocPtr;
28 struct _xmlDoc;
29 //<<
30
31 /*
32  * Returns true if theNode is XML ELEMENT node (not a "text" node ie).
33  */
34 CONFIG_EXPORT bool isElementNode(xmlNodePtr theNode);
35
36 /*
37  * Returns true if theNode is XML node with a given name.
38
39  * Please note that this function should be called with NULL last argument.
40  * In example: isNode(aNode, "type1", ["type2", ...], NULL);
41  * ", NULL" is required to use unlimited number of arguments.
42  * TODO(sbh): find a way to simplify calling this method.
43  */
44 CONFIG_EXPORT bool isNode(xmlNodePtr theNode, const char* theNodeName, ...);
45
46 /*
47  * Checks is the given node is attribute (widget) node.
48  */
49 CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
50
51 /*
52  * Every xml node has child. Even if there is no explicit
53  * child nodes libxml gives the "Text node" as child.
54  *
55  * This method checks if real child nodes exist in the
56  * given node.
57  */
58 CONFIG_EXPORT bool hasChild(xmlNodePtr theNode);
59
60 /*
61  * Returns named property for an id node as std::string and the parameters of the node.
62  */
63 CONFIG_EXPORT bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId,
64                                      std::list<std::string>& outValidatorParameters);
65
66 /*!
67  \brief Convert the given parameter to the platform-specific library name.
68
69  The function appends platform-specific prefix (lib) and suffix (.dll/.so)
70  to the library file name.
71  For example, if \a str = "mylib", "libmylib.so" is returned for Linux and
72  mylib.dll for Windows.
73
74  \param str short library name
75  \return full library name
76  */
77 CONFIG_EXPORT std::string library(const std::string& theLibName);
78
79 /*
80  * Returns named property for a given node as std::string.
81  */
82 CONFIG_EXPORT std::string getProperty(xmlNodePtr theNode, const char* thePropName);
83
84 /*
85  * Checks if the given XML node has the given attribute,
86  * if yes - returns it's bool value, if no, or if the value can not
87  * be converted to bool - returns theDefault value.
88  * \param theAttributeName attribute to check
89  * \param theDefault default value on bad data
90  * \return the boolean result
91  */
92 CONFIG_EXPORT bool getBooleanAttribute(xmlNodePtr theNode,
93                                        const char* theAttributeName,
94                                        bool theDefault);
95
96 #endif