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:
parent
6800f6eff5
commit
413ab652c8
3 changed files with 29 additions and 21 deletions
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue