| 67 | |
| 68 | |
| 69 | Json::Value KeyValueStore::GetValue(const std::string& name) const |
| 70 | { |
| 71 | BNDataBuffer* bnBuffer = BNGetKeyValueStoreBuffer(m_object, name.c_str()); |
| 72 | if (bnBuffer == nullptr) |
| 73 | { |
| 74 | throw DatabaseException("BNGetKeyValueStoreBuffer"); |
| 75 | } |
| 76 | DataBuffer value = DataBuffer(bnBuffer); |
| 77 | Json::Value json; |
| 78 | std::unique_ptr<Json::CharReader> reader(Json::CharReaderBuilder().newCharReader()); |
| 79 | std::string errors; |
| 80 | if (!reader->parse(static_cast<const char*>(value.GetData()), |
| 81 | static_cast<const char*>(value.GetDataAt(value.GetLength())), &json, &errors)) |
| 82 | { |
| 83 | throw DatabaseException(errors); |
| 84 | } |
| 85 | return json; |
| 86 | } |
| 87 | |
| 88 | |
| 89 | DataBuffer KeyValueStore::GetValueHash(const std::string& name) const |
no test coverage detected