Merge branch 'main' into heightmaps

This commit is contained in:
MihailRis 2024-09-12 18:26:09 +03:00
commit 16f9c42d59
2 changed files with 20 additions and 0 deletions

View File

@ -129,6 +129,12 @@ Map& List::putMap() {
return *map;
}
ByteBuffer& List::putBytes(size_t size) {
auto bytes = create_bytes(size);
put(bytes);
return *bytes;
}
void List::remove(size_t index) {
values.erase(values.begin() + index);
}
@ -280,6 +286,12 @@ Map& Map::putMap(const std::string& key) {
return *obj;
}
ByteBuffer& Map::putBytes(const std::string& key, size_t size) {
auto bytes = create_bytes(size);
put(key, bytes);
return *bytes;
}
bool Map::has(const std::string& key) const {
return values.find(key) != values.end();
}
@ -312,6 +324,10 @@ Map_sptr dynamic::create_map(
return std::make_shared<Map>(entries);
}
ByteBuffer_sptr dynamic::create_bytes(size_t size) {
return std::make_shared<ByteBuffer>(size);
}
number_t dynamic::get_number(const Value& value) {
if (auto num = std::get_if<number_t>(&value)) {
return *num;

View File

@ -27,6 +27,8 @@ namespace dynamic {
Map_sptr create_map(
std::initializer_list<std::pair<const std::string, Value>> entries = {}
);
ByteBuffer_sptr create_bytes(size_t size);
number_t get_number(const Value& value);
integer_t get_integer(const Value& value);
@ -82,6 +84,7 @@ namespace dynamic {
List& putList();
Map& putMap();
ByteBuffer& putBytes(size_t size);
void remove(size_t index);
};
@ -173,6 +176,7 @@ namespace dynamic {
List& putList(const std::string& key);
Map& putMap(const std::string& key);
ByteBuffer& putBytes(const std::string& key, size_t size);
bool has(const std::string& key) const;
size_t size() const;