本文整理汇总了C++中AttributeMap::keys方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeMap::keys方法的具体用法?C++ AttributeMap::keys怎么用?C++ AttributeMap::keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeMap
的用法示例。
在下文中一共展示了AttributeMap::keys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writePreserving
void writePreserving(QFile& inFile, QTextStream& out, const AttributeMap& data)
{
FNTRACE("ini", "", "writePreserving", QString("in, out, %1 rows of data").arg(data.size()));
int i, j;
QChar c;
QString name;
size_t lineNumber = 0;
QString line;
typedef QSet<AttributeMap::key_type> KeySet;
KeySet unwrittenKeys = KeySet::fromList(data.keys());
if (!inFile.open(QIODevice::ReadOnly | QIODevice::Text))
ETHROW(Exception(QString("Unable to open %1 for reading.").arg(inFile.fileName())));
QTextStream in(&inFile);
while (!(line = in.readLine()).isNull())
{
++lineNumber;
//std::cout << lineNumber << ": " << line.toStdString() << ":\n";
for (i = 0; line[i].isSpace(); ++i) { out << line[i]; }
if (line[i].isNull()) { out << '\n'; continue; }
else if (line[i] == COMMENT_BEGIN) { out << line.mid(i) << '\n'; continue; }
for (j = i; !(c = line[i]).isNull() && c!=COMMENT_BEGIN && c!=ASSIGNER; ++i) ;
//std::cout << "non-empty, ";
if (c != ASSIGNER) // non-empty line that isn't assignment -> invalid
ETHROW(ParseError(inFile.fileName(), lineNumber, "Unknown non-empty line."));
for (--i; line[i].isSpace(); --i) ; // last character of name
name = line.mid(j, i - j + 1);
//std::cout << "name: " << name.toStdString() << ' ';
for ( ; line[j]!=ASSIGNER; ++j) out << line[j];
out << ASSIGNER;
i = j + 1;
for ( ; line[i].isSpace(); ++i) out << line[i];
if (data.contains(name))
{
//std::cout << "known ";
out << data.value(name);
unwrittenKeys.remove(name);
for (j = i; !line[i].isNull() && line[i]!=COMMENT_BEGIN; ++i) ; // EOL || comment
for (--i; line[i].isSpace(); --i) ; // last character of value
++i; // first character after value
}
out << line.mid(i) << '\n';
//std::cout << '\n';
}
if (unwrittenKeys.size())
{
out << '\n' << COMMENT_BEGIN << "Following lines were generated by Ds1edit Loader:\n";
for (KeySet::iterator key = unwrittenKeys.begin();
key != unwrittenKeys.end(); ++key)
out << (*key) << ' ' << ASSIGNER << ' ' << data.value(*key) << '\n';
}
//in.resize(in.pos()+1);
inFile.close();
}