diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-03-24 17:31:42 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-03-24 17:31:42 +0000 |
commit | 83200b6de517b3634769090fd04523ab25a8942b (patch) | |
tree | 8f380f4bdddd77c48167bc3eee0679d1107f0328 /cpp/src/IceGrid/DescriptorHelper.cpp | |
parent | Fixed bug 916 (diff) | |
download | ice-83200b6de517b3634769090fd04523ab25a8942b.tar.bz2 ice-83200b6de517b3634769090fd04523ab25a8942b.tar.xz ice-83200b6de517b3634769090fd04523ab25a8942b.zip |
Fixed bug 885 and 920
Diffstat (limited to 'cpp/src/IceGrid/DescriptorHelper.cpp')
-rw-r--r-- | cpp/src/IceGrid/DescriptorHelper.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp index bf82a95a24c..ae35ff622b6 100644 --- a/cpp/src/IceGrid/DescriptorHelper.cpp +++ b/cpp/src/IceGrid/DescriptorHelper.cpp @@ -353,8 +353,13 @@ Resolver::asInt(const string& value, const string& name) const string v = operator()(value, name); if(!v.empty()) { + string::size_type beg = v.find_first_not_of(' '); + string::size_type end = v.find_last_not_of(' '); + v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1); + int val; - if(!(istringstream(v) >> val)) + istringstream is(v); + if(!(is >> val) || !is.eof()) { DeploymentException ex; ex.reason = "invalid value `" + value + "' for `" + name + "' in " + _context + ": not an integer"; @@ -364,6 +369,29 @@ Resolver::asInt(const string& value, const string& name) const return v; } +string +Resolver::asFloat(const string& value, const string& name) const +{ + string v = operator()(value, name); + if(!v.empty()) + { + string::size_type beg = v.find_first_not_of(' '); + string::size_type end = v.find_last_not_of(' '); + v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1); + + float val; + istringstream is(v); + if(!(is >> val) || !is.eof()) + { + DeploymentException ex; + ex.reason = "invalid value `" + value + "' for `" + name + "' in " + _context + ": not a float"; + throw ex; + } + cerr << v << " " << val << endl; + } + return v; +} + void Resolver::setReserved(const string& name, const string& value) { @@ -1488,7 +1516,7 @@ NodeHelper::instantiate(const Resolver& resolve) const { NodeDescriptor desc; desc.variables = _definition.variables; - desc.loadFactor = resolve(_definition.loadFactor, "load factor"); + desc.loadFactor = resolve.asFloat(_definition.loadFactor, "load factor"); desc.description = resolve(_definition.description, "description"); ServerInstanceHelperDict::const_iterator r; for(r = _serverInstances.begin(); r != _serverInstances.end(); ++r) |