diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-05-10 15:13:17 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-05-10 15:13:17 +0000 |
commit | ddad611afa296fe49141b006d8cdd0dc0d273ead (patch) | |
tree | e43a7e254ce485ce9416a985a3d3e1473db00ddc /cpp/src | |
parent | adding support for --clone (diff) | |
download | ice-ddad611afa296fe49141b006d8cdd0dc0d273ead.tar.bz2 ice-ddad611afa296fe49141b006d8cdd0dc0d273ead.tar.xz ice-ddad611afa296fe49141b006d8cdd0dc0d273ead.zip |
allow multiple files in Ice.Config
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 82 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.h | 2 |
2 files changed, 44 insertions, 40 deletions
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 3493d5aa8fd..e8a7a9b8c16 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -167,12 +167,7 @@ Ice::PropertiesI::clone() Ice::PropertiesI::PropertiesI() { - const char* s = getenv("ICE_CONFIG"); - if (s && *s != '\0') - { - load(s); - setProperty("Ice.Config", s); - } + loadConfig(); } Ice::PropertiesI::PropertiesI(StringSeq& args) @@ -196,23 +191,7 @@ Ice::PropertiesI::PropertiesI(StringSeq& args) } } - string file = getProperty("Ice.Config"); - - if (file.empty() || file == "1") - { - const char* s = getenv("ICE_CONFIG"); - if (s && *s != '\0') - { - file = s; - } - } - - if (!file.empty()) - { - load(file); - } - - setProperty("Ice.Config", file); + loadConfig(); } Ice::PropertiesI::PropertiesI(int& argc, char* argv[]) @@ -235,23 +214,7 @@ Ice::PropertiesI::PropertiesI(int& argc, char* argv[]) } } - string file = getProperty("Ice.Config"); - - if (file.empty() || file == "1") - { - const char* s = getenv("ICE_CONFIG"); - if (s && *s != '\0') - { - file = s; - } - } - - if (!file.empty()) - { - load(file); - } - - setProperty("Ice.Config", file); + loadConfig(); if (argc > 0) { @@ -312,3 +275,42 @@ Ice::PropertiesI::parseLine(const string& line) setProperty(key, value); } + +void +Ice::PropertiesI::loadConfig() +{ + string value = getProperty("Ice.Config"); + + if (value.empty() || value == "1") + { + const char* s = getenv("ICE_CONFIG"); + if (s && *s != '\0') + { + value = s; + } + } + + if (!value.empty()) + { + static const string delim = " \t\r\n"; + string::size_type beg = value.find_first_not_of(delim); + while (beg != string::npos) + { + string::size_type end = value.find(",", beg); + string file; + if (end == string::npos) + { + file = value.substr(beg); + beg = end; + } + else + { + file = value.substr(beg, end - beg); + beg = value.find_first_not_of("," + delim, end); + } + load(file); + } + } + + setProperty("Ice.Config", value); +} diff --git a/cpp/src/Ice/PropertiesI.h b/cpp/src/Ice/PropertiesI.h index 1857eba479a..4e301f68306 100644 --- a/cpp/src/Ice/PropertiesI.h +++ b/cpp/src/Ice/PropertiesI.h @@ -44,6 +44,8 @@ private: void parseLine(const std::string&); + void loadConfig(); + std::map<std::string, std::string> _properties; }; |