本文整理汇总了C++中FileParser::incrementLineNum方法的典型用法代码示例。如果您正苦于以下问题:C++ FileParser::incrementLineNum方法的具体用法?C++ FileParser::incrementLineNum怎么用?C++ FileParser::incrementLineNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileParser
的用法示例。
在下文中一共展示了FileParser::incrementLineNum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadLayer
void Map::loadLayer(FileParser &infile) {
if (infile.key == "type") {
// @ATTR layer.type|string|Map layer type.
layers.resize(layers.size()+1);
layers.back().resize(w);
for (size_t i=0; i<layers.back().size(); ++i) {
layers.back()[i].resize(h);
}
layernames.push_back(infile.val);
if (infile.val == "collision")
collision_layer = static_cast<int>(layernames.size())-1;
}
else if (infile.key == "format") {
// @ATTR layer.format|string|Format for map layer, must be 'dec'
if (infile.val != "dec") {
infile.error("Map: The format of a layer must be 'dec'!");
logErrorDialog("Map: The format of a layer must be 'dec'!");
mods->resetModConfig();
Exit(1);
}
}
else if (infile.key == "data") {
// @ATTR layer.data|raw|Raw map layer data
// layer map data handled as a special case
// The next h lines must contain layer data.
for (int j=0; j<h; j++) {
std::string val = infile.getRawLine();
infile.incrementLineNum();
if (!val.empty() && val[val.length()-1] != ',') {
val += ',';
}
// verify the width of this row
int comma_count = 0;
for (unsigned i=0; i<val.length(); ++i) {
if (val[i] == ',') comma_count++;
}
if (comma_count != w) {
infile.error("Map: A row of layer data has a width not equal to %d.", w);
mods->resetModConfig();
Exit(1);
}
for (int i=0; i<w; i++)
layers.back()[i][j] = static_cast<unsigned short>(popFirstInt(val));
}
}
else {
infile.error("Map: '%s' is not a valid key.", infile.key.c_str());
}
}