本文整理汇总了C++中common::DumpFile::writeString方法的典型用法代码示例。如果您正苦于以下问题:C++ DumpFile::writeString方法的具体用法?C++ DumpFile::writeString怎么用?C++ DumpFile::writeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::DumpFile
的用法示例。
在下文中一共展示了DumpFile::writeString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dumpResourcesList
void ResourceManager::dumpResourcesList(const Common::UString &fileName) const {
Common::DumpFile file;
if (!file.open(fileName))
throw Common::Exception(Common::kOpenError);
file.writeString(" Name | Size \n");
file.writeString("-------------------------------------|-------------\n");
for (ResourceMap::const_iterator itName = _resources.begin(); itName != _resources.end(); ++itName) {
for (ResourceTypeMap::const_iterator itType = itName->second.begin(); itType != itName->second.end(); ++itType) {
if (itType->second.empty())
continue;
const Resource &resource = itType->second.back();
const Common::UString &name = itName->first;
const Common::UString ext = setFileType("", resource.type);
const uint32 size = getResourceSize(resource);
const Common::UString line =
Common::UString::sprintf("%32s%4s | %12d\n", name.c_str(), ext.c_str(), size);
file.writeString(line);
}
}
file.flush();
if (file.err())
throw Common::Exception("Write error");
file.close();
}
示例2: dumpResourcesList
void ResourceManager::dumpResourcesList(const Common::UString &fileName) const {
Common::DumpFile file;
if (!file.open(fileName))
throw Common::Exception(Common::kOpenError);
file.writeString(" Name | Hash | Size \n");
file.writeString("-------------------------------------|--------------------|-------------\n");
for (ResourceMap::const_iterator r = _resources.begin(); r != _resources.end(); ++r) {
if (r->second.empty())
continue;
const Resource &res = r->second.back();
const Common::UString &name = res.name;
const Common::UString ext = TypeMan.setFileType("", res.type);
const uint64 hash = r->first;
const uint32 size = getResourceSize(res);
const Common::UString line =
Common::UString::sprintf("%32s%4s | 0x%016llX | %12d\n", name.c_str(), ext.c_str(),
(unsigned long long) hash, size);
file.writeString(line);
}
file.flush();
if (file.err())
throw Common::Exception("Write error");
file.close();
}
示例3: Cmd_DumpItems
bool Debugger::Cmd_DumpItems(int argc, const char **argv) {
InventoryObjects &objects = _vm->_game->_objects;
Common::DumpFile outFile;
outFile.open("items.txt");
for (uint32 i = 0; i < objects.size(); i++) {
Common::String curId = Common::String::format("%d", i);
Common::String desc = _vm->_game->_scene.getVocab(objects[i]._descId);
desc.toUppercase();
for (uint j = 0; j < desc.size(); j++) {
if (desc[j] == ' ' || desc[j] == '-')
desc.setChar('_', j);
}
Common::String cur = "\tOBJ_" + desc + " = " + curId + ",\n";
outFile.writeString(cur.c_str());
}
outFile.flush();
outFile.close();
debugPrintf("Game items dumped\n");
return true;
}
示例4: Cmd_DumpVocab
bool Debugger::Cmd_DumpVocab(int argc, const char **argv) {
Common::DumpFile outFile;
outFile.open("vocab.txt");
for (uint32 i = 0; i < _vm->_game->_scene.getVocabStringsCount(); i++) {
Common::String curId = Common::String::format("%x", i + 1);
Common::String curVocab = _vm->_game->_scene.getVocab(i + 1);
curVocab.toUppercase();
for (uint j = 0; j < curVocab.size(); j++) {
if (curVocab[j] == ' ' || curVocab[j] == '-')
curVocab.setChar('_', j);
}
Common::String cur = "\tNOUN_" + curVocab + " = 0x" + curId + ",\n";
outFile.writeString(cur.c_str());
}
outFile.flush();
outFile.close();
debugPrintf("Game vocab dumped\n");
return true;
}
示例5: tryToDumpLine
void tryToDumpLine(const Common::String &key,
Common::String &line,
Common::HashMap<Common::String, byte> *count,
Common::HashMap<Common::String, bool> *fileAlreadyUsed,
Common::DumpFile &output) {
const byte numberOfExamplesPerType = 8;
if ((*count)[key] < numberOfExamplesPerType && !(*fileAlreadyUsed)[key]) {
output.writeString(line);
output.writeByte('\n');
(*count)[key]++;
(*fileAlreadyUsed)[key] = true;
}
}
示例6: dumpASCII
bool TwoDAFile::dumpASCII(const Common::UString &fileName) const {
Common::DumpFile file;
if (!file.open(fileName))
return false;
// Write header
file.writeString("2DA V2.0\n");
file.writeString(_defaultString); file.writeByte('\n');
// Calculate column lengths
std::vector<uint32> colLength;
colLength.resize(_headers.size() + 1);
const Common::UString maxRow = Common::UString::sprintf("%d", (int)_rows.size() - 1);
colLength[0] = maxRow.size();
for (uint32 i = 0; i < _headers.size(); i++)
colLength[i + 1] = _headers[i].size();
for (uint32 i = 0; i < _rows.size(); i++)
for (uint32 j = 0; j < _rows[i]->_data.size(); j++)
colLength[j + 1] = MAX<uint32>(colLength[j + 1], _rows[i]->_data[j].size());
// Write column headers
file.writeString(Common::UString::sprintf("%-*s", colLength[0], ""));
for (uint32 i = 0; i < _headers.size(); i++)
file.writeString(Common::UString::sprintf(" %-*s", colLength[i + 1], _headers[i].c_str()));
file.writeByte('\n');
// Write array
for (uint32 i = 0; i < _rows.size(); i++) {
file.writeString(Common::UString::sprintf("%*d", colLength[0], i));
for (uint32 j = 0; j < _rows[i]->_data.size(); j++)
file.writeString(Common::UString::sprintf(" %-*s", colLength[j + 1], _rows[i]->_data[j].c_str()));
file.writeByte('\n');
}
file.flush();
file.close();
return true;
}