mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-25 16:46:17 +00:00
Changed: Don't use CSString
--HG-- branch : develop
This commit is contained in:
parent
e94b06066f
commit
532a81f5cb
1 changed files with 31 additions and 17 deletions
|
@ -17,7 +17,6 @@
|
||||||
#include "stdmisc.h"
|
#include "stdmisc.h"
|
||||||
|
|
||||||
#include "nel/misc/i_xml.h"
|
#include "nel/misc/i_xml.h"
|
||||||
#include "nel/misc/sstring.h"
|
|
||||||
|
|
||||||
#ifndef NL_DONT_USE_EXTERNAL_CODE
|
#ifndef NL_DONT_USE_EXTERNAL_CODE
|
||||||
|
|
||||||
|
@ -1067,6 +1066,7 @@ bool CIXml::getPropertyString (std::string &result, xmlNodePtr node, const std::
|
||||||
// Found
|
// Found
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1074,18 +1074,21 @@ bool CIXml::getPropertyString (std::string &result, xmlNodePtr node, const std::
|
||||||
|
|
||||||
int CIXml::getIntProperty(xmlNodePtr node, const std::string &property, int defaultValue)
|
int CIXml::getIntProperty(xmlNodePtr node, const std::string &property, int defaultValue)
|
||||||
{
|
{
|
||||||
CSString s;
|
std::string s;
|
||||||
bool b;
|
|
||||||
|
|
||||||
b=getPropertyString(s,node,property);
|
bool b = getPropertyString(s, node, property);
|
||||||
if (b==false)
|
|
||||||
|
if (!b)
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
|
||||||
s=s.strip();
|
// remove leading and trailing spaces
|
||||||
sint val=s.atoi();
|
s = trim(s);
|
||||||
if (val==0 && s!="0")
|
|
||||||
|
sint val;
|
||||||
|
|
||||||
|
if (!fromString(s, val) || (val == 0 && s != "0"))
|
||||||
{
|
{
|
||||||
nlwarning("bad integer value: %s",s.c_str());
|
nlwarning("Bad integer value: %s",s.c_str());
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1096,14 +1099,25 @@ int CIXml::getIntProperty(xmlNodePtr node, const std::string &property, int defa
|
||||||
|
|
||||||
double CIXml::getFloatProperty(xmlNodePtr node, const std::string &property, float defaultValue)
|
double CIXml::getFloatProperty(xmlNodePtr node, const std::string &property, float defaultValue)
|
||||||
{
|
{
|
||||||
CSString s;
|
std::string s;
|
||||||
bool b;
|
|
||||||
|
|
||||||
b=getPropertyString(s,node,property);
|
bool b = getPropertyString(s, node, property);
|
||||||
if (b==false)
|
|
||||||
|
if (!b)
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
|
||||||
return s.strip().atof();
|
// remove leading and trailing spaces
|
||||||
|
s = trim(s);
|
||||||
|
|
||||||
|
float val;
|
||||||
|
|
||||||
|
if (!fromString(s, val))
|
||||||
|
{
|
||||||
|
nlwarning("Bad float value: %s", s.c_str());
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -1111,10 +1125,10 @@ double CIXml::getFloatProperty(xmlNodePtr node, const std::string &property, flo
|
||||||
std::string CIXml::getStringProperty(xmlNodePtr node, const std::string &property, const std::string& defaultValue)
|
std::string CIXml::getStringProperty(xmlNodePtr node, const std::string &property, const std::string& defaultValue)
|
||||||
{
|
{
|
||||||
std::string s;
|
std::string s;
|
||||||
bool b;
|
|
||||||
|
|
||||||
b=getPropertyString(s,node,property);
|
bool b = getPropertyString(s, node, property);
|
||||||
if (b==false)
|
|
||||||
|
if (!b)
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
Loading…
Reference in a new issue