void SynonymMap::save(const string& sFileName) { TextFile tf; tf.open(sFileName.c_str(), "w"); for(SynMap::const_iterator it = m_synMap.begin(); it != m_synMap.end();it++) { tf.write(it->first.c_str()); Group* pGroup = it->second; tf.write(":"); for(Group::const_iterator git = pGroup->begin(); git != pGroup->end(); git++) { tf.write((*git).c_str()); if( (git + 1) != pGroup->end()) { tf.write(","); } } tf.write("\n"); } tf.close(); }
void operator << ( TextFile & file, stringstream & strm ) { // get buffer string & str = strm.str(); char * buffer = (char *) str.c_str(); if ( !buffer ) return; // write buffer to file long sz = str.size(); file.write(buffer,sz); }
void SymbolData::writeNocashSym() { if (nocashSymFileName.empty()) return; std::vector<NocashSymEntry> entries; for (size_t k = 0; k < modules.size(); k++) { SymDataModule& module = modules[k]; for (size_t i = 0; i < module.symbols.size(); i++) { SymDataSymbol& sym = module.symbols[i]; NocashSymEntry entry; entry.address = sym.address; entry.text = sym.name; entries.push_back(entry); } for (size_t i = 0; i < module.data.size(); i++) { SymDataData& data = module.data[i]; NocashSymEntry entry; entry.address = data.address; switch (data.type) { case Data8: entry.text = formatString(".byt:%04X",data.size); break; case Data16: entry.text = formatString(".wrd:%04X",data.size); break; case Data32: entry.text = formatString(".dbl:%04X",data.size); break; case DataAscii: entry.text = formatString(".asc:%04X",data.size); break; } entries.push_back(entry); } } std::sort(entries.begin(),entries.end()); TextFile file; if (file.open(nocashSymFileName,TextFile::Write,TextFile::ASCII) == false) { Logger::printError(Logger::Error,L"Could not open sym file %s.",file.getFileName().c_str()); return; } file.writeLine(L"00000000 0"); for (size_t i = 0; i < entries.size(); i++) { file.writeFormat(L"%08X %S\n",entries[i].address,entries[i].text.c_str()); } file.write("\x1A"); file.close(); }