本文整理汇总了C++中ArgumentParser::hasNext方法的典型用法代码示例。如果您正苦于以下问题:C++ ArgumentParser::hasNext方法的具体用法?C++ ArgumentParser::hasNext怎么用?C++ ArgumentParser::hasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgumentParser
的用法示例。
在下文中一共展示了ArgumentParser::hasNext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
ArgumentParser parser;
QTextStream out(stdout);
parser.next(); // eat the program name
if (!parser.hasNext()) {
showHelp(out);
return 0;
}
try {
Engine eng;
commandWebExport(out, parser);
}
catch (ArgumentParser::HelpException &) {
showHelp(out);
return 0;
}
catch (ArgumentParser::Exception &e){
showError(out, e);
return 1;
}
return 0;
}
示例2: commandWebExport
static void commandWebExport(QTextStream &out, ArgumentParser &parser)
{
std::vector<QString> ops;
QString outputdir, title;
bool build_file_tree = false;
bool verbose_output = false;
// parse the command line
while (parser.hasNext()) {
bool isswitch;
QString cmd(parser.next(&isswitch));
if (cmd == "-o")
outputdir = parser.nextParam("-o");
else if (cmd == "-t")
title = parser.nextParam("-t");
else if (cmd == "-f")
build_file_tree = true;
else if (cmd == "-v")
verbose_output = true;
else if (isswitch)
throw ArgumentParser::ErrorException("Unknown switch: " + cmd);
else
ops.push_back(cmd);
}
if (outputdir.isEmpty())
throw ArgumentParser::ErrorException("The output (-o) directory must be specified");
if (!QFileInfo(outputdir).isDir())
throw ArgumentParser::ErrorException(outputdir + " must be a directory");
// parse the ops into the webexporter
WebExport exporter(outputdir, out);
QString fullcur, dir_prefix;
int j, maxj;
enum {
flat_type,
subdir_type,
pivot_type,
};
short curtype = flat_type;
QString pivot_tag, pivot_path, webpath;
std::shared_ptr<hydra::Token> query_tok, pivot_tok;
int scanned_count = 0;
parseQueryTokens("", query_tok); // init it
if (!title.isEmpty())
exporter.setTitle(title);
maxj = static_cast<int>(ops.size());
j = 0;
while (j<maxj) {
QString ¶m = ops[j];
if (param == "flat") {
curtype = flat_type;
} else if (param == "subdir") {
curtype = subdir_type;
} else if (param == "pivot") {
j++;
if (j<maxj) {
curtype = pivot_type;
pivot_tag = ops[j];
parseQueryTokens(pivot_tag + "*", pivot_tok);
} else {
out << "passing empty tag parameter to pivot subcommand!" << endl;
curtype = flat_type; // fail
}
} else if (param == "webpath") {
j++;
if (j<maxj)
webpath = ops[j];
} else if (param == "query") {
j++;
if (j<maxj)
parseQueryTokens(ops[j], query_tok);
} else {
// must be a file param
FileIterator ii(param);
FileItemRecord item;
FilePathRecord path;
dir_prefix = prepPrefix(param);
while (ii.hasNext()) {
fullcur = ii.next();
scanned_count++;
if (verbose_output && scanned_count % 100 == 0)
out << "Files scanned: " << scanned_count << endl;
// load and check query
if (Engine::instance()->getFileItem(fullcur, &item, 0, &path) != Engine::Load_OK)
continue;
if (!query_tok->isMatch(item.tags))
continue;
//std::cerr << "prefix=" << dir_prefix.utf8_str() << " cur=" << fullcur.utf8_str() << endl;
//.........这里部分代码省略.........