]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | // Licensed to the Apache Software Foundation(ASF) under one |
2 | // 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 | ||
18 | namespace Thrift.Protocol.Utilities | |
19 | { | |
20 | // ReSharper disable once InconsistentNaming | |
21 | public static class TJSONProtocolConstants | |
22 | { | |
23 | //TODO Check for performance for reusing ImmutableArray from System.Collections.Immutable (https://blogs.msdn.microsoft.com/dotnet/2013/06/24/please-welcome-immutablearrayt/) | |
24 | // can be possible to get better performance and also better GC | |
25 | ||
26 | public static readonly byte[] Comma = {(byte) ','}; | |
27 | public static readonly byte[] Colon = {(byte) ':'}; | |
28 | public static readonly byte[] LeftBrace = {(byte) '{'}; | |
29 | public static readonly byte[] RightBrace = {(byte) '}'}; | |
30 | public static readonly byte[] LeftBracket = {(byte) '['}; | |
31 | public static readonly byte[] RightBracket = {(byte) ']'}; | |
32 | public static readonly byte[] Quote = {(byte) '"'}; | |
33 | public static readonly byte[] Backslash = {(byte) '\\'}; | |
34 | ||
35 | public static readonly byte[] JsonCharTable = | |
36 | { | |
37 | 0, 0, 0, 0, 0, 0, 0, 0, (byte) 'b', (byte) 't', (byte) 'n', 0, (byte) 'f', (byte) 'r', 0, 0, | |
38 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
39 | 1, 1, (byte) '"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | |
40 | }; | |
41 | ||
42 | public static readonly char[] EscapeChars = "\"\\/bfnrt".ToCharArray(); | |
43 | public static readonly byte[] EscapeCharValues = {(byte) '"', (byte) '\\', (byte) '/', (byte) '\b', (byte) '\f', (byte) '\n', (byte) '\r', (byte) '\t'}; | |
44 | public static readonly byte[] EscSequences = {(byte) '\\', (byte) 'u', (byte) '0', (byte) '0'}; | |
45 | ||
46 | public static class TypeNames | |
47 | { | |
48 | public static readonly byte[] NameBool = { (byte)'t', (byte)'f' }; | |
49 | public static readonly byte[] NameByte = { (byte)'i', (byte)'8' }; | |
50 | public static readonly byte[] NameI16 = { (byte)'i', (byte)'1', (byte)'6' }; | |
51 | public static readonly byte[] NameI32 = { (byte)'i', (byte)'3', (byte)'2' }; | |
52 | public static readonly byte[] NameI64 = { (byte)'i', (byte)'6', (byte)'4' }; | |
53 | public static readonly byte[] NameDouble = { (byte)'d', (byte)'b', (byte)'l' }; | |
54 | public static readonly byte[] NameStruct = { (byte)'r', (byte)'e', (byte)'c' }; | |
55 | public static readonly byte[] NameString = { (byte)'s', (byte)'t', (byte)'r' }; | |
56 | public static readonly byte[] NameMap = { (byte)'m', (byte)'a', (byte)'p' }; | |
57 | public static readonly byte[] NameList = { (byte)'l', (byte)'s', (byte)'t' }; | |
58 | public static readonly byte[] NameSet = { (byte)'s', (byte)'e', (byte)'t' }; | |
59 | } | |
60 | } | |
61 | } |