diff options
Diffstat (limited to 'cpp/src/IceGrid/Util.cpp')
-rw-r--r-- | cpp/src/IceGrid/Util.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cpp/src/IceGrid/Util.cpp b/cpp/src/IceGrid/Util.cpp index 5b0fc8d72fc..3d402b4f278 100644 --- a/cpp/src/IceGrid/Util.cpp +++ b/cpp/src/IceGrid/Util.cpp @@ -78,6 +78,31 @@ IceGrid::getProperty(const PropertyDescriptorSeq& properties, const string& name return result; } +int +IceGrid::getPropertyAsInt(const PropertyDescriptorSeq& properties, const string& name, int def) +{ + string strVal; + for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q) + { + if(q->name == name) + { + strVal = q->value; + } + } + + int result = def; + + if(!strVal.empty()) + { + istringstream v(strVal); + if(!(v >> result) || !v.eof()) + { + result = def; + } + } + return result; +} + bool IceGrid::hasProperty(const PropertyDescriptorSeq& properties, const string& name) { |