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


C++ string::strtoken方法代码示例

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


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

示例1: create

ST::string administrator::create(const ST::string & in)
  {

//  int test;



  ST::string name;
  vector<ST::string> token = in.strtoken(" ");

  if (token.size() != 2)
	 {
	 errormessages.push_back("ERROR: invalid creation of new object\n");
	 return "";
	 }
  else // token.size() == 2
	 {

	 if (token[1].isvarname() == 1)
		{
		errormessages.push_back("ERROR: invalid object name\n");
		return "";
		}
	 else
		{
		if (alreadyexisting(token[1]) == true)
		  errormessages.push_back(
		  "ERROR: object " + token[1] + " is already existing\n");
		else
		  {

		  if (token[0] == "dataset")
			 {
			 dataobject newobject(token[1],&logout,input);
			 dataobjects.push_back(newobject);
			 }
		  else if (token[0] == "bayesreg")
			 {
			 bayesreg newobject(token[1],&logout,input,defaultpath,&objects);
			 bayesregobjects.push_back(newobject);
			 }
		  else if (token[0] == "map")
			 {
			 MAP::map newobject(token[1],&logout,input,defaultpath);
			 mapobjects.push_back(newobject);
			 }


		  adjustobjects();


		  }
		return token[1];
		}
	 } // end: if token.size() == 2
  }
开发者ID:cran,项目名称:BayesXsrc,代码行数:56,代码来源:admin.cpp

示例2: parse

bool administrator::parse(ST::string & in)
  {

  errormessages.clear();

  ST::string objectname;
  ST::string firsttoken = in.getFirstToken(" .");
  int pointpos = in.checksign('.');

  if (firsttoken.length() > 0)
	 {
	 if ( (firsttoken == "quit") || (firsttoken == "exit") )
		return true;
	 else if (firsttoken == "delimeter")
		{
		vector<ST::string> token = in.strtoken(" ");
		if (token.size() != 3)
		  errormessages.push_back("ERROR: invalid syntax\n");
		else if (token[1] != "=")
		  errormessages.push_back("ERROR: \"=\" expected\n");
		else
		  {
		  if (token[2] == "newline")
			 delim = '\n';
		  else if (token[2].length() > 1)
			 errormessages.push_back("ERROR: invalid delimeter symbol\n");
		  else
			 delim = token[2][0];
		  }

		return false;
		} // end: delimeter
	 else if (firsttoken == "usefile")
		{

		vector<ST::string> token = in.strtoken(" ");
		if (token.size() < 2)
		  errormessages.push_back("ERROR: filename expected\n");
		else if (token.size() > 2)
		  errormessages.push_back("ERROR: invalid syntax\n");

		if (errormessages.empty())
		  {
		  ST::string path = token[1];
		  if (path.isexistingfile() == 1)
			 errormessages.push_back("ERROR: file " + path +
											 " could not be opened\n");
		  else
			 {
			 ST::string in;
			 ifstream infile;
			 input = &infile;
			 ST::open(infile,path);
			 while (! infile.eof())
				{
				ST::getline(infile,10000,in,delim);
				if (delim != '\n')
				 in = in.replaceallsigns('\n',' ');
	         in = in.eatwhitespace();


				out("> " + in + "\n");
				parse(in);
				}

			 }
		  }

		input = &cin;
		out(errormessages);
		return false;

		}
	 else if (firsttoken == "logopen")
		{
		model m;
		simpleoption replace("replace",false);
		optionlist logoptions;
		logoptions.push_back(&replace);
		usePathWrite uw;

		command logopen("logopen",&m,&logoptions,&uw,notallowed,notallowed,
							 notallowed,notallowed,optional,required);

		logopen.parse(in);
		errormessages = logopen.geterrormessages();
		if (logfileopen == true)
		  errormessages.push_back("ERROR: logfile is already open\n");
		if (errormessages.empty())
		  {
		  logfileopen = true;
		  logfilepath = uw.getPath();
		  if ((replace.getvalue() == false) && (uw.isexisting() == true))
            {
            ST::open(logout,logfilepath,ios::app);
            }
		  else
            {
            ST::open(logout,logfilepath);
            }
//.........这里部分代码省略.........
开发者ID:cran,项目名称:BayesXsrc,代码行数:101,代码来源:admin.cpp


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