本文整理汇总了C++中Tokeniser::Tokenise方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokeniser::Tokenise方法的具体用法?C++ Tokeniser::Tokenise怎么用?C++ Tokeniser::Tokenise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokeniser
的用法示例。
在下文中一共展示了Tokeniser::Tokenise方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
bool ConfigFile::Load(const std::string& filename)
{
// Ctor args: arg 1 (true) => has version info
// arg2 (false) => don't use Glue File implementation.
File f(true, File::STD);
if (!f.OpenRead(filename))
{
#ifdef _DEBUG
// This is ok for a clean install, so don't complain in a release build.
f.ReportError("Couldn't open config file.");
#endif
return false;
}
// This config file simply consists of pairs of tokens. The first of each
// pair is the key; the second is the value.
Tokeniser toker;
string configLine;
while (f.GetDataLine(&configLine))
{
string key;
string value;
if (!toker.Tokenise(&configLine, &key))
{
string error = "No value for " + key + " in config file.";
f.ReportError(error);
return false;
}
// Tokeniser chops head (the key) off configLine, leaving the value tail.
value = configLine;
// Set value in map.
Set(key, value);
}
// No more tokens. This is ok, we have finished.
return true;
}