CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
json_reader_helper.h
1#pragma once
2
3#include <system/array.h>
4#include <cstdint>
5
6namespace System
7{
8namespace Buffers
9{
10template <typename> class ReadOnlySequence;
11template <typename> class SearchValues;
12} // namespace Buffers
13class DateTime;
14class DateTimeOffset;
15class Guid;
16class Half;
17template <typename> class ReadOnlySpan;
18template <typename> class Span;
19namespace Text
20{
21namespace Json
22{
23enum class JsonTokenType : uint8_t;
24enum class JsonValueKind : uint8_t;
25} // namespace Json
26class StringBuilder;
27class UTF8Encoding;
28class ValueStringBuilder;
29} // namespace Text
30template <typename...> class ValueTuple;
31} // namespace System
32
33namespace System {
34
35namespace Text {
36
37namespace Json {
38
40{
42
43public:
44
46
47 static ASPOSECPP_SHARED_API bool ContainsSpecialCharacters(ReadOnlySpan<char16_t> text);
48 static ASPOSECPP_SHARED_API void AppendEscapedPropertyName(ValueStringBuilder& builder, String propertyName);
49 static ASPOSECPP_SHARED_API void AppendEscapedPropertyName(System::SharedPtr<StringBuilder> builder, String propertyName);
51 static ASPOSECPP_SHARED_API JsonValueKind ToValueKind(JsonTokenType tokenType);
52 static ASPOSECPP_SHARED_API bool IsTokenTypePrimitive(JsonTokenType tokenType);
53 static ASPOSECPP_SHARED_API bool IsHexDigit(uint8_t nextByte);
54 static ASPOSECPP_SHARED_API bool TryGetValue(ReadOnlySpan<uint8_t> segment, bool isEscaped, DateTime& value);
55 static ASPOSECPP_SHARED_API bool TryGetEscapedDateTime(ReadOnlySpan<uint8_t> source, DateTime& value);
56 static ASPOSECPP_SHARED_API bool TryGetValue(ReadOnlySpan<uint8_t> segment, bool isEscaped, DateTimeOffset& value);
57 static ASPOSECPP_SHARED_API bool TryGetEscapedDateTimeOffset(ReadOnlySpan<uint8_t> source, DateTimeOffset& value);
58 static ASPOSECPP_SHARED_API bool TryGetValue(ReadOnlySpan<uint8_t> segment, bool isEscaped, Guid& value);
59 static ASPOSECPP_SHARED_API bool TryGetEscapedGuid(ReadOnlySpan<uint8_t> source, Guid& value);
60 static ASPOSECPP_SHARED_API bool TryGetFloatingPointConstant(ReadOnlySpan<uint8_t> span, float& value);
61 static ASPOSECPP_SHARED_API bool TryGetFloatingPointConstant(ReadOnlySpan<uint8_t> span, double& value);
62 static ASPOSECPP_SHARED_API int32_t IndexOfQuoteOrAnyControlOrBackSlash(ReadOnlySpan<uint8_t> span);
63 static ASPOSECPP_SHARED_API int32_t IndexOfFirstNonWhiteSpace(ReadOnlySpan<uint8_t> span);
64 static ASPOSECPP_SHARED_API bool TryGetUnescapedBase64Bytes(ReadOnlySpan<uint8_t> utf8Source, System::SharedPtr<Array<uint8_t>>& bytes);
65 static ASPOSECPP_SHARED_API String GetUnescapedString(ReadOnlySpan<uint8_t> utf8Source);
67 static ASPOSECPP_SHARED_API bool UnescapeAndCompare(ReadOnlySpan<uint8_t> utf8Source, ReadOnlySpan<uint8_t> other);
68 static ASPOSECPP_SHARED_API bool UnescapeAndCompare(Buffers::ReadOnlySequence<uint8_t> utf8Source, ReadOnlySpan<uint8_t> other);
69 static ASPOSECPP_SHARED_API bool UnescapeAndCompareBothInputs(ReadOnlySpan<uint8_t> utf8Source1, ReadOnlySpan<uint8_t> utf8Source2);
70 static ASPOSECPP_SHARED_API bool TryDecodeBase64InPlace(Span<uint8_t> utf8Unescaped, System::SharedPtr<Array<uint8_t>>& bytes);
71 static ASPOSECPP_SHARED_API bool TryDecodeBase64(ReadOnlySpan<uint8_t> utf8Unescaped, System::SharedPtr<Array<uint8_t>>& bytes);
72 static ASPOSECPP_SHARED_API String TranscodeHelper(ReadOnlySpan<uint8_t> utf8Unescaped);
73 static ASPOSECPP_SHARED_API int32_t TranscodeHelper(ReadOnlySpan<uint8_t> utf8Unescaped, Span<char16_t> destination);
74 static ASPOSECPP_SHARED_API void ValidateUtf8(ReadOnlySpan<uint8_t> utf8Buffer);
75 static ASPOSECPP_SHARED_API int32_t GetUtf8ByteCount(ReadOnlySpan<char16_t> text);
76 static ASPOSECPP_SHARED_API int32_t GetUtf8FromText(ReadOnlySpan<char16_t> text, Span<uint8_t> dest);
77 static ASPOSECPP_SHARED_API String GetTextFromUtf8(ReadOnlySpan<uint8_t> utf8Text);
78 static ASPOSECPP_SHARED_API void Unescape(ReadOnlySpan<uint8_t> source, Span<uint8_t> destination, int32_t& written);
79 static ASPOSECPP_SHARED_API void Unescape(ReadOnlySpan<uint8_t> source, Span<uint8_t> destination, int32_t idx, int32_t& written);
80 static ASPOSECPP_SHARED_API bool TryUnescape(ReadOnlySpan<uint8_t> source, Span<uint8_t> destination, int32_t& written);
81
82private:
83
84 static System::SharedPtr<Buffers::SearchValues<char16_t>> s_specialCharacters;
85 static System::SharedPtr<Buffers::SearchValues<char16_t>> s_charactersToEscape;
86 static System::SharedPtr<Buffers::SearchValues<uint8_t>> s_controlQuoteBackslash;
88
89 static bool TryUnescape(ReadOnlySpan<uint8_t> source, Span<uint8_t> destination, int32_t idx, int32_t& written);
90
91 static struct __StaticConstructor__ { __StaticConstructor__(); } s_constructor__;
92
93public:
94 JsonReaderHelper() = delete;
95};
96
97} // namespace Json
98} // namespace Text
99} // namespace System
Class that represents an array data structure. Objects of this class should only be allocated using S...
Definition: array.h:296
Represents a specific date and time value on the time continuum. This type should be allocated on sta...
Definition: date_time.h:50
Contains the date and time of day relative to Coordinated Universal Time. Objects of this class shoul...
Definition: date_time_offset.h:16
Represents a Globally Unique IDentifier This type should be allocated on stack and passed to function...
Definition: guid.h:34
Forward to use within Span class.
Definition: span.h:415
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Represents a contiguous region of arbitrary memory similar to C++20's std::span.
Definition: span.h:375
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:126
Definition: json_reader_helper.h:40
static int32_t GetUtf8ByteCount(ReadOnlySpan< char16_t > text)
static bool TryGetEscapedDateTimeOffset(ReadOnlySpan< uint8_t > source, DateTimeOffset &value)
static void AppendEscapedPropertyName(System::SharedPtr< StringBuilder > builder, String propertyName)
static bool TryGetValue(ReadOnlySpan< uint8_t > segment, bool isEscaped, Guid &value)
static bool IsTokenTypePrimitive(JsonTokenType tokenType)
static void AppendEscapedPropertyName(ValueStringBuilder &builder, String propertyName)
static bool IsHexDigit(uint8_t nextByte)
static bool TryGetValue(ReadOnlySpan< uint8_t > segment, bool isEscaped, DateTime &value)
static int32_t IndexOfQuoteOrAnyControlOrBackSlash(ReadOnlySpan< uint8_t > span)
static String GetTextFromUtf8(ReadOnlySpan< uint8_t > utf8Text)
static bool TryGetEscapedGuid(ReadOnlySpan< uint8_t > source, Guid &value)
static void ValidateUtf8(ReadOnlySpan< uint8_t > utf8Buffer)
static bool UnescapeAndCompareBothInputs(ReadOnlySpan< uint8_t > utf8Source1, ReadOnlySpan< uint8_t > utf8Source2)
static bool ContainsSpecialCharacters(ReadOnlySpan< char16_t > text)
static int32_t IndexOfFirstNonWhiteSpace(ReadOnlySpan< uint8_t > span)
static bool TryUnescape(ReadOnlySpan< uint8_t > source, Span< uint8_t > destination, int32_t &written)
static bool TryGetFloatingPointConstant(ReadOnlySpan< uint8_t > span, double &value)
static bool UnescapeAndCompare(Buffers::ReadOnlySequence< uint8_t > utf8Source, ReadOnlySpan< uint8_t > other)
static String TranscodeHelper(ReadOnlySpan< uint8_t > utf8Unescaped)
static int32_t GetUtf8FromText(ReadOnlySpan< char16_t > text, Span< uint8_t > dest)
static bool TryDecodeBase64(ReadOnlySpan< uint8_t > utf8Unescaped, System::SharedPtr< Array< uint8_t > > &bytes)
static ValueTuple< int32_t, int32_t > CountNewLines(ReadOnlySpan< uint8_t > data)
static String GetUnescapedString(ReadOnlySpan< uint8_t > utf8Source)
static JsonValueKind ToValueKind(JsonTokenType tokenType)
static bool TryGetValue(ReadOnlySpan< uint8_t > segment, bool isEscaped, DateTimeOffset &value)
static void Unescape(ReadOnlySpan< uint8_t > source, Span< uint8_t > destination, int32_t idx, int32_t &written)
static bool TryGetEscapedDateTime(ReadOnlySpan< uint8_t > source, DateTime &value)
static int32_t TranscodeHelper(ReadOnlySpan< uint8_t > utf8Unescaped, Span< char16_t > destination)
static void Unescape(ReadOnlySpan< uint8_t > source, Span< uint8_t > destination, int32_t &written)
static System::SharedPtr< Array< uint8_t > > GetUnescaped(ReadOnlySpan< uint8_t > utf8Source)
static bool TryGetFloatingPointConstant(ReadOnlySpan< uint8_t > span, float &value)
static bool TryGetUnescapedBase64Bytes(ReadOnlySpan< uint8_t > utf8Source, System::SharedPtr< Array< uint8_t > > &bytes)
static bool TryDecodeBase64InPlace(Span< uint8_t > utf8Unescaped, System::SharedPtr< Array< uint8_t > > &bytes)
static System::SharedPtr< UTF8Encoding > s_utf8Encoding
Definition: json_reader_helper.h:45
static bool UnescapeAndCompare(ReadOnlySpan< uint8_t > utf8Source, ReadOnlySpan< uint8_t > other)
Definition: value_string_builder.h:17
@ Half
Pixels are offset by -0.5 units both horizontally and vertically for high performance anti-aliasing.
@ Text
Defines color adjustment information for text.
JsonTokenType
Definition: json_token_type.h:12
JsonValueKind
Definition: json_value_kind.h:12
Definition: db_command.h:9