当前位置: 首页>>代码示例>>C++>>正文


C++ ArgumentParser::hasNext方法代码示例

本文整理汇总了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;
}
开发者ID:ademko,项目名称:hydra,代码行数:29,代码来源:hydraweb.cpp

示例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 &param = 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;
//.........这里部分代码省略.........
开发者ID:ademko,项目名称:hydra,代码行数:101,代码来源:hydraweb.cpp


注:本文中的ArgumentParser::hasNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。