1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:38:12 +00:00
serenity/Userland/Libraries/LibWeb/Cookie/ParsedCookie.h
Timothy Flynn 9b483625e6 LibIPC+Everywhere: Change IPC decoders to construct values in-place
Currently, the generated IPC decoders will default-construct the type to
be decoded, then pass that value by reference to the concrete decoder.
This, of course, requires that the type is default-constructible. This
was an issue for decoding Variants, which had to require the first type
in the Variant list is Empty, to ensure it is default constructible.

Further, this made it possible for values to become uninitialized in
user-defined decoders.

This patch makes the decoder interface such that the concrete decoders
themselves contruct the decoded type upon return from the decoder. To do
so, the default decoders in IPC::Decoder had to be moved to the IPC
namespace scope, as these decoders are now specializations instead of
overloaded methods (C++ requires specializations to be in a namespace
scope).
2022-12-26 09:36:16 +01:00

41 lines
983 B
C++

/*
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <LibCore/DateTime.h>
#include <LibIPC/Forward.h>
#include <LibWeb/Cookie/Cookie.h>
namespace Web::Cookie {
struct ParsedCookie {
DeprecatedString name;
DeprecatedString value;
SameSite same_site_attribute { SameSite::Default };
Optional<Core::DateTime> expiry_time_from_expires_attribute {};
Optional<Core::DateTime> expiry_time_from_max_age_attribute {};
Optional<DeprecatedString> domain {};
Optional<DeprecatedString> path {};
bool secure_attribute_present { false };
bool http_only_attribute_present { false };
};
Optional<ParsedCookie> parse_cookie(DeprecatedString const& cookie_string);
}
namespace IPC {
template<>
bool encode(Encoder&, Web::Cookie::ParsedCookie const&);
template<>
ErrorOr<Web::Cookie::ParsedCookie> decode(Decoder&);
}