summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/PluginManagerI.cpp75
-rw-r--r--cpp/src/Ice/PropertiesI.cpp25
-rw-r--r--cpp/src/Ice/ProxyFactory.cpp60
-rw-r--r--cpp/src/IceBox/ServiceManagerI.cpp25
-rw-r--r--cpp/src/IceGrid/Client.cpp20
-rw-r--r--cpp/src/IceGrid/IceGridNode.cpp18
-rw-r--r--cpp/src/IceGrid/NodeI.cpp88
-rw-r--r--cpp/src/IceSSL/Instance.cpp26
-rw-r--r--cpp/src/IceSSL/Instance.h3
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp2
10 files changed, 103 insertions, 239 deletions
diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp
index 4a850896e5b..ec7bae151d0 100644
--- a/cpp/src/Ice/PluginManagerI.cpp
+++ b/cpp/src/Ice/PluginManagerI.cpp
@@ -161,56 +161,39 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
PropertiesPtr properties = _communicator->getProperties();
PropertyDict plugins = properties->getPropertiesForPrefix(prefix);
- string loadOrder = properties->getProperty("Ice.PluginLoadOrder");
- string::size_type beg = 0;
- if(!loadOrder.empty())
+ StringSeq loadOrder = properties->getPropertyAsList("Ice.PluginLoadOrder");
+ for(StringSeq::const_iterator p = loadOrder.begin(); p != loadOrder.end(); ++p)
{
- const string delim = ", \t\n";
- beg = loadOrder.find_first_not_of(delim, beg);
- while(beg != string::npos)
- {
- string name;
- string::size_type end = loadOrder.find_first_of(delim, beg);
- if(end == string::npos)
- {
- name = loadOrder.substr(beg);
- beg = end;
- }
- else
- {
- name = loadOrder.substr(beg, end - beg);
- beg = loadOrder.find_first_not_of(delim, end);
- }
+ string name = *p;
- map<string, PluginPtr>::iterator p = _plugins.find(name);
- if(p != _plugins.end())
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "plugin `" + name + "' already loaded";
- throw ex;
- }
+ map<string, PluginPtr>::iterator p = _plugins.find(name);
+ if(p != _plugins.end())
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "plugin `" + name + "' already loaded";
+ throw ex;
+ }
- PropertyDict::iterator q = plugins.find("Ice.Plugin." + name + ".cpp");
- if(q == plugins.end())
- {
- q = plugins.find("Ice.Plugin." + name);
- }
- else
- {
- plugins.erase("Ice.Plugin." + name);
- }
+ PropertyDict::iterator q = plugins.find("Ice.Plugin." + name + ".cpp");
+ if(q == plugins.end())
+ {
+ q = plugins.find("Ice.Plugin." + name);
+ }
+ else
+ {
+ plugins.erase("Ice.Plugin." + name);
+ }
- if(q != plugins.end())
- {
- loadPlugin(name, q->second, cmdArgs);
- plugins.erase(q);
- }
- else
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "plugin `" + name + "' not defined";
- throw ex;
- }
+ if(q != plugins.end())
+ {
+ loadPlugin(name, q->second, cmdArgs);
+ plugins.erase(q);
+ }
+ else
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "plugin `" + name + "' not defined";
+ throw ex;
}
}
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp
index cc60f9bde79..bf8840badbe 100644
--- a/cpp/src/Ice/PropertiesI.cpp
+++ b/cpp/src/Ice/PropertiesI.cpp
@@ -101,7 +101,7 @@ Ice::PropertiesI::getPropertyAsListWithDefault(const string& key, const StringSe
p->second.used = true;
StringSeq result;
- if(!IceUtilInternal::splitString(p->second.value, " \t\n", result))
+ if(!IceUtilInternal::splitString(p->second.value, ", \t\n", result))
{
Warning out(getProcessLogger());
out << "mismatched quotes in property " << key << "'s value, returning default value";
@@ -486,29 +486,14 @@ Ice::PropertiesI::loadConfig()
if(s && *s != '\0')
{
value = s;
+ setProperty("Ice.Config", value);
}
}
- if(!value.empty())
+ StringSeq files = getPropertyAsList("Ice.Config");
+ for(StringSeq::const_iterator p = files.begin(); p != files.end(); ++p)
{
- 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);
- }
+ load(*p);
}
PropertyValue pv(value, true);
diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp
index f55a159bb6c..bd378d74896 100644
--- a/cpp/src/Ice/ProxyFactory.cpp
+++ b/cpp/src/Ice/ProxyFactory.cpp
@@ -223,53 +223,33 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co
IceInternal::ProxyFactory::ProxyFactory(const InstancePtr& instance) :
_instance(instance)
{
- string str = _instance->initializationData().properties->getPropertyWithDefault("Ice.RetryIntervals", "0");
-
- string::size_type beg;
- string::size_type end = 0;
-
- while(true)
+ StringSeq retryValues = _instance->initializationData().properties->getPropertyAsList("Ice.RetryIntervals");
+ if(retryValues.size() == 0)
{
- const string delim = " \t";
-
- beg = str.find_first_not_of(delim, end);
- if(beg == string::npos)
+ _retryIntervals.push_back(0);
+ }
+ else
+ {
+ for(StringSeq::const_iterator p = retryValues.begin(); p != retryValues.end(); ++p)
{
- if(_retryIntervals.empty())
+ istringstream value(*p);
+
+ int v;
+ if(!(value >> v) || !value.eof())
{
- _retryIntervals.push_back(0);
+ v = 0;
}
- break;
- }
-
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
-
- if(beg == end)
- {
- break;
- }
-
- istringstream value(str.substr(beg, end - beg));
- int v;
- if(!(value >> v) || !value.eof())
- {
- v = 0;
- }
+ //
+ // If -1 is the first value, no retry and wait intervals.
+ //
+ if(v == -1 && _retryIntervals.empty())
+ {
+ break;
+ }
- //
- // If -1 is the first value, no retry and wait intervals.
- //
- if(v == -1 && _retryIntervals.empty())
- {
- break;
+ _retryIntervals.push_back(v > 0 ? v : 0);
}
-
- _retryIntervals.push_back(v > 0 ? v : 0);
}
}
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp
index fecb1285761..759a9c58072 100644
--- a/cpp/src/IceBox/ServiceManagerI.cpp
+++ b/cpp/src/IceBox/ServiceManagerI.cpp
@@ -357,30 +357,6 @@ IceBox::ServiceManagerI::start()
}
//
- // Parse the IceBox.LoadOrder property.
- //
- string order = properties->getProperty("IceBox.LoadOrder");
- StringSeq loadOrder;
- if(!order.empty())
- {
- string::size_type beg = order.find_first_not_of(",\t ");
- while(beg != string::npos)
- {
- string::size_type end = order.find_first_of(",\t ", beg);
- if(end == string::npos)
- {
- loadOrder.push_back(order.substr(beg));
- beg = end;
- }
- else
- {
- loadOrder.push_back(order.substr(beg, end - beg));
- beg = order.find_first_not_of(",\t ", end);
- }
- }
- }
-
- //
// Load and start the services defined in the property set
// with the prefix "IceBox.Service.". These properties should
// have the following format:
@@ -393,6 +369,7 @@ IceBox::ServiceManagerI::start()
const string prefix = "IceBox.Service.";
PropertyDict services = properties->getPropertiesForPrefix(prefix);
PropertyDict::iterator p;
+ StringSeq loadOrder = properties->getPropertyAsList("IceBox.LoadOrder");
for(StringSeq::const_iterator q = loadOrder.begin(); q != loadOrder.end(); ++q)
{
p = services.find(prefix + *q);
diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp
index 3bbc3d03c19..3a20680cdd3 100644
--- a/cpp/src/IceGrid/Client.cpp
+++ b/cpp/src/IceGrid/Client.cpp
@@ -11,6 +11,7 @@
#include <IceUtil/Options.h>
#include <IceUtil/CtrlCHandler.h>
#include <IceUtil/Thread.h>
+#include <IceUtil/StringUtil.h>
#include <Ice/Ice.h>
#include <Ice/SliceChecksums.h>
#include <IceGrid/Parser.h>
@@ -99,7 +100,6 @@ public:
Ice::CommunicatorPtr communicator() const { return _communicator; }
const char* appName() const { return _appName; }
- string trim(const string&);
string getPassword(const string&);
private:
@@ -380,7 +380,7 @@ Client::run(int argc, char* argv[])
{
cout << "user id: " << flush;
getline(cin, id);
- id = trim(id);
+ id = IceUtilInternal::trim(id);
}
if(password.empty())
@@ -486,7 +486,7 @@ Client::run(int argc, char* argv[])
{
cout << "user id: " << flush;
getline(cin, id);
- id = trim(id);
+ id = IceUtilInternal::trim(id);
}
if(password.empty())
@@ -615,18 +615,6 @@ Client::run(int argc, char* argv[])
}
string
-Client::trim(const string& s)
-{
- static const string delims = "\t\r\n ";
- string::size_type last = s.find_last_not_of(delims);
- if(last != string::npos)
- {
- return s.substr(s.find_first_not_of(delims), last+1);
- }
- return s;
-}
-
-string
Client::getPassword(const string& prompt)
{
cout << prompt << flush;
@@ -648,5 +636,5 @@ Client::getPassword(const string& prompt)
}
#endif
cout << endl;
- return trim(password);
+ return IceUtilInternal::trim(password);
}
diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp
index 575c4120c89..9f997d2b577 100644
--- a/cpp/src/IceGrid/IceGridNode.cpp
+++ b/cpp/src/IceGrid/IceGridNode.cpp
@@ -9,6 +9,7 @@
#include <IceUtil/UUID.h>
#include <IceUtil/Timer.h>
+#include <IceUtil/StringUtil.h>
#include <Ice/Ice.h>
#include <Ice/Locator.h>
#include <Ice/Service.h>
@@ -83,7 +84,6 @@ protected:
private:
void usage(const std::string&);
- string trim(const string&);
ActivatorPtr _activator;
IceUtil::TimerPtr _timer;
@@ -583,14 +583,14 @@ NodeService::start(int argc, char* argv[])
{
cout << "user id: " << flush;
getline(cin, id);
- id = trim(id);
+ id = IceUtilInternal::trim(id);
}
if(password.empty())
{
cout << "password: " << flush;
getline(cin, password);
- password = trim(password);
+ password = IceUtilInternal::trim(password);
}
session = registry->createAdminSession(id, password);
@@ -812,18 +812,6 @@ NodeService::usage(const string& appName)
print("Usage: " + appName + " [options]\n" + options);
}
-string
-NodeService::trim(const string& s)
-{
- static const string delims = "\t\r\n ";
- string::size_type last = s.find_last_not_of(delims);
- if(last != string::npos)
- {
- return s.substr(s.find_first_not_of(delims), last+1);
- }
- return s;
-}
-
int
main(int argc, char* argv[])
{
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp
index 1d3629245c9..899511f95a9 100644
--- a/cpp/src/IceGrid/NodeI.cpp
+++ b/cpp/src/IceGrid/NodeI.cpp
@@ -228,65 +228,45 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
//
// Parse the properties override property.
//
- string overrides = props->getProperty("IceGrid.Node.PropertiesOverride");
- Ice::StringSeq propsAsArgs;
- if(!overrides.empty())
+ Ice::StringSeq overrides = props->getPropertyAsList("IceGrid.Node.PropertiesOverride");
+ for(Ice::StringSeq::const_iterator p = overrides.begin(); p != overrides.end(); ++p)
{
- string::size_type end = 0;
- while(end != string::npos)
- {
- const string delim = " \t\r\n";
-
- string::size_type beg = overrides.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = overrides.find_first_of(delim, beg);
- string arg;
- if(end == string::npos)
- {
- arg = overrides.substr(beg);
- }
- else
- {
- arg = overrides.substr(beg, end - beg);
- }
+ string arg = *p;
- if(arg.find("--") == 0)
- {
- arg = arg.substr(2);
- }
+ const string delim = " \t\r\n";
- //
- // Extract the key/value
- //
- string::size_type argEnd = arg.find_first_of(delim + "=");
- if(argEnd == string::npos)
- {
- continue;
- }
-
- string key = arg.substr(0, argEnd);
-
- argEnd = arg.find('=', argEnd);
- if(argEnd == string::npos)
- {
- return;
- }
- ++argEnd;
-
- string value;
- string::size_type argBeg = arg.find_first_not_of(delim, argEnd);
- if(argBeg != string::npos)
- {
- argEnd = arg.length();
- value = arg.substr(argBeg, argEnd - argBeg);
- }
+ if(arg.find("--") == 0)
+ {
+ arg = arg.substr(2);
+ }
- _propertiesOverride.push_back(createProperty(key, value));
+ //
+ // Extract the key/value
+ //
+ string::size_type argEnd = arg.find_first_of(delim + "=");
+ if(argEnd == string::npos)
+ {
+ continue;
+ }
+
+ string key = arg.substr(0, argEnd);
+
+ argEnd = arg.find('=', argEnd);
+ if(argEnd == string::npos)
+ {
+ return;
}
+ ++argEnd;
+
+ string value;
+ string::size_type argBeg = arg.find_first_not_of(delim, argEnd);
+ if(argBeg != string::npos)
+ {
+ argEnd = arg.length();
+ value = arg.substr(argBeg, argEnd - argBeg);
+ }
+
+ _propertiesOverride.push_back(createProperty(key, value));
}
}
diff --git a/cpp/src/IceSSL/Instance.cpp b/cpp/src/IceSSL/Instance.cpp
index 50ae4a9f516..b0109240528 100644
--- a/cpp/src/IceSSL/Instance.cpp
+++ b/cpp/src/IceSSL/Instance.cpp
@@ -146,7 +146,7 @@ IceSSL::Instance::initialize()
// Select protocols.
//
{
- string protocols = properties->getProperty(propPrefix + "Protocols");
+ StringSeq protocols = properties->getPropertyAsList(propPrefix + "Protocols");
if(!protocols.empty())
{
parseProtocols(protocols);
@@ -841,30 +841,12 @@ IceSSL::Instance::traceConnection(SSL* ssl, bool incoming)
}
void
-IceSSL::Instance::parseProtocols(const string& val)
+IceSSL::Instance::parseProtocols(const StringSeq& protocols)
{
- const string delim = ", ";
bool sslv3 = false, tlsv1 = false;
- string::size_type pos = 0;
- while(pos != string::npos)
+ for(Ice::StringSeq::const_iterator p = protocols.begin(); p != protocols.end(); ++p)
{
- pos = val.find_first_not_of(delim, pos);
- if(pos == string::npos)
- {
- break;
- }
-
- string prot;
- string::size_type end = val.find_first_of(delim, pos);
- if(end == string::npos)
- {
- prot = val.substr(pos);
- }
- else
- {
- prot = val.substr(pos, end - pos);
- }
- pos = end;
+ string prot = *p;
if(prot == "ssl3" || prot == "sslv3")
{
diff --git a/cpp/src/IceSSL/Instance.h b/cpp/src/IceSSL/Instance.h
index 39a81808013..4cf354760f2 100644
--- a/cpp/src/IceSSL/Instance.h
+++ b/cpp/src/IceSSL/Instance.h
@@ -18,6 +18,7 @@
#include <Ice/ProtocolPluginFacadeF.h>
#include <IceSSL/Plugin.h>
#include <IceSSL/TrustManagerF.h>
+#include <Ice/BuiltinSequences.h>
namespace IceSSL
{
@@ -62,7 +63,7 @@ public:
private:
- void parseProtocols(const std::string&);
+ void parseProtocols(const Ice::StringSeq&);
Ice::LoggerPtr _logger;
IceInternal::ProtocolPluginFacadePtr _facade;
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp
index 54e1a1d6253..2d56cf06a93 100644
--- a/cpp/src/IceUtil/StringUtil.cpp
+++ b/cpp/src/IceUtil/StringUtil.cpp
@@ -370,7 +370,7 @@ IceUtilInternal::splitString(const string& str, const string& delim, vector<stri
string
IceUtilInternal::trim(const string& s)
{
- const string delim = " \t\r\n";
+ static const string delim = " \t\r\n";
if(s.length() != 0)
{
string::size_type beg = s.find_first_not_of(delim);