mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
add json BJSON_TYPE_BYTES support
This commit is contained in:
parent
6f4a7db910
commit
f8fadf8b74
7 changed files with 72 additions and 8 deletions
|
|
@ -249,6 +249,12 @@ List_sptr Map::list(const std::string& key) const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ByteBuffer_sptr Map::bytes(const std::string& key) const {
|
||||
auto found = values.find(key);
|
||||
if (found != values.end()) return std::get<ByteBuffer_sptr>(found->second);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Map::flag(const std::string& key, bool& dst) const {
|
||||
dst = get(key, dst);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ namespace dynamic {
|
|||
none = 0,
|
||||
map,
|
||||
list,
|
||||
bytes,
|
||||
string,
|
||||
number,
|
||||
boolean,
|
||||
integer,
|
||||
bytes
|
||||
integer
|
||||
};
|
||||
|
||||
const std::string& type_name(const Value& value);
|
||||
|
|
@ -127,6 +127,7 @@ namespace dynamic {
|
|||
void num(const std::string& key, double& dst) const;
|
||||
Map_sptr map(const std::string& key) const;
|
||||
List_sptr list(const std::string& key) const;
|
||||
ByteBuffer_sptr bytes(const std::string& key) const;
|
||||
void flag(const std::string& key, bool& dst) const;
|
||||
|
||||
Map& put(std::string key, std::unique_ptr<Map> value) {
|
||||
|
|
@ -156,6 +157,13 @@ namespace dynamic {
|
|||
Map& put(std::string key, bool value) {
|
||||
return put(key, Value(static_cast<bool>(value)));
|
||||
}
|
||||
Map& put(const std::string& key, const ByteBuffer* bytes) {
|
||||
return put(key, std::make_unique<ByteBuffer>(
|
||||
bytes->data(), bytes->size()));
|
||||
}
|
||||
Map& put(std::string key, const ubyte* bytes, size_t size) {
|
||||
return put(key, std::make_unique<ByteBuffer>(bytes, size));
|
||||
}
|
||||
Map& put(std::string key, const char* value) {
|
||||
return put(key, Value(value));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue