| 479 | |
| 480 | |
| 481 | Json::Value Database::ReadGlobal(const std::string& key) const |
| 482 | { |
| 483 | char* value = BNReadDatabaseGlobal(m_object, key.c_str()); |
| 484 | if (value == nullptr) |
| 485 | { |
| 486 | throw DatabaseException("BNReadDatabaseGlobal"); |
| 487 | } |
| 488 | |
| 489 | Json::Value json; |
| 490 | std::unique_ptr<Json::CharReader> reader(Json::CharReaderBuilder().newCharReader()); |
| 491 | std::string errors; |
| 492 | if (!reader->parse(value, value + strlen(value), &json, &errors)) |
| 493 | { |
| 494 | throw DatabaseException(errors); |
| 495 | } |
| 496 | |
| 497 | BNFreeString(value); |
| 498 | return json; |
| 499 | } |
| 500 | |
| 501 | |
| 502 | void Database::WriteGlobal(const std::string& key, const Json::Value& val) |