mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-26 06:50:09 +03:00
Bug #1738: Cleanup code using xpath | operator
This commit is contained in:
parent
4c27fd2fea
commit
f1eaea5662
@ -104,27 +104,15 @@ stmt: expr { result = static_cast<int>($1);}
|
||||
expr: STRING { float val = 0.0;
|
||||
|
||||
ostringstream xpath_t;
|
||||
ostringstream xpath_s;
|
||||
ostringstream xpath_c;
|
||||
|
||||
vector<string> results;
|
||||
|
||||
xpath_t << "/HOST/TEMPLATE/" << $1;
|
||||
xpath_s << "/HOST/HOST_SHARE/" << $1;
|
||||
xpath_c << "/HOST/CLUSTER_TEMPLATE/" << $1;
|
||||
xpath_t << "/HOST/TEMPLATE/" << $1
|
||||
<< "|/HOST/HOST_SHARE/" << $1
|
||||
<< "|/HOST/CLUSTER_TEMPLATE/" << $1;
|
||||
|
||||
results = (*oxml)[xpath_t.str().c_str()];
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
results = (*oxml)[xpath_s.str().c_str()];
|
||||
}
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
results = (*oxml)[xpath_c.str().c_str()];
|
||||
}
|
||||
|
||||
if (results.size() != 0)
|
||||
{
|
||||
istringstream iss(results[0]);
|
||||
|
@ -198,33 +198,13 @@ int get_xml_attribute(ObjectXML * oxml, const char* attr, int& val)
|
||||
vector<string> results;
|
||||
ostringstream xpath_t;
|
||||
|
||||
xpath_t << "/HOST/TEMPLATE/" << attr;
|
||||
xpath_t << "/HOST/TEMPLATE/" << attr
|
||||
<< "|/HOST/HOST_SHARE/" << attr
|
||||
<< "|/HOST/" << attr
|
||||
<< "|/HOST/CLUSTER_TEMPLATE/" << attr;
|
||||
|
||||
results = (*oxml)[xpath_t.str().c_str()];
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
ostringstream xpath_s;
|
||||
|
||||
xpath_s << "/HOST/HOST_SHARE/" << attr;
|
||||
results = (*oxml)[xpath_s.str().c_str()];
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
ostringstream xpath_h;
|
||||
|
||||
xpath_h << "/HOST/" << attr;
|
||||
results = (*oxml)[xpath_h.str().c_str()];
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
xpath_h.str("");
|
||||
|
||||
xpath_h << "/HOST/CLUSTER_TEMPLATE/" << attr;
|
||||
results = (*oxml)[xpath_h.str().c_str()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (results.size() != 0)
|
||||
{
|
||||
istringstream iss(results[0]);
|
||||
@ -251,33 +231,13 @@ int get_xml_attribute(ObjectXML * oxml, const char* attr, float& val)
|
||||
ostringstream xpath_t;
|
||||
vector<string> results;
|
||||
|
||||
xpath_t << "/HOST/TEMPLATE/" << attr;
|
||||
xpath_t << "/HOST/TEMPLATE/" << attr
|
||||
<< "|/HOST/HOST_SHARE/" << attr
|
||||
<< "|/HOST/" << attr
|
||||
<< "|/HOST/CLUSTER_TEMPLATE/" << attr;
|
||||
|
||||
results = (*oxml)[xpath_t.str().c_str()];
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
ostringstream xpath_s;
|
||||
|
||||
xpath_s << "/HOST/HOST_SHARE/" << attr;
|
||||
results = (*oxml)[xpath_s.str().c_str()];
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
ostringstream xpath_h;
|
||||
|
||||
xpath_h << "/HOST/" << attr;
|
||||
results = (*oxml)[xpath_h.str().c_str()];
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
xpath_h.str("");
|
||||
|
||||
xpath_h << "/HOST/CLUSTER_TEMPLATE/" << attr;
|
||||
results = (*oxml)[xpath_h.str().c_str()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (results.size() != 0)
|
||||
{
|
||||
istringstream iss(results[0]);
|
||||
@ -304,33 +264,13 @@ int get_xml_attribute(ObjectXML * oxml, const char* attr, string& val)
|
||||
ostringstream xpath_t;
|
||||
vector<string> results;
|
||||
|
||||
xpath_t << "/HOST/TEMPLATE/" << attr;
|
||||
xpath_t << "/HOST/TEMPLATE/" << attr
|
||||
<< "|/HOST/HOST_SHARE/" << attr
|
||||
<< "|/HOST/" << attr
|
||||
<< "|/HOST/CLUSTER_TEMPLATE/" << attr;
|
||||
|
||||
results = (*oxml)[xpath_t.str().c_str()];
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
ostringstream xpath_s;
|
||||
|
||||
xpath_s << "/HOST/HOST_SHARE/" << attr;
|
||||
results = (*oxml)[xpath_s.str().c_str()];
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
ostringstream xpath_h;
|
||||
|
||||
xpath_h << "/HOST/" << attr;
|
||||
results = (*oxml)[xpath_h.str().c_str()];
|
||||
|
||||
if (results.size() == 0)
|
||||
{
|
||||
xpath_h.str("");
|
||||
|
||||
xpath_h << "/HOST/CLUSTER_TEMPLATE/" << attr;
|
||||
results = (*oxml)[xpath_h.str().c_str()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (results.size() != 0)
|
||||
{
|
||||
val = results[0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user