本文整理汇总了C++中OptionsList::push_back_copy方法的典型用法代码示例。如果您正苦于以下问题:C++ OptionsList::push_back_copy方法的具体用法?C++ OptionsList::push_back_copy怎么用?C++ OptionsList::push_back_copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptionsList
的用法示例。
在下文中一共展示了OptionsList::push_back_copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseThreadSpecificOptions
void parseThreadSpecificOptions(OptionsList& threadOptions, const Options& opts)
{
unsigned numThreads = opts.getThreads();
for(unsigned i = 0; i < numThreads; ++i) {
threadOptions.push_back_copy(opts);
Options& tOpts = threadOptions.back();
// Set thread identifier
tOpts.setThreadId(i);
const std::vector<std::string>& optThreadArgvs = opts.getThreadArgv();
if(i < optThreadArgvs.size() && (! optThreadArgvs[i].empty())) {
// separate out the thread's individual configuration string
stringstream optidss;
optidss << "--thread" << i;
string optid = optidss.str();
int targc = 1;
char* tbuf = strdup(optThreadArgvs[i].c_str());
char* p = tbuf;
// string length is certainly an upper bound on size needed
char** targv = new char*[optThreadArgvs[i].size()];
char** vp = targv;
*vp++ = strdup(optid.c_str());
p = strtok(p, " ");
while(p != NULL) {
*vp++ = p;
++targc;
p = strtok(NULL, " ");
}
*vp++ = NULL;
if(targc > 1) { // this is necessary in case you do e.g. --thread0=" "
try {
Options::parseOptions(&tOpts, targc, targv);
} catch(OptionException& e) {
stringstream ss;
ss << optid << ": " << e.getMessage();
throw OptionException(ss.str());
}
if(tOpts.getThreads() != numThreads ||
tOpts.getThreadArgv() != opts.getThreadArgv()) {
stringstream ss;
ss << "not allowed to set thread options in " << optid << " !";
throw OptionException(ss.str());
}
}
free(targv[0]);
delete [] targv;
free(tbuf);
}
}
assert(numThreads >= 1); //do we need this?
}