| 237 | } |
| 238 | |
| 239 | void endElement(void* ctx, const char* name) override |
| 240 | { |
| 241 | SAXState curState = _stateStack.empty() ? SAX_DICT : _stateStack.top(); |
| 242 | const std::string sName((char*)name); |
| 243 | if (sName == "dict"sv) |
| 244 | { |
| 245 | _stateStack.pop(); |
| 246 | _dictStack.pop(); |
| 247 | if (!_dictStack.empty()) |
| 248 | { |
| 249 | _curDict = _dictStack.top(); |
| 250 | } |
| 251 | } |
| 252 | else if (sName == "array"sv) |
| 253 | { |
| 254 | _stateStack.pop(); |
| 255 | _arrayStack.pop(); |
| 256 | if (!_arrayStack.empty()) |
| 257 | { |
| 258 | _curArray = _arrayStack.top(); |
| 259 | } |
| 260 | } |
| 261 | else if (sName == "true"sv) |
| 262 | { |
| 263 | if (SAX_ARRAY == curState) |
| 264 | { |
| 265 | _curArray->emplace_back(Value(true)); |
| 266 | } |
| 267 | else if (SAX_DICT == curState) |
| 268 | { |
| 269 | (*_curDict)[_curKey] = Value(true); |
| 270 | } |
| 271 | } |
| 272 | else if (sName == "false"sv) |
| 273 | { |
| 274 | if (SAX_ARRAY == curState) |
| 275 | { |
| 276 | _curArray->emplace_back(Value(false)); |
| 277 | } |
| 278 | else if (SAX_DICT == curState) |
| 279 | { |
| 280 | (*_curDict)[_curKey] = Value(false); |
| 281 | } |
| 282 | } |
| 283 | else if (sName == "string"sv || sName == "integer"sv || sName == "real"sv) |
| 284 | { |
| 285 | if (SAX_ARRAY == curState) |
| 286 | { |
| 287 | if (sName == "string"sv) |
| 288 | _curArray->emplace_back(Value(_curValue)); |
| 289 | else if (sName == "integer"sv) |
| 290 | _curArray->emplace_back(Value(atoi(_curValue.c_str()))); |
| 291 | else |
| 292 | _curArray->emplace_back(Value(std::atof(_curValue.c_str()))); |
| 293 | } |
| 294 | else if (SAX_DICT == curState) |
| 295 | { |
| 296 | if (sName == "string"sv) |