本文整理汇总了C++中SeekableReadStream::ioFailed方法的典型用法代码示例。如果您正苦于以下问题:C++ SeekableReadStream::ioFailed方法的具体用法?C++ SeekableReadStream::ioFailed怎么用?C++ SeekableReadStream::ioFailed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SeekableReadStream
的用法示例。
在下文中一共展示了SeekableReadStream::ioFailed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromStream
bool ConfigFile::loadFromStream(SeekableReadStream &stream) {
char buf[MAXLINELEN];
Section section;
KeyValue kv;
String comment;
int lineno = 0;
// TODO: Detect if a section occurs multiple times (or likewise, if
// a key occurs multiple times inside one section).
while (!stream.eos()) {
lineno++;
if (!stream.readLine(buf, MAXLINELEN))
break;
if (buf[0] == '#') {
// Accumulate comments here. Once we encounter either the start
// of a new section, or a key-value-pair, we associate the value
// of the 'comment' variable with that entity.
comment += buf;
comment += "\n";
} else if (buf[0] == '(') {
// HACK: The following is a hack added by Kirben to support the
// "map.ini" used in the HE SCUMM game "SPY Fox in Hold the Mustard".
//
// It would be nice if this hack could be restricted to that game,
// but the current design of this class doesn't allow to do that
// in a nice fashion (a "isMustard" parameter is *not* a nice
// solution).
comment += buf;
comment += "\n";
} else if (buf[0] == '[') {
// It's a new section which begins here.
char *p = buf + 1;
// Get the section name, and check whether it's valid (that
// is, verify that it only consists of alphanumerics,
// dashes and underscores).
while (*p && (isalnum(*p) || *p == '-' || *p == '_'))
p++;
if (*p == '\0')
error("ConfigFile::loadFromStream: missing ] in line %d", lineno);
else if (*p != ']')
error("ConfigFile::loadFromStream: Invalid character '%c' occured in section name in line %d", *p, lineno);
*p = 0;
// Previous section is finished now, store it.
if (!section.name.empty())
_sections.push_back(section);
section.name = buf + 1;
section.keys.clear();
section.comment = comment;
comment.clear();
assert(isValidName(section.name));
} else {
// Skip leading & trailing whitespaces
char *t = rtrim(ltrim(buf));
// Skip empty lines
if (*t == 0)
continue;
// If no section has been set, this config file is invalid!
if (section.name.empty()) {
error("ConfigFile::loadFromStream: Key/value pair found outside a section in line %d", lineno);
}
// Split string at '=' into 'key' and 'value'.
char *p = strchr(t, '=');
if (!p)
error("ConfigFile::loadFromStream: Junk found in line line %d: '%s'", lineno, t);
*p = 0;
kv.key = rtrim(t);
kv.value = ltrim(p + 1);
kv.comment = comment;
comment.clear();
assert(isValidName(kv.key));
section.keys.push_back(kv);
}
}
// Save last section
if (!section.name.empty())
_sections.push_back(section);
return (!stream.ioFailed() || stream.eos());
}