Commit 3fbc638a authored by Vitaly Lipatov's avatar Vitaly Lipatov

Configuration: add getPIntField, getIntProp, getPIntProp, getArgPint

parent e3418768
...@@ -71,6 +71,8 @@ namespace UniSetTypes ...@@ -71,6 +71,8 @@ namespace UniSetTypes
std::string getField(const std::string path); std::string getField(const std::string path);
/// ԣ path /// ԣ path
int getIntField(const std::string path); int getIntField(const std::string path);
/// ԣ path ( def, <= 0)
int getPIntField(const std::string path, int def);
xmlNode* findNode(xmlNode* node, const std::string searchnode, const std::string name = "" ); xmlNode* findNode(xmlNode* node, const std::string searchnode, const std::string name = "" );
...@@ -78,6 +80,8 @@ namespace UniSetTypes ...@@ -78,6 +80,8 @@ namespace UniSetTypes
xmlNode* getNode(const std::string& path); xmlNode* getNode(const std::string& path);
// //
std::string getProp(xmlNode*, const std::string name); std::string getProp(xmlNode*, const std::string name);
int getIntProp(xmlNode*, const std::string name);
int getPIntProp(xmlNode*, const std::string name, int def);
// //
std::string getPropByNodeName(const std::string& nodename, const std::string& prop); std::string getPropByNodeName(const std::string& nodename, const std::string& prop);
...@@ -132,8 +136,11 @@ namespace UniSetTypes ...@@ -132,8 +136,11 @@ namespace UniSetTypes
/*! , */ /*! , */
std::string getArgParam(const std::string name, const std::string defval=""); std::string getArgParam(const std::string name, const std::string defval="");
/*! , , 0 */ /*! , , 0. , defval */
int getArgInt(const std::string name, const std::string defval=""); int getArgInt(const std::string name, const std::string defval="");
/*! , , defval */
int getArgPInt(const std::string name, int defval);
int getArgPInt(const std::string name, const std::string strdefval, int defval);
xmlNode* initDebug( DebugStream& deb, const std::string& nodename ); xmlNode* initDebug( DebugStream& deb, const std::string& nodename );
......
...@@ -410,6 +410,22 @@ int Configuration::getArgInt( const string name, const string defval ) ...@@ -410,6 +410,22 @@ int Configuration::getArgInt( const string name, const string defval )
return UniSetTypes::uni_atoi(getArgParam( name, defval )); return UniSetTypes::uni_atoi(getArgParam( name, defval ));
} }
int Configuration::getArgPInt( const string name, int defval )
{
int i = getArgInt(name);
if ( i <= 0 )
return defval;
return i;
}
int Configuration::getArgPInt( const string name, const string strdefval, int defval )
{
int i = getArgInt(name, strdefval);
if ( i <= 0 )
return defval;
return i;
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// ????????????? ????????... (??? ???????????) // ????????????? ????????... (??? ???????????)
...@@ -569,13 +585,23 @@ xmlNode* Configuration::getNode(const string& path) ...@@ -569,13 +585,23 @@ xmlNode* Configuration::getNode(const string& path)
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string Configuration::getProp(xmlNode* node, const string name) string Configuration::getProp(xmlNode* node, const string name)
{ {
return UniXML::getProp(node,name); return UniXML::getProp(node, name);
}
int Configuration::getIntProp(xmlNode* node, const string name)
{
return UniXML::getIntProp(node, name);
} }
int Configuration::getPIntProp(xmlNode* node, const string name, int def)
{
return UniXML::getPIntProp(node, name, def);
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string Configuration::getField(const string path) string Configuration::getField(const string path)
{ {
return getProp(getNode(path),"name"); return getProp(getNode(path),"name");
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
int Configuration::getIntField(const std::string path) int Configuration::getIntField(const std::string path)
{ {
...@@ -583,6 +609,15 @@ int Configuration::getIntField(const std::string path) ...@@ -583,6 +609,15 @@ int Configuration::getIntField(const std::string path)
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
int Configuration::getPIntField(const std::string path, int def)
{
int i = getIntField(path);;
if (i <= 0)
return def;
return i;
}
// -------------------------------------------------------------------------
xmlNode* Configuration::findNode(xmlNode* node, const std::string snode, const std::string sname) xmlNode* Configuration::findNode(xmlNode* node, const std::string snode, const std::string sname)
{ {
if( !unixml.isOpen() ) if( !unixml.isOpen() )
......
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