Saves it as a true binary file, intended to replace the existing one. Don't bother using it with all strings.
| 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 = "") |
| 481 | { |
| 482 | if (!hasFileAssociation(filename)) |
| 483 | return false; |
| 484 | |
| 485 | fini_ofstream_t file(((filename == "") ? this->filename : filename).c_str(), std::ios::trunc | std::ios::binary); |
| 486 | if (!file.is_open()) |
| 487 | return false; |
| 488 | |
| 489 | size_t sectionCount = sections.size(); |
| 490 | size_t keyCount; |
| 491 | |
| 492 | file.write((fini_char_t*)§ionCount, sizeof(sectionCount)); |
| 493 | |
| 494 | //Loop through sections |
| 495 | for (typename INI::sectionsit_t i = sections.begin(); i != sections.end(); i++) |
| 496 | { |
| 497 | keyCount = i->second->size(); |
| 498 | file.write((fini_char_t*)&keyCount, sizeof(keyCount)); |
| 499 | |
| 500 | file.write((fini_char_t*)&i->first, Converters::GetDataSize(i->first)); |
| 501 | |
| 502 | for (typename INI::keysit_t j = i->second->begin(); j != i->second->end(); j++) |
| 503 | { |
| 504 | file.write((fini_char_t*)&j->first, Converters::GetDataSize(j->first)); |
| 505 | file.write((fini_char_t*)&j->second, Converters::GetDataSize(j->second)); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | file.close(); |
| 510 | |
| 511 | return true; |
| 512 | } |
| 513 | |
| 514 | //Alows another INI's contents to be insert into another, with the ability to retain the original values |
| 515 | void merge(ini_t& other, bool retainValues = true) |