Commit 08a0a0f9 authored by Vitaly Lipatov's avatar Vitaly Lipatov

introduce getPintProp for get positive only values (returns def if the value…

introduce getPintProp for get positive only values (returns def if the value zero or negative). Note: def may be negative if needed.
parent 3c165914
...@@ -81,6 +81,8 @@ public: ...@@ -81,6 +81,8 @@ public:
// name node // name node
static std::string getProp(xmlNode* node, const std::string name); static std::string getProp(xmlNode* node, const std::string name);
static int getIntProp(xmlNode* node, const std::string name); static int getIntProp(xmlNode* node, const std::string name);
/// if value if not positive ( <= 0 ), returns def
static int getPIntProp(xmlNode* node, const std::string name, int def);
// name node // name node
static void setProp(xmlNode* node, const std::string name, const std::string text); static void setProp(xmlNode* node, const std::string name, const std::string text);
...@@ -126,6 +128,8 @@ class UniXML_iterator ...@@ -126,6 +128,8 @@ class UniXML_iterator
std::string getProp(const std::string name); std::string getProp(const std::string name);
int getIntProp(const std::string name); int getIntProp(const std::string name);
/// if value if not positive ( <= 0 ), returns def
int getPIntProp(const std::string name, int def);
void setProp(const std::string name, const std::string text); void setProp(const std::string name, const std::string text);
/*! . false, */ /*! . false, */
......
...@@ -213,6 +213,14 @@ int UniXML::getIntProp(xmlNode* node, const string name ) ...@@ -213,6 +213,14 @@ int UniXML::getIntProp(xmlNode* node, const string name )
return UniSetTypes::uni_atoi((const char*)::xmlGetProp(node, (const xmlChar*)name.c_str())); return UniSetTypes::uni_atoi((const char*)::xmlGetProp(node, (const xmlChar*)name.c_str()));
} }
int UniXML::getPIntProp(xmlNode* node, const string name, int def )
{
int i = getIntProp(node, name);
if (i <= 0)
return def;
return i;
}
void UniXML::setProp(xmlNode* node, string name, string text) void UniXML::setProp(xmlNode* node, string name, string text)
{ {
xmlSetProp(node, (const xmlChar*)name.c_str(), local2xml(text)); xmlSetProp(node, (const xmlChar*)name.c_str(), local2xml(text));
...@@ -448,6 +456,15 @@ int UniXML_iterator::getIntProp( const string name ) ...@@ -448,6 +456,15 @@ int UniXML_iterator::getIntProp( const string name )
{ {
return UniSetTypes::uni_atoi((char*)::xmlGetProp(curNode, (const xmlChar*)name.c_str())); return UniSetTypes::uni_atoi((char*)::xmlGetProp(curNode, (const xmlChar*)name.c_str()));
} }
int UniXML_iterator::getPIntProp( const string name, int def )
{
int i = getIntProp(name);
if (i <= 0)
return def;
return i;
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void UniXML_iterator::setProp( const string name, const string text ) void UniXML_iterator::setProp( const string name, const string text )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment