Changeset 15655 for gsdl/trunk/lib/sqlitedbclass.cpp
- Timestamp:
- 2008-05-22T16:44:51+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/lib/sqlitedbclass.cpp
r15652 r15655 90 90 91 91 // returns true on success 92 bool sqlitedbclass::getinfo (const text_t& key, infodbclass &info)93 {94 text_t data;95 if (!getkeydata(key, data)) return false;96 97 // Use getinfoline() to parse the data value into the infodbclass object98 text_t::iterator data_iterator = data.begin();99 text_t ikey, ivalue;100 info.clear();101 while (getinfoline(data_iterator, data.end(), ikey, ivalue))102 {103 info.addinfo(ikey, ivalue);104 }105 106 return true;107 }108 109 110 // returns true on success111 92 bool sqlitedbclass::getkeydata (const text_t& key, text_t &data) 112 93 { … … 151 132 152 133 // returns true on success 153 bool sqlitedbclass::setinfo (const text_t &key, const infodbclass &info)154 {155 text_t subkey;156 text_t data;157 158 // get all the keys and values159 infodbclass::const_iterator info_here = info.begin();160 infodbclass::const_iterator info_end = info.end();161 while (info_here != info_end) {162 // add the key163 subkey.clear();164 subkey.push_back('<');165 text_t::const_iterator subkey_here = (*info_here).first.begin();166 text_t::const_iterator subkey_end = (*info_here).first.end();167 while (subkey_here != subkey_end) {168 if (*subkey_here == '>') {169 subkey.push_back('\\'); subkey.push_back('>');170 } else if (*subkey_here == '\n') {171 subkey.push_back('\\'); subkey.push_back('n');172 } else if (*subkey_here == '\r') {173 subkey.push_back('\\'); subkey.push_back('r');174 } else if (*subkey_here == '\\') {175 subkey.push_back('\\'); subkey.push_back('\\');176 } else {177 subkey.push_back (*subkey_here);178 }179 ++subkey_here;180 }181 subkey.push_back('>');182 183 // add the values184 text_tarray::const_iterator subvalue_here = (*info_here).second.begin();185 text_tarray::const_iterator subvalue_end = (*info_here).second.end();186 while (subvalue_here != subvalue_end) {187 data += subkey;188 189 text_t::const_iterator thissubvalue_here = (*subvalue_here).begin();190 text_t::const_iterator thissubvalue_end = (*subvalue_here).end();191 while (thissubvalue_here != thissubvalue_end) {192 if (*thissubvalue_here == '>') {193 data.push_back('\\'); data.push_back('>');194 } else if (*thissubvalue_here == '\n') {195 data.push_back('\\'); data.push_back('n');196 } else if (*thissubvalue_here == '\r') {197 data.push_back('\\'); data.push_back('r');198 } else if (*thissubvalue_here == '\\') {199 data.push_back('\\'); data.push_back('\\');200 } else {201 data.push_back (*thissubvalue_here);202 }203 204 ++thissubvalue_here;205 }206 207 data.push_back('\n');208 ++subvalue_here;209 }210 211 ++info_here;212 }213 214 return setkeydata(key, data);215 }216 217 218 // returns true on success219 134 bool sqlitedbclass::setkeydata (const text_t &key, const text_t &data) 220 135 { … … 233 148 234 149 235 // returns true on success236 bool sqlitedbclass::getinfoline (text_t::iterator &here, text_t::iterator end,237 text_t &key, text_t &value)238 {239 key.clear();240 value.clear();241 242 // ignore white space243 while (here != end && is_unicode_space (*here)) ++here;244 245 // get the '<'246 if (here == end || *here != '<') return false;247 ++here;248 249 // get the key250 while (here != end && *here != '>') {251 key.push_back(*here);252 ++here;253 }254 255 // get the '>'256 if (here == end || *here != '>') return false;257 ++here;258 259 // get the value260 while (here != end && *here != '\n') {261 if (*here == '\\') {262 // found escape character263 ++here;264 if (here != end) {265 if (*here == 'n') value.push_back ('\n');266 else if (*here == 'r') value.push_back ('\r');267 else value.push_back(*here);268 }269 270 } else {271 // a normal character272 value.push_back(*here);273 }274 275 ++here;276 }277 278 return true;279 }280 281 282 150 // ---------------------------------------------------------------------------------------- 283 // CORE SQLFUNCTIONS151 // SQLITE-ONLY FUNCTIONS 284 152 // ---------------------------------------------------------------------------------------- 285 153
Note:
See TracChangeset
for help on using the changeset viewer.