diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/slice/Ice/Properties.ice | 12 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 19 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.h | 1 |
3 files changed, 32 insertions, 0 deletions
diff --git a/cpp/slice/Ice/Properties.ice b/cpp/slice/Ice/Properties.ice index c8051bdc9e8..64caa9fa58b 100644 --- a/cpp/slice/Ice/Properties.ice +++ b/cpp/slice/Ice/Properties.ice @@ -58,6 +58,18 @@ local interface Properties /** * + * Get all properties whose keys begins with + * <replaceable>prefix</replaceable>. If + * <replaceable>prefix</replaceable> is an empty string, + * then all properties are returned. + * + * @return The matching properties, in [key,value] pairs. + * + **/ + StringSeq getProperties(string prefix); + + /** + * * Set a property. * * @param key The property key. diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 11a0d1aa7ca..8f3767b2530 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -50,6 +50,25 @@ Ice::PropertiesI::getPropertyWithDefault(const string& key, const string& value) } } +StringSeq +Ice::PropertiesI::getProperties(const string& prefix) +{ + IceUtil::Mutex::Lock sync(*this); + + StringSeq result; + map<string, string>::const_iterator p; + for (p = _properties.begin(); p != _properties.end(); ++p) + { + if (prefix.empty() || p->first.find(prefix) == 0) + { + result.push_back(p->first); + result.push_back(p->second); + } + } + + return result; +} + void Ice::PropertiesI::setProperty(const string& key, const string& value) { diff --git a/cpp/src/Ice/PropertiesI.h b/cpp/src/Ice/PropertiesI.h index d134544016e..f97e368bad8 100644 --- a/cpp/src/Ice/PropertiesI.h +++ b/cpp/src/Ice/PropertiesI.h @@ -24,6 +24,7 @@ public: virtual std::string getProperty(const std::string&); virtual std::string getPropertyWithDefault(const std::string&, const std::string&); + virtual StringSeq getProperties(const std::string&); virtual void setProperty(const std::string&, const std::string&); virtual StringSeq getCommandLineOptions(); virtual PropertiesPtr clone(); |