本文整理汇总了C++中util::split方法的典型用法代码示例。如果您正苦于以下问题:C++ util::split方法的具体用法?C++ util::split怎么用?C++ util::split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util
的用法示例。
在下文中一共展示了util::split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
vector<string> args;
for(int i = 1; i < argc; ++i)
args.push_back(argv[i]);
Options opts{};
for(auto &arg : args) {
if (arg == "--teval") {
teval(args);
return 0;
}
if(arg == "--pprint") {
for(auto &arg2 : args)
if(!startsWith(arg2, "--"))
prettyPrint(arg2);
return 0;
}
if(arg == "--importGoogle") {
importGoogleNGramData();
return 0;
}
if(arg == "--import") {
opts.import = true;
cerr << "pbrane: import mode enabled" << endl;
} else if(arg == "--debugSQL") {
opts.debugSQL = true;
cerr << "pbrane: debug sql enabled" << endl;
} else if(arg == "--debugEventSystem") {
opts.debugEventSystem = true;
cerr << "pbrane: debug event system enabled" << endl;
} else if(arg == "--debugFunctionBodies") {
opts.debugFunctionBodies = true;
cerr << "pbrane: debug function bodies enabled" << endl;
} else if(arg == "--importLog") {
opts.import = true;
opts.importLog = true;
cerr << "pbrane: import log enabled" << endl;
} else {
opts.seed = fromString<unsigned int>(argv[1]);
}
}
if(args.empty()) {
random_device randomDevice;
opts.seed = randomDevice();
}
Database db{config::databaseFileName};
Bot pbrane{db, opts, Clock{}, setupBot};
// while there is more input coming
while(!cin.eof() && !pbrane.done) {
// read the current line of input
string line;
getline(cin, line);
if(line.find_first_not_of(" \t\r\n") == string::npos)
continue;
string network;
auto ts = Clock{}.now();
if(!opts.importLog) {
network = line.substr(0, line.find(" "));
line = line.substr(line.find(" ") + 1);
if(line.find_first_not_of(" \t\r\n") == string::npos)
continue;
} else {
auto fs = util::split(line, "|");
if(fs.size() < 3) {
cerr << "unable to parse log line" << endl;
cerr << "line: " << line << endl;
return 32;
}
ts = util::fromString<sqlite_int64>(fs[0]);
network = fs[1];
line = util::join(fs.begin() + 2, fs.end(), " ");
}
Entry entry{ts, network, line};
pbrane.journal.upsert(entry);
auto fields = split(line);
if(fields.empty()) continue;
if(entry.type == EntryType::Text) {
auto nick = entry.nick();
auto message = entry.arguments;
auto target = entry.where;
if(target == pbrane.vars.get("bot.nick").toString())
target = nick;
// TODO: simplify construction?
pbrane.vars.set("nick", nick);
pbrane.vars.set("where", target);
pbrane.vars.set("text", message);
//.........这里部分代码省略.........