summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Initialize.cpp16
-rw-r--r--cpp/src/Ice/PropertiesI.cpp40
-rw-r--r--cpp/src/Ice/PropertiesI.h2
3 files changed, 58 insertions, 0 deletions
diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp
index 6bff3fa51ec..dcb044b42e4 100644
--- a/cpp/src/Ice/Initialize.cpp
+++ b/cpp/src/Ice/Initialize.cpp
@@ -73,6 +73,16 @@ Ice::getDefaultProperties()
}
PropertiesPtr
+Ice::getDefaultProperties(StringSeq& args)
+{
+ if (!defaultProperties)
+ {
+ defaultProperties = createProperties(args);
+ }
+ return defaultProperties;
+}
+
+PropertiesPtr
Ice::getDefaultProperties(int& argc, char* argv[])
{
if (!defaultProperties)
@@ -89,6 +99,12 @@ Ice::createProperties()
}
PropertiesPtr
+Ice::createProperties(StringSeq& args)
+{
+ return new PropertiesI(args);
+}
+
+PropertiesPtr
Ice::createProperties(int& argc, char* argv[])
{
return new PropertiesI(argc, argv);
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp
index 8454ac62371..3493d5aa8fd 100644
--- a/cpp/src/Ice/PropertiesI.cpp
+++ b/cpp/src/Ice/PropertiesI.cpp
@@ -175,6 +175,46 @@ Ice::PropertiesI::PropertiesI()
}
}
+Ice::PropertiesI::PropertiesI(StringSeq& args)
+{
+ StringSeq::iterator q = args.begin();
+ while (q != args.end())
+ {
+ string s = *q;
+ if (s.find("--Ice.Config") == 0)
+ {
+ if (s.find('=') == string::npos)
+ {
+ s += "=1";
+ }
+ parseLine(s.substr(2));
+ args.erase(q);
+ }
+ else
+ {
+ ++q;
+ }
+ }
+
+ 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);
+}
+
Ice::PropertiesI::PropertiesI(int& argc, char* argv[])
{
for (int i = 1; i < argc; ++i)
diff --git a/cpp/src/Ice/PropertiesI.h b/cpp/src/Ice/PropertiesI.h
index 5c1ea0656a2..1857eba479a 100644
--- a/cpp/src/Ice/PropertiesI.h
+++ b/cpp/src/Ice/PropertiesI.h
@@ -36,8 +36,10 @@ public:
private:
PropertiesI();
+ PropertiesI(StringSeq&);
PropertiesI(int&, char*[]);
friend ICE_API PropertiesPtr createProperties();
+ friend ICE_API PropertiesPtr createProperties(StringSeq&);
friend ICE_API PropertiesPtr createProperties(int&, char*[]);
void parseLine(const std::string&);