blob: 6e248db8d778fbe925f7be89a67d58ea4da4f634 [file] [log] [blame]
Jens Geyer62445c12022-06-29 00:00:00 +02001// Licensed to the Apache Software Foundation(ASF) under one
Jens Geyeraa0c8b32019-01-28 23:27:45 +01002// or more contributor license agreements.See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
Jens Geyer4115e952023-11-21 23:00:01 +010018#pragma warning disable IDE0079 // net20 - unneeded suppression
19#pragma warning disable IDE0300 // net8 - simplified collection init
20
Jens Geyeraa0c8b32019-01-28 23:27:45 +010021namespace Thrift.Protocol.Utilities
22{
23 // ReSharper disable once InconsistentNaming
24 public static class TJSONProtocolConstants
25 {
26 //TODO Check for performance for reusing ImmutableArray from System.Collections.Immutable (https://blogs.msdn.microsoft.com/dotnet/2013/06/24/please-welcome-immutablearrayt/)
27 // can be possible to get better performance and also better GC
28
29 public static readonly byte[] Comma = {(byte) ','};
30 public static readonly byte[] Colon = {(byte) ':'};
31 public static readonly byte[] LeftBrace = {(byte) '{'};
32 public static readonly byte[] RightBrace = {(byte) '}'};
33 public static readonly byte[] LeftBracket = {(byte) '['};
34 public static readonly byte[] RightBracket = {(byte) ']'};
35 public static readonly byte[] Quote = {(byte) '"'};
36 public static readonly byte[] Backslash = {(byte) '\\'};
37
38 public static readonly byte[] JsonCharTable =
39 {
40 0, 0, 0, 0, 0, 0, 0, 0, (byte) 'b', (byte) 't', (byte) 'n', 0, (byte) 'f', (byte) 'r', 0, 0,
41 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42 1, 1, (byte) '"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
43 };
44
45 public static readonly char[] EscapeChars = "\"\\/bfnrt".ToCharArray();
46 public static readonly byte[] EscapeCharValues = {(byte) '"', (byte) '\\', (byte) '/', (byte) '\b', (byte) '\f', (byte) '\n', (byte) '\r', (byte) '\t'};
47 public static readonly byte[] EscSequences = {(byte) '\\', (byte) 'u', (byte) '0', (byte) '0'};
48
49 public static class TypeNames
50 {
51 public static readonly byte[] NameBool = { (byte)'t', (byte)'f' };
52 public static readonly byte[] NameByte = { (byte)'i', (byte)'8' };
53 public static readonly byte[] NameI16 = { (byte)'i', (byte)'1', (byte)'6' };
54 public static readonly byte[] NameI32 = { (byte)'i', (byte)'3', (byte)'2' };
55 public static readonly byte[] NameI64 = { (byte)'i', (byte)'6', (byte)'4' };
56 public static readonly byte[] NameDouble = { (byte)'d', (byte)'b', (byte)'l' };
57 public static readonly byte[] NameStruct = { (byte)'r', (byte)'e', (byte)'c' };
58 public static readonly byte[] NameString = { (byte)'s', (byte)'t', (byte)'r' };
59 public static readonly byte[] NameMap = { (byte)'m', (byte)'a', (byte)'p' };
60 public static readonly byte[] NameList = { (byte)'l', (byte)'s', (byte)'t' };
61 public static readonly byte[] NameSet = { (byte)'s', (byte)'e', (byte)'t' };
Jens Geyer62445c12022-06-29 00:00:00 +020062 public static readonly byte[] NameUuid = { (byte)'u', (byte)'i', (byte)'d' };
Jens Geyeraa0c8b32019-01-28 23:27:45 +010063 }
64 }
Jens Geyer62445c12022-06-29 00:00:00 +020065}