LibGUI: Add IPC encode and decode for FileTypeFilter
Allows the use of GUI::FileTypeFilter in IPC.
This commit is contained in:
parent
95da08e035
commit
106ad6bb13
Notes:
sideshowbarker
2024-07-17 04:10:16 +09:00
Author: https://github.com/huttongrabiel Commit: https://github.com/SerenityOS/serenity/commit/106ad6bb13 Pull-request: https://github.com/SerenityOS/serenity/pull/17904 Reviewed-by: https://github.com/AtkinsSJ
1 changed files with 23 additions and 0 deletions
|
@ -9,6 +9,8 @@
|
|||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
@ -28,3 +30,24 @@ struct FileTypeFilter {
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
inline ErrorOr<void> encode(Encoder& encoder, GUI::FileTypeFilter const& response)
|
||||
{
|
||||
TRY(encoder.encode(response.name));
|
||||
TRY(encoder.encode(response.extensions));
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
inline ErrorOr<GUI::FileTypeFilter> decode(Decoder& decoder)
|
||||
{
|
||||
auto name = TRY(decoder.decode<DeprecatedString>());
|
||||
auto extensions = TRY(decoder.decode<Optional<Vector<AK::DeprecatedString>>>());
|
||||
|
||||
return GUI::FileTypeFilter { move(name), move(extensions) };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue