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


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

本文整理汇总了C++中ArgumentParser::items方法的典型用法代码示例。如果您正苦于以下问题:C++ ArgumentParser::items方法的具体用法?C++ ArgumentParser::items怎么用?C++ ArgumentParser::items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArgumentParser的用法示例。


在下文中一共展示了ArgumentParser::items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ArgumentParser

int
main(int argc, char **argv)
{
  int rv = 0;
  ArgumentParser *argp = new ArgumentParser(argc, argv, "hd:v");

  const vector<const char *> & items = argp->items();
  if ( items.size() == 0 || argp->has_arg("h") ) {
  cout << "Fawkes Interface generator - Usage Instructions" << endl
       << "===============================================================================" << endl
       << "Usage: " << argv[0] << " [-h] [-d dir] [-v] config.xml [config2.xml...]" << endl
       << "where [options] is one or more of:" << endl
       << " -h        These help instructions" << endl
       << " -d dir    Directory where to write generated files" << endl
       << " -v        Verbose console output." << endl
       << endl;
  } else {
    string dir = ".";
    if ( argp->has_arg("d") ) {
      dir = argp->arg("d");
    }

    for ( vector<const char *>::const_iterator i = items.begin(); i != items.end(); ++i) {
      string s = *i;
      string prefix;
      size_t pos;

      if ( ( pos = s.find_last_of (".")) != string::npos ) {
	prefix = s.substr(0, pos);
      } else {
	prefix = s;
      }
      s = prefix;
      if ( ( pos = s.find_last_of ("/")) != string::npos ) {
	prefix = s.substr(pos + 1);
      } else {
	prefix = s;
      }

      if ( ! File::exists( *i ) ) {
	cout << "File " << *i << " does not exist" << endl;
	continue;
      } else if (! File::is_regular( *i ) ) {
	cout << *i << " is not a regular file" << endl;
	continue;
      }

      try {
	InterfaceParser    *iparse = new InterfaceParser(*i);
	iparse->parse();
	if ( argp->has_arg("v") ) {
	  iparse->print();
	}
	
	InterfaceDigest    *idigest = new InterfaceDigest(*i);

	CppInterfaceGenerator *cppigen = new CppInterfaceGenerator(dir,
								   iparse->getInterfaceName(),
								   prefix,
								   iparse->getInterfaceAuthor(),
								   iparse->getInterfaceYear(),
								   iparse->getInterfaceCreationDate(),
								   iparse->getDataComment(),
								   idigest->get_hash(),
								   idigest->get_hash_size(),
								   iparse->getConstants(),
								   iparse->getEnumConstants(),
								   iparse->getDataFields(),
								   iparse->getPseudoMaps(),
								   iparse->getMessages()
								   );

	ToLuaInterfaceGenerator *toluaigen = new ToLuaInterfaceGenerator(dir,
									 iparse->getInterfaceName(),
									 prefix,
									 iparse->getInterfaceAuthor(),
									 iparse->getInterfaceYear(),
									 iparse->getInterfaceCreationDate(),
									 iparse->getDataComment(),
									 idigest->get_hash(),
									 idigest->get_hash_size(),
									 iparse->getConstants(),
									 iparse->getEnumConstants(),
									 iparse->getDataFields(),
									 iparse->getPseudoMaps(),
									 iparse->getMessages()
									 );

	cppigen->generate();
	toluaigen->generate();

	delete cppigen;
	delete toluaigen;

	delete iparse;
	delete idigest;
      } catch (Exception &e) {
	cout << "Generating the interface failed." << endl;
	e.print_trace();
        rv = -1;
//.........这里部分代码省略.........
开发者ID:fuxiang90,项目名称:fawkes,代码行数:101,代码来源:main.cpp


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