Alows another INI's contents to be insert into another, with the ability to retain the original values
| 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) |
| 516 | { |
| 517 | for (typename INI::sectionsit_t i = other.sections.begin(); i != other.sections.end(); i++) |
| 518 | { |
| 519 | if (!select(i->first)) //Create and insert all key values into a missing section |
| 520 | { |
| 521 | keys_t* keys = new keys_t(*i->second); |
| 522 | sections.insert(std::make_pair(i->first, keys)); |
| 523 | } |
| 524 | else |
| 525 | { |
| 526 | for (typename INI::keysit_t j = i->second->begin(); j != i->second->end(); j++) |
| 527 | { |
| 528 | keysit_t it = current->find(j->first); |
| 529 | if (it == current->end()) |
| 530 | current->insert(std::make_pair(j->first, j->second)); |
| 531 | else if (!retainValues) |
| 532 | it->second = j->second; |
| 533 | } |
| 534 | } |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | private: |
| 539 | ///Functions |