LibTextCodec: Enable EXPLICIT_SYMBOL_EXPORT

This commit is contained in:
ayeteadoe 2025-06-28 12:57:28 -07:00 committed by Andrew Kaster
commit e497303e94
Notes: github-actions[bot] 2025-08-23 22:07:22 +00:00
4 changed files with 49 additions and 31 deletions

View file

@ -12,10 +12,11 @@
#include <AK/Function.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <LibTextCodec/Forward.h>
namespace TextCodec {
class Decoder {
class TEXTCODEC_API Decoder {
public:
virtual bool validate(StringView);
virtual ErrorOr<String> to_utf8(StringView);
@ -25,14 +26,14 @@ protected:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) = 0;
};
class UTF8Decoder final : public Decoder {
class TEXTCODEC_API UTF8Decoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
virtual bool validate(StringView) override;
virtual ErrorOr<String> to_utf8(StringView) override;
};
class UTF16BEDecoder final : public Decoder {
class TEXTCODEC_API UTF16BEDecoder final : public Decoder {
public:
virtual bool validate(StringView) override;
virtual ErrorOr<String> to_utf8(StringView) override;
@ -41,7 +42,7 @@ private:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)>) override { VERIFY_NOT_REACHED(); }
};
class UTF16LEDecoder final : public Decoder {
class TEXTCODEC_API UTF16LEDecoder final : public Decoder {
public:
virtual bool validate(StringView) override;
virtual ErrorOr<String> to_utf8(StringView) override;
@ -64,55 +65,55 @@ private:
Array<ArrayType, 128> m_translation_table;
};
class Latin1Decoder final : public Decoder {
class TEXTCODEC_API Latin1Decoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
virtual bool validate(StringView) override { return true; }
};
class PDFDocEncodingDecoder final : public Decoder {
class TEXTCODEC_API PDFDocEncodingDecoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
virtual bool validate(StringView) override { return true; }
};
class XUserDefinedDecoder final : public Decoder {
class TEXTCODEC_API XUserDefinedDecoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
virtual bool validate(StringView) override { return true; }
};
class GB18030Decoder final : public Decoder {
class TEXTCODEC_API GB18030Decoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
};
class Big5Decoder final : public Decoder {
class TEXTCODEC_API Big5Decoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
};
class EUCJPDecoder final : public Decoder {
class TEXTCODEC_API EUCJPDecoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
};
class ISO2022JPDecoder final : public Decoder {
class TEXTCODEC_API ISO2022JPDecoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
};
class ShiftJISDecoder final : public Decoder {
class TEXTCODEC_API ShiftJISDecoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
};
class EUCKRDecoder final : public Decoder {
class TEXTCODEC_API EUCKRDecoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
};
class ReplacementDecoder final : public Decoder {
class TEXTCODEC_API ReplacementDecoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
virtual bool validate(StringView input) override { return input.is_empty(); }
@ -120,18 +121,18 @@ public:
// This will return a decoder for the exact name specified, skipping get_standardized_encoding.
// Use this when you want ISO-8859-1 instead of windows-1252.
Optional<Decoder&> decoder_for_exact_name(StringView encoding);
TEXTCODEC_API Optional<Decoder&> decoder_for_exact_name(StringView encoding);
Optional<Decoder&> decoder_for(StringView encoding);
Optional<StringView> get_standardized_encoding(StringView encoding);
TEXTCODEC_API Optional<Decoder&> decoder_for(StringView encoding);
TEXTCODEC_API Optional<StringView> get_standardized_encoding(StringView encoding);
// This returns the appropriate Unicode decoder for the sniffed BOM or nothing if there is no appropriate decoder.
Optional<Decoder&> bom_sniff_to_decoder(StringView);
TEXTCODEC_API Optional<Decoder&> bom_sniff_to_decoder(StringView);
// NOTE: This has an obnoxious name to discourage usage. Only use this if you absolutely must! For example, XHR in LibWeb uses this.
// This will use the given decoder unless there is a byte order mark in the input, in which we will instead use the appropriate Unicode decoder.
ErrorOr<String> convert_input_to_utf8_using_given_decoder_unless_there_is_a_byte_order_mark(Decoder&, StringView);
TEXTCODEC_API ErrorOr<String> convert_input_to_utf8_using_given_decoder_unless_there_is_a_byte_order_mark(Decoder&, StringView);
StringView get_output_encoding(StringView encoding);
TEXTCODEC_API StringView get_output_encoding(StringView encoding);
}