| 86 | /// |
| 87 | template <typename T = fini_string_t, typename U = fini_string_t, typename V = fini_string_t> |
| 88 | class INI |
| 89 | { |
| 90 | public: |
| 91 | typedef T section_t; |
| 92 | typedef U key_t; |
| 93 | typedef V value_t; |
| 94 | typedef INI<section_t, key_t, value_t> ini_t; |
| 95 | |
| 96 | ///Type definition declarations |
| 97 | #ifdef FINI_CPP11 |
| 98 | typedef typename std::unordered_map<key_t, value_t> keys_t; |
| 99 | typedef typename std::unordered_map<section_t, keys_t*> sections_t; |
| 100 | #else |
| 101 | typedef typename std::map<key_t, value_t> keys_t; |
| 102 | typedef typename std::map<section_t, keys_t*> sections_t; |
| 103 | #endif |
| 104 | |
| 105 | typedef typename keys_t::iterator keysit_t; |
| 106 | typedef typename sections_t::iterator sectionsit_t; |
| 107 | |
| 108 | typedef typename std::pair<key_t, value_t> keyspair_t; |
| 109 | typedef typename std::pair<section_t, keys_t*> sectionspair_t; |
| 110 | |
| 111 | typedef char data_t; |
| 112 | |
| 113 | enum source_e { SOURCE_FILE, SOURCE_MEMORY }; |
| 114 | |
| 115 | ///Data members |
| 116 | std::string filename; |
| 117 | data_t* data; |
| 118 | size_t dataSize; |
| 119 | keys_t* current; |
| 120 | sections_t sections; |
| 121 | source_e source; |
| 122 | |
| 123 | ///Constuctor/Destructor |
| 124 | //Specify the filename to associate and whether to parse immediately |
| 125 | INI(const std::string filename, bool doParse) : filename(filename) |
| 126 | { |
| 127 | init(SOURCE_FILE, doParse); |
| 128 | } |
| 129 | |
| 130 | //Used for loading INI from memory |
| 131 | INI(void* data, size_t dataSize, bool doParse) : data((data_t*)data), dataSize(dataSize) |
| 132 | { |
| 133 | init(SOURCE_MEMORY, doParse); |
| 134 | } |
| 135 | |
| 136 | ~INI() |
| 137 | { |
| 138 | clear(); |
| 139 | } |
| 140 | |
| 141 | ///Access Content |
| 142 | //Provide bracket access to section contents |
| 143 | keys_t& operator[](section_t section) |
| 144 | { |
| 145 | #ifdef FINI_SAFE |