本文整理汇总了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
}
示例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);
}
//.........这里部分代码省略.........