mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-03 06:40:05 +00:00
AK+LibIPC: Make all enums codable
If an enum has a supported underlying type we can provide encoding and decoding for the enum as well.
This commit is contained in:
parent
60f84f3154
commit
e42484bb65
Notes:
sideshowbarker
2024-07-18 10:30:55 +09:00
Author: https://github.com/timmot
Commit: e42484bb65
Pull-request: https://github.com/SerenityOS/serenity/pull/8421
Reviewed-by: https://github.com/Dexesttp
Reviewed-by: https://github.com/alimpfard
3 changed files with 25 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Concepts.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
@ -66,6 +67,17 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
template<Enum T>
|
||||
bool decode(T& enum_value)
|
||||
{
|
||||
UnderlyingType<T> inner_value;
|
||||
if (!decode(inner_value))
|
||||
return false;
|
||||
|
||||
enum_value = T(inner_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool decode(T& value)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue