1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

LibIPC: Add support for passing around ByteBuffers and HashMap<K, V>

It should be noted that using a shared buffer should still be preferred
over passing a raw ByteBuffer over the wire.
This commit is contained in:
AnotherTest 2020-11-07 23:09:45 +03:30 committed by Andreas Kling
parent 705ad670f3
commit c930e02624
4 changed files with 59 additions and 0 deletions

View file

@ -60,8 +60,29 @@ public:
bool decode(i64&);
bool decode(float&);
bool decode(String&);
bool decode(ByteBuffer&);
bool decode(URL&);
bool decode(Dictionary&);
template<typename K, typename V>
bool decode(HashMap<K, V>& hashmap)
{
u32 size;
if (!decode(size) || size > NumericLimits<i32>::max())
return false;
for (size_t i = 0; i < size; ++i) {
K key;
if (!decode(key))
return false;
V value;
if (!decode(value))
return false;
hashmap.set(move(key), move(value));
}
return true;
}
template<typename T>
bool decode(T& value)