1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef RY_PDS_COMMON_H
18 #define RY_PDS_COMMON_H
20 #include <nel/misc/types_nl.h>
21 #include <nel/misc/i_xml.h>
24 #include <nel/misc/log.h>
36 class ITaskEventListener
40 /// Called when RBS task was done successfully
41 virtual void taskSuccessful(void* arg
) = 0;
43 /// Called when RBS task has failed
44 virtual void taskFailed(void* arg
) = 0;
55 CLocatePath() : Pos(0) {}
60 return Pos
>= FullPath
.size();
63 struct CLocateAttributeNode
65 /// The name of the attribute to locate
68 /// Is this node an array?
71 /// Is this node a set?
74 /// Key, for array and set
79 CLocateAttributeNode
& node()
91 typedef std::vector
<CLocateAttributeNode
> TLocatePath
;
93 /// Full path to value
96 /// Current pos in path
105 /// 'for' loop through xml children
106 #define FOREACH_CHILD(node, parent, type) for (node=CIXml::getFirstChildNode(parent, #type);\
108 node=CIXml::getNextChildNode(node, #type))
119 * Store node property propName into result
120 * Returns true iff the property appears in the node (but won't tell if property was of the matching type)
123 bool getProperty(xmlNodePtr node
, const char* propName
, T
&result
)
126 if (!NLMISC::CIXml::getPropertyString(res
, node
, propName
))
128 nlwarning("Couldn't get property '%s' in xml node", propName
);
131 NLMISC::fromString(res
, result
);
137 * Store node property propName into result, and if property not present in node use defaultValue instead
138 * Returns true iff the property appears in the node (but won't tell if property was of the matching type)
141 bool getProperty(xmlNodePtr node
, const char* propName
, T
&result
, const T
&defaultValue
, bool quiet
= true)
144 if (!NLMISC::CIXml::getPropertyString(res
, node
, propName
))
147 nlwarning("Couldn't get property '%s' in xml node, use '%s' value instead", propName
, NLMISC::toString(defaultValue
).c_str());
148 result
= defaultValue
;
151 NLMISC::fromString(res
, result
);
158 #endif //RY_PDS_COMMON_H