本文整理汇总了C++中StringSeq::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ StringSeq::begin方法的具体用法?C++ StringSeq::begin怎么用?C++ StringSeq::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringSeq
的用法示例。
在下文中一共展示了StringSeq::begin方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
Ice::stringSeqToArgs(const StringSeq& args, int& argc, char* argv[])
{
//
// Shift all elements in argv which are present in args to the
// beginning of argv.
//
int i = 0;
while(i < argc)
{
if(find(args.begin(), args.end(), argv[i]) == args.end())
{
for(int j = i; j < argc - 1; j++)
{
argv[j] = argv[j + 1];
}
--argc;
}
else
{
++i;
}
}
//
// Make sure that argv[argc] == 0, the ISO C++ standard requires this.
//
if(argv)
{
argv[argc] = 0;
}
}
示例2: value
IceInternal::ProxyFactory::ProxyFactory(const InstancePtr& instance) :
_instance(instance)
{
StringSeq retryValues = _instance->initializationData().properties->getPropertyAsList("Ice.RetryIntervals");
if(retryValues.size() == 0)
{
_retryIntervals.push_back(0);
}
else
{
for(StringSeq::const_iterator p = retryValues.begin(); p != retryValues.end(); ++p)
{
istringstream value(*p);
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;
}
_retryIntervals.push_back(v > 0 ? v : 0);
}
}
}
示例3: getClassList
void ScriptSystem::getClassList(const char* prefix, bool sort, StringSeq& result) const {
ClassInfoDict::const_iterator it = m_classInfoReg.begin();
size_t prefixlen = 0;
if (prefix) {
prefixlen = strlen(prefix);
}
for (; it != m_classInfoReg.end(); ++it) {
ClassInfo* ci = it->second;
if (prefixlen) {
if (strncmp(prefix, ci->m_className.c_str(), prefixlen) != 0) {
continue;
}
result.push_back(ci->m_className.c_str() + prefixlen);
} else {
result.push_back(ci->m_className);
}
}
if (sort) {
std::sort(result.begin(), result.end(), std::less<String>());
}
}
示例4: findSensor
void golem::findSensor(const Sensor::Map& sensors, const StringSeq& idSeq, Sensor::Seq& sensorSeq) {
for (StringSeq::const_iterator i = idSeq.begin(); i != idSeq.end(); ++i) {
golem::Sensor::Map::const_iterator pSensor = std::find_if(sensors.begin(), sensors.end(), [=](const golem::Sensor::Map::value_type& val) -> bool { return val.first == *i; });
if (pSensor == sensors.end())
throw Message(Message::LEVEL_CRIT, "findSensor(): unknown sensor id: %s", i->c_str());
sensorSeq.push_back(pSensor->second.get());
}
}
示例5: getProcessStringConverter
void
Ice::stringSeqToArgs(const StringSeq& args, int& argc, const wchar_t* argv[])
{
//
// Don't need to use a wide string converter argv is expected to
// come from Windows API.
//
const StringConverterPtr converter = getProcessStringConverter();
//
// Shift all elements in argv which are present in args to the
// beginning of argv. We record the original value of argc so
// that we can know later if we've shifted the array.
//
const int argcOrig = argc;
int i = 0;
while(i < argc)
{
if(find(args.begin(), args.end(), wstringToString(argv[i], converter)) == args.end())
{
for(int j = i; j < argc - 1; j++)
{
argv[j] = argv[j + 1];
}
--argc;
}
else
{
++i;
}
}
//
// Make sure that argv[argc] == 0, the ISO C++ standard requires this.
// We can only do this if we've shifted the array, otherwise argv[argc]
// may point to an invalid address.
//
if(argv && argcOrig != argc)
{
argv[argc] = 0;
}
}
示例6: newCallback
IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) :
_communicator(communicator),
_adminEnabled(false),
_pendingStatusChanges(false),
_traceServiceObserver(0)
{
#ifndef ICE_CPP11_MAPPING
const_cast<CallbackPtr&>(_observerCompletedCB) = newCallback(this, &ServiceManagerI::observerCompleted);
#endif
_logger = _communicator->getLogger();
PropertiesPtr props = _communicator->getProperties();
_traceServiceObserver = props->getPropertyAsInt("IceBox.Trace.ServiceObserver");
if(props->getProperty("Ice.Admin.Enabled") == "")
{
_adminEnabled = props->getProperty("Ice.Admin.Endpoints") != "";
}
else
{
_adminEnabled = props->getPropertyAsInt("Ice.Admin.Enabled") > 0;
}
if(_adminEnabled)
{
StringSeq facetSeq = props->getPropertyAsList("Ice.Admin.Facets");
if(!facetSeq.empty())
{
_adminFacetFilter.insert(facetSeq.begin(), facetSeq.end());
}
}
for(int i = 1; i < argc; i++)
{
_argv.push_back(argv[i]);
}
}
示例7: while
void
Ice::stringSeqToArgs(const StringSeq& args, int& argc, char* argv[])
{
//
// Shift all elements in argv which are present in args to the
// beginning of argv. We record the original value of argc so
// that we can know later if we've shifted the array.
//
const int argcOrig = argc;
int i = 0;
while(i < argc)
{
if(find(args.begin(), args.end(), argv[i]) == args.end())
{
for(int j = i; j < argc - 1; j++)
{
argv[j] = argv[j + 1];
}
--argc;
}
else
{
++i;
}
}
//
// Make sure that argv[argc] == 0, the ISO C++ standard requires this.
// We can only do this if we've shifted the array, otherwise argv[argc]
// may point to an invalid address.
//
if(argv && argcOrig != argc)
{
argv[argc] = 0;
}
}
示例8: ex
bool
IceBox::ServiceManagerI::start()
{
try
{
ServiceManagerPtr obj = this;
PropertiesPtr properties = _communicator->getProperties();
//
// Create an object adapter. Services probably should NOT share
// this object adapter, as the endpoint(s) for this object adapter
// will most likely need to be firewalled for security reasons.
//
ObjectAdapterPtr adapter;
if(properties->getProperty("IceBox.ServiceManager.Endpoints") != "")
{
adapter = _communicator->createObjectAdapter("IceBox.ServiceManager");
Identity identity;
identity.category = properties->getPropertyWithDefault("IceBox.InstanceName", "IceBox");
identity.name = "ServiceManager";
adapter->add(obj, identity);
}
//
// Parse the property set with the prefix "IceBox.Service.". These
// properties should have the following format:
//
// IceBox.Service.Foo=entry_point [args]
//
// We parse the service properties specified in IceBox.LoadOrder
// first, then the ones from remaining services.
//
const string prefix = "IceBox.Service.";
PropertyDict services = properties->getPropertiesForPrefix(prefix);
PropertyDict::iterator p;
StringSeq loadOrder = properties->getPropertyAsList("IceBox.LoadOrder");
vector<StartServiceInfo> servicesInfo;
for(StringSeq::const_iterator q = loadOrder.begin(); q != loadOrder.end(); ++q)
{
p = services.find(prefix + *q);
if(p == services.end())
{
FailureException ex(__FILE__, __LINE__);
ex.reason = "ServiceManager: no service definition for `" + *q + "'";
throw ex;
}
servicesInfo.push_back(StartServiceInfo(*q, p->second, _argv));
services.erase(p);
}
for(p = services.begin(); p != services.end(); ++p)
{
servicesInfo.push_back(StartServiceInfo(p->first.substr(prefix.size()), p->second, _argv));
}
//
// Check if some services are using the shared communicator in which
// case we create the shared communicator now with a property set which
// is the union of all the service properties (services which are using
// the shared communicator).
//
PropertyDict sharedCommunicatorServices = properties->getPropertiesForPrefix("IceBox.UseSharedCommunicator.");
if(!sharedCommunicatorServices.empty())
{
InitializationData initData;
initData.properties = createServiceProperties("SharedCommunicator");
for(vector<StartServiceInfo>::iterator q = servicesInfo.begin(); q != servicesInfo.end(); ++q)
{
if(properties->getPropertyAsInt("IceBox.UseSharedCommunicator." + q->name) <= 0)
{
continue;
}
//
// Load the service properties using the shared communicator properties as
// the default properties.
//
PropertiesPtr svcProperties = createProperties(q->args, initData.properties);
//
// Erase properties from the shared communicator which don't exist in the
// service properties (which include the shared communicator properties
// overriden by the service properties).
//
PropertyDict allProps = initData.properties->getPropertiesForPrefix("");
for(PropertyDict::iterator p = allProps.begin(); p != allProps.end(); ++p)
{
if(svcProperties->getProperty(p->first) == "")
{
initData.properties->setProperty(p->first, "");
}
}
//
// Add the service properties to the shared communicator properties.
//
PropertyDict props = svcProperties->getPropertiesForPrefix("");
for(PropertyDict::const_iterator r = props.begin(); r != props.end(); ++r)
{
initData.properties->setProperty(r->first, r->second);
//.........这里部分代码省略.........
示例9: string
int
Activator::activate(const string& name,
const string& exePath,
const string& pwdPath,
#ifndef _WIN32
uid_t uid,
gid_t gid,
#endif
const Ice::StringSeq& options,
const Ice::StringSeq& envs,
const ServerIPtr& server)
{
IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
if(_deactivating)
{
throw string("The node is being shutdown.");
}
string path = exePath;
if(path.empty())
{
throw string("The server executable path is empty.");
}
string pwd = IcePatch2Internal::simplify(pwdPath);
#ifdef _WIN32
if(!IceUtilInternal::isAbsolutePath(path))
{
if(path.find('/') == string::npos)
{
//
// Get the absolute pathname of the executable.
//
wchar_t absbuf[_MAX_PATH];
wchar_t* fPart;
wstring ext = path.size() <= 4 || path[path.size() - 4] != '.' ? L".exe" : L"";
//
// IceGrid doesn't support to use string converters, so don't need to use
// any string converter in wstringToString conversions.
//
if(SearchPathW(NULL, IceUtil::stringToWstring(path).c_str(), ext.c_str(), _MAX_PATH, absbuf, &fPart) == 0)
{
if(_traceLevels->activator > 0)
{
Trace out(_traceLevels->logger, _traceLevels->activatorCat);
out << "couldn't find `" << path << "' executable.";
}
throw string("Couldn't find `" + path + "' executable.");
}
path = IceUtil::wstringToString(absbuf);
}
else if(!pwd.empty())
{
path = pwd + "/" + path;
}
}
//
// Get the absolute pathname of the working directory.
//
// IceGrid doesn't support to use string converters, so
// don't need to use any string converter in stringToWstring
// conversions.
//
if(!pwd.empty())
{
wchar_t absbuf[_MAX_PATH];
if(_wfullpath(absbuf, IceUtil::stringToWstring(pwd).c_str(), _MAX_PATH) == NULL)
{
if(_traceLevels->activator > 0)
{
Trace out(_traceLevels->logger, _traceLevels->activatorCat);
out << "cannot convert `" << pwd << "' into an absolute path";
}
throw string("The server working directory path `" + pwd + "' can't be converted into an absolute path.");
}
pwd = IceUtil::wstringToString(absbuf);
}
#endif
//
// Setup arguments.
//
StringSeq args;
args.push_back(path);
args.insert(args.end(), options.begin(), options.end());
if(_traceLevels->activator > 0)
{
Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
out << "activating server `" << name << "'";
if(_traceLevels->activator > 1)
{
out << "\n";
out << "path = " << path << "\n";
if(pwd.empty())
{
string cwd;
//.........这里部分代码省略.........
示例10: e
void
Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, StringSeq& cmdArgs)
{
assert(_communicator);
string entryPoint;
StringSeq args;
if(!pluginSpec.empty())
{
//
// Split the entire property value into arguments. An entry point containing spaces
// must be enclosed in quotes.
//
try
{
args = IceUtilInternal::Options::split(pluginSpec);
}
catch(const IceUtilInternal::BadOptException& ex)
{
PluginInitializationException e(__FILE__, __LINE__);
e.reason = "invalid arguments for plug-in `" + name + "':\n" + ex.reason;
throw e;
}
assert(!args.empty());
//
// Shift the arguments.
//
entryPoint = args[0];
args.erase(args.begin());
//
// Convert command-line options into properties. First we
// convert the options from the plug-in configuration, then
// we convert the options from the application command-line.
//
PropertiesPtr properties = _communicator->getProperties();
args = properties->parseCommandLineOptions(name, args);
cmdArgs = properties->parseCommandLineOptions(name, cmdArgs);
}
PluginFactory factory = 0;
DynamicLibraryPtr library;
//
// Always check the static plugin factory table first, it takes
// precedence over the the entryPoint specified in the plugin
// property value.
//
if(factories)
{
map<string, PluginFactory>::const_iterator p = factories->find(name);
if(p != factories->end())
{
factory = p->second;
}
}
//
// If we didn't find the factory, get the factory using the entry
// point symbol.
//
if(!factory)
{
assert(!entryPoint.empty());
library = new DynamicLibrary();
DynamicLibrary::symbol_type sym = library->loadEntryPoint(entryPoint);
if(sym == 0)
{
ostringstream out;
string msg = library->getErrorMessage();
out << "unable to load entry point `" << entryPoint << "'";
if(!msg.empty())
{
out << ": " + msg;
}
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = out.str();
throw ex;
}
#ifdef __IBMCPP__
// xlC warns when casting a void* to function pointer
# pragma report(disable, "1540-0216")
#endif
factory = reinterpret_cast<PluginFactory>(sym);
}
//
// Invoke the factory function. No exceptions can be raised
// by the factory function because it's declared extern "C".
//
PluginPtr plugin(factory(_communicator, name, args));
if(!plugin)
{
PluginInitializationException e(__FILE__, __LINE__);
ostringstream out;
out << "failure in entry point `" << entryPoint << "'";
//.........这里部分代码省略.........
示例11: ex
void
Ice::PluginManagerI::loadPlugins(int& argc, const char* argv[])
{
assert(_communicator);
StringSeq cmdArgs = argsToStringSeq(argc, argv);
const string prefix = "Ice.Plugin.";
PropertiesPtr properties = _communicator->getProperties();
PropertyDict plugins = properties->getPropertiesForPrefix(prefix);
//
// First, load static plugin factories which were setup to load on
// communicator initialization. If a matching plugin property is
// set, we load the plugin with the plugin specification. The
// entryPoint will be ignored but the rest of the plugin
// specification might be used.
//
if(loadOnInitialization)
{
for(vector<string>::const_iterator p = loadOnInitialization->begin(); p != loadOnInitialization->end(); ++p)
{
string property = prefix + *p;
PropertyDict::iterator r = plugins.find(property + ".cpp");
if(r == plugins.end())
{
r = plugins.find(property);
}
else
{
plugins.erase(property);
}
if(r != plugins.end())
{
loadPlugin(*p, r->second, cmdArgs);
plugins.erase(r);
}
else
{
loadPlugin(*p, "", cmdArgs);
}
}
}
//
// Next, load and initialize the plug-ins defined in the property
// set with the prefix "Ice.Plugin.". These properties should have
// the following format:
//
// Ice.Plugin.name[.<language>]=entry_point [args]
//
// If the Ice.PluginLoadOrder property is defined, load the
// specified plug-ins in the specified order, then load any
// remaining plug-ins.
//
StringSeq loadOrder = properties->getPropertyAsList("Ice.PluginLoadOrder");
for(StringSeq::const_iterator p = loadOrder.begin(); p != loadOrder.end(); ++p)
{
string name = *p;
if(findPlugin(name))
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "plug-in `" + name + "' already loaded";
throw ex;
}
string property = prefix + name;
PropertyDict::iterator r = plugins.find(property + ".cpp");
if(r == plugins.end())
{
r = plugins.find(property);
}
else
{
plugins.erase(property);
}
if(r != plugins.end())
{
loadPlugin(name, r->second, cmdArgs);
plugins.erase(r);
}
else
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "plug-in `" + name + "' not defined";
throw ex;
}
}
//
// Load any remaining plug-ins that weren't specified in PluginLoadOrder.
//
while(!plugins.empty())
{
PropertyDict::iterator p = plugins.begin();
//.........这里部分代码省略.........
示例12: out
Freeze::MapDb::MapDb(const ConnectionIPtr& connection,
const string& dbName,
const string& key,
const string& value,
const KeyCompareBasePtr& keyCompare,
const vector<MapIndexBasePtr>& indices,
bool createDb) :
Db(connection->dbEnv()->getEnv(), 0),
_communicator(connection->communicator()),
_dbName(dbName),
_trace(connection->trace()),
_keyCompare(keyCompare)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "opening Db \"" << _dbName << "\"";
}
Catalog catalog(connection, _catalogName);
TransactionPtr tx = connection->currentTransaction();
bool ownTx = (tx == 0);
for(;;)
{
try
{
if(ownTx)
{
tx = 0;
tx = connection->beginTransaction();
}
Catalog::iterator ci = catalog.find(_dbName);
if(ci != catalog.end())
{
if(ci->second.evictor)
{
throw DatabaseException(__FILE__, __LINE__, _dbName + " is an evictor database");
}
_key = ci->second.key;
_value = ci->second.value;
checkTypes(key, value);
}
else
{
_key = key;
_value = value;
}
set_app_private(this);
if(_keyCompare->compareEnabled())
{
set_bt_compare(&customCompare);
}
PropertiesPtr properties = _communicator->getProperties();
string propPrefix = "Freeze.Map." + _dbName + ".";
int btreeMinKey = properties->getPropertyAsInt(propPrefix + "BtreeMinKey");
if(btreeMinKey > 2)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "Setting \"" << _dbName << "\"'s btree minkey to " << btreeMinKey;
}
set_bt_minkey(btreeMinKey);
}
bool checksum = properties->getPropertyAsInt(propPrefix + "Checksum") > 0;
if(checksum)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "Turning checksum on for \"" << _dbName << "\"";
}
set_flags(DB_CHKSUM);
}
int pageSize = properties->getPropertyAsInt(propPrefix + "PageSize");
if(pageSize > 0)
{
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Map");
out << "Setting \"" << _dbName << "\"'s pagesize to " << pageSize;
}
set_pagesize(pageSize);
}
DbTxn* txn = getTxn(tx);
u_int32_t flags = DB_THREAD;
//.........这里部分代码省略.........
示例13: if
int
main(int argc, char* argv[])
#endif
{
Ice::StringSeq originalArgs = Ice::argsToStringSeq(argc, argv);
assert(originalArgs.size() > 0);
const string appName = originalArgs[0];
string dataDir;
StringSeq fileSeq;
int compress = 1;
bool verbose;
bool caseInsensitive;
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("z", "compress");
opts.addOpt("Z", "no-compress");
opts.addOpt("V", "verbose");
opts.addOpt("i", "case-insensitive");
vector<string> args;
try
{
args = opts.parse(originalArgs);
}
catch(const IceUtilInternal::BadOptException& e)
{
cerr << e.reason << endl;
usage(appName);
return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
usage(appName);
return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
cout << ICE_STRING_VERSION << endl;
return EXIT_SUCCESS;
}
bool doCompress = opts.isSet("compress");
bool dontCompress = opts.isSet("no-compress");
if(doCompress && dontCompress)
{
cerr << appName << ": only one of -z and -Z are mutually exclusive" << endl;
usage(appName);
return EXIT_FAILURE;
}
if(doCompress)
{
compress = 2;
}
else if(dontCompress)
{
compress = 0;
}
verbose = opts.isSet("verbose");
caseInsensitive = opts.isSet("case-insensitive");
if(args.empty())
{
cerr << appName << ": no data directory specified" << endl;
usage(appName);
return EXIT_FAILURE;
}
dataDir = simplify(args[0]);
for(vector<string>::size_type i = 1; i < args.size(); ++i)
{
fileSeq.push_back(simplify(args[i]));
}
try
{
string absDataDir = dataDir;
string cwd;
if(IceUtilInternal::getcwd(cwd) != 0)
{
throw "cannot get the current directory:\n" + IceUtilInternal::lastErrorToString();
}
if(!IceUtilInternal::isAbsolutePath(absDataDir))
{
absDataDir = simplify(cwd + '/' + absDataDir);
}
for(StringSeq::iterator p = fileSeq.begin(); p != fileSeq.end(); ++p)
{
if(!IceUtilInternal::isAbsolutePath(*p))
{
*p = cwd + '/' + *p;
}
}
//
//.........这里部分代码省略.........