MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / saveBinary

Method saveBinary

Source/Utils/ini.hpp:445–477  ·  view source on GitHub ↗

Saves it without any conventional INI formatting characters, however it only uses string streams

Source from the content-addressed store, hash-verified

443
444 //Saves it without any conventional INI formatting characters, however it only uses string streams
445 bool saveBinary(const std::string filename = "")
446 {
447 if (!hasFileAssociation(filename))
448 return false;
449
450 fini_ofstream_t file(((filename == "") ? this->filename : filename).c_str(), std::ios::trunc | std::ios::binary);
451 if (!file.is_open())
452 return false;
453
454 size_t sectionCount = sections.size();
455 size_t keyCount;
456
457 file.write((fini_char_t*)&sectionCount, sizeof(sectionCount));
458
459 //Loop through sections
460 for (typename INI::sectionsit_t i = sections.begin(); i != sections.end(); i++)
461 {
462 keyCount = i->second->size();
463 file.write((fini_char_t*)&keyCount, sizeof(keyCount));
464
465 file << i->first << std::endl;
466
467 for (typename INI::keysit_t j = i->second->begin(); j != i->second->end(); j++)
468 {
469 file << j->first << std::endl;
470 file << j->second << std::endl;
471 }
472 }
473
474 file.close();
475
476 return true;
477 }
478
479 //Saves it as a true binary file, intended to replace the existing one. Don't bother using it with all strings.
480 bool saveBinaryExperimental(std::string filename = "")

Callers

nothing calls this directly

Calls 4

closeMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected