1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:35:07 +00:00
serenity/Userland/Libraries/LibWeb/Encoding/TextEncoder.h
Linus Groh 35d3a1e77b LibWeb: Add the TextEncoder interface
This is from the Encoding Standard (https://encoding.spec.whatwg.org),
and therefore gets its own namespace and subdirectory within LibWeb :^)
2021-12-12 20:58:36 +01:00

40 lines
878 B
C++

/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Forward.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
#include <LibJS/Forward.h>
#include <LibWeb/Bindings/Wrappable.h>
#include <LibWeb/Forward.h>
namespace Web::Encoding {
// https://encoding.spec.whatwg.org/#textencoder
class TextEncoder
: public RefCounted<TextEncoder>
, public Bindings::Wrappable {
public:
using WrapperType = Bindings::TextEncoderWrapper;
static NonnullRefPtr<TextEncoder> create()
{
return adopt_ref(*new TextEncoder());
}
static NonnullRefPtr<TextEncoder> create_with_global_object(Bindings::WindowObject&)
{
return TextEncoder::create();
}
protected:
// https://encoding.spec.whatwg.org/#dom-textencoder
TextEncoder() = default;
};
}