12 checkSlow(SourceLengthRemaining > 0);
14 const ANSICHAR* OctetPtr = SourceString;
17 uint32 Octet = (uint32)((uint8)*SourceString);
18 uint32 Octet2, Octet3, Octet4;
30 return UNICODE_BOGUS_CHAR_CODEPOINT;
35 if (SourceLengthRemaining < 2)
38 SourceString += SourceLengthRemaining;
39 return UNICODE_BOGUS_CHAR_CODEPOINT;
43 Octet2 = (uint32)((uint8) * (++OctetPtr));
44 if ((Octet2 & (128 + 64)) != 128)
47 return UNICODE_BOGUS_CHAR_CODEPOINT;
50 Codepoint = ((Octet << 6) | (Octet2 - 128));
51 if ((Codepoint >= 0x80) && (Codepoint <= 0x7FF))
60 if (SourceLengthRemaining < 3)
63 SourceString += SourceLengthRemaining;
64 return UNICODE_BOGUS_CHAR_CODEPOINT;
67 Octet -= (128 + 64 + 32);
68 Octet2 = (uint32)((uint8) * (++OctetPtr));
69 if ((Octet2 & (128 + 64)) != 128)
72 return UNICODE_BOGUS_CHAR_CODEPOINT;
75 Octet3 = (uint32)((uint8) * (++OctetPtr));
76 if ((Octet3 & (128 + 64)) != 128)
79 return UNICODE_BOGUS_CHAR_CODEPOINT;
82 Codepoint = (((Octet << 12)) | ((Octet2 - 128) << 6) | ((Octet3 - 128)));
85 if (StringConv::IsHighSurrogate(Codepoint) || StringConv::IsLowSurrogate(Codepoint))
88 return UNICODE_BOGUS_CHAR_CODEPOINT;
92 if ((Codepoint >= 0x800) && (Codepoint <= 0xFFFD))
101 if (SourceLengthRemaining < 4)
104 SourceString += SourceLengthRemaining;
105 return UNICODE_BOGUS_CHAR_CODEPOINT;
108 Octet -= (128 + 64 + 32 + 16);
109 Octet2 = (uint32)((uint8) * (++OctetPtr));
110 if ((Octet2 & (128 + 64)) != 128)
113 return UNICODE_BOGUS_CHAR_CODEPOINT;
116 Octet3 = (uint32)((uint8) * (++OctetPtr));
117 if ((Octet3 & (128 + 64)) != 128)
120 return UNICODE_BOGUS_CHAR_CODEPOINT;
123 Octet4 = (uint32)((uint8) * (++OctetPtr));
124 if ((Octet4 & (128 + 64)) != 128)
127 return UNICODE_BOGUS_CHAR_CODEPOINT;
130 Codepoint = (((Octet << 18)) | ((Octet2 - 128) << 12) |
131 ((Octet3 - 128) << 6) | ((Octet4 - 128)));
132 if ((Codepoint >= 0x10000) && (Codepoint <= 0x10FFFF))
141 else if (Octet < 252)
144 if (SourceLengthRemaining < 5)
147 SourceString += SourceLengthRemaining;
148 return UNICODE_BOGUS_CHAR_CODEPOINT;
151 Octet = (uint32)((uint8) * (++OctetPtr));
152 if ((Octet & (128 + 64)) != 128)
155 return UNICODE_BOGUS_CHAR_CODEPOINT;
158 Octet = (uint32)((uint8) * (++OctetPtr));
159 if ((Octet & (128 + 64)) != 128)
162 return UNICODE_BOGUS_CHAR_CODEPOINT;
165 Octet = (uint32)((uint8) * (++OctetPtr));
166 if ((Octet & (128 + 64)) != 128)
169 return UNICODE_BOGUS_CHAR_CODEPOINT;
172 Octet = (uint32)((uint8) * (++OctetPtr));
173 if ((Octet & (128 + 64)) != 128)
176 return UNICODE_BOGUS_CHAR_CODEPOINT;
180 return UNICODE_BOGUS_CHAR_CODEPOINT;
186 if (SourceLengthRemaining < 6)
189 SourceString += SourceLengthRemaining;
190 return UNICODE_BOGUS_CHAR_CODEPOINT;
193 Octet = (uint32)((uint8) * (++OctetPtr));
194 if ((Octet & (128 + 64)) != 128)
197 return UNICODE_BOGUS_CHAR_CODEPOINT;
200 Octet = (uint32)((uint8) * (++OctetPtr));
201 if ((Octet & (128 + 64)) != 128)
204 return UNICODE_BOGUS_CHAR_CODEPOINT;
207 Octet = (uint32)((uint8) * (++OctetPtr));
208 if ((Octet & (128 + 64)) != 128)
211 return UNICODE_BOGUS_CHAR_CODEPOINT;
214 Octet = (uint32)((uint8) * (++OctetPtr));
215 if ((Octet & (128 + 64)) != 128)
218 return UNICODE_BOGUS_CHAR_CODEPOINT;
221 Octet = (uint32)((uint8) * (++OctetPtr));
222 if ((Octet & (128 + 64)) != 128)
225 return UNICODE_BOGUS_CHAR_CODEPOINT;
229 return UNICODE_BOGUS_CHAR_CODEPOINT;
233 return UNICODE_BOGUS_CHAR_CODEPOINT;
324 const auto Value =
Objects.Last(0);
325 if (Value->Type == EJson::Object || Value->Type == EJson::Array)
341 const auto LowerCase =
Data.ToLower();
342 if (LowerCase != TEXT(
"null"))
358 const FString LowerCase =
Data.ToLower();
359 int32 ePosition = INDEX_NONE;
360 LowerCase.FindChar(
'e', ePosition);
361 if (ePosition == INDEX_NONE)
363 if (LowerCase.IsNumeric())
372 else if (LowerCase.Len() > ePosition + 2)
374 const FString Left = LowerCase.Left(ePosition);
375 const FString Rigth = LowerCase.Right(LowerCase.Len() - ePosition - 1);
376 if (Left.IsNumeric() && Rigth.IsNumeric())
378 ((
FJsonValueNonConstNumber*)Value.Get())->AsNonConstNumber() = FCString::Atod(*Left) * FMath::Pow(10.f, FCString::Atoi(*Rigth));
393 const auto LowerCase =
Data.ToLower();
394 if (LowerCase == TEXT(
"true"))
398 else if (LowerCase == TEXT(
"false"))
417 const auto Container =
Objects.Last(0);
418 if (Container->Type == EJson::Object)
422 FString KeyCopy =
Key;
424 Container->AsObject()->SetField(KeyCopy, Value);
425 Size += KeyCopy.GetAllocatedSize();
433 else if (Container->Type == EJson::Array)
1050 FArchive& Ar = *Writer;
1057 switch (JsonValue->Type)
1061 int ElementsCount = 0;
1062 auto Values = JsonValue->AsObject()->Values;
1064 for (
auto& ChildJsonPair : Values)
1066 Str = FString(TEXT(
"\""));
1069 const TCHAR* BufferPtr = *ChildJsonPair.Key;
1070 for (
int i = 0; i < ChildJsonPair.Key.Len(); ++i)
1072 Str = FString(1, &ChildJsonPair.Key[i]);
1076 Str = FString(TEXT(
"\""));
1079 Str = FString(TEXT(
":"));
1084 Write(ChildJsonPair.Value, Writer, ElementsCount >= Values.Num());
1090 int ElementsCount = 0;
1091 auto Array = JsonValue->AsArray();
1093 for (
auto& ChildJsonValue :
Array)
1096 Write(ChildJsonValue, Writer, ElementsCount >=
Array.Num());
1102 const FString Value = JsonValue->AsString();
1104 const TCHAR* BufferPtr = *Value;
1105 for (
int i = 0; i < Value.Len(); ++i)
1107 Str = FString(1, &BufferPtr[i]);
1108 if (Str == TEXT(
"\""))
1110 Str = FString(TEXT(
"\\"));
1112 Str = FString(1, &BufferPtr[i]);
1114 if (Str == TEXT(
"\n"))
1116 Str = FString(TEXT(
"\\"));
1118 Str = FString(TEXT(
"n"));
1120 Str = FString(1, &BufferPtr[i]);
1122 else if (Str == TEXT(
"\t"))
1124 Str = FString(TEXT(
"\\"));
1126 Str = FString(TEXT(
"t"));
1128 Str = FString(1, &BufferPtr[i]);
1147 Str = FString(TEXT(
","));