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

LibIPC+IPCCompiler: Templatize encoding/decoding of Optional<T>

This was the last one! IPCCompiler no longer has any type-specific
encoding/decoding logic! :^)
This commit is contained in:
Andreas Kling 2020-05-12 19:02:44 +02:00
parent 6800f6eff5
commit 413ab652c8
3 changed files with 29 additions and 21 deletions

View file

@ -83,6 +83,23 @@ public:
return true;
}
template<typename T>
bool decode(Optional<T>& optional)
{
bool has_value;
if (!decode(has_value))
return false;
if (!has_value) {
optional = {};
return true;
}
T value;
if (!decode(value))
return false;
optional = move(value);
return true;
}
private:
BufferStream& m_stream;
};