Girish Gowdra | 631ef3d | 2020-06-15 10:45:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | package thrift |
| 21 | |
| 22 | // Type constants in the Thrift protocol |
| 23 | type TType byte |
| 24 | |
| 25 | const ( |
| 26 | STOP = 0 |
| 27 | VOID = 1 |
| 28 | BOOL = 2 |
| 29 | BYTE = 3 |
| 30 | I08 = 3 |
| 31 | DOUBLE = 4 |
| 32 | I16 = 6 |
| 33 | I32 = 8 |
| 34 | I64 = 10 |
| 35 | STRING = 11 |
| 36 | UTF7 = 11 |
| 37 | STRUCT = 12 |
| 38 | MAP = 13 |
| 39 | SET = 14 |
| 40 | LIST = 15 |
| 41 | UTF8 = 16 |
| 42 | UTF16 = 17 |
| 43 | //BINARY = 18 wrong and unusued |
| 44 | ) |
| 45 | |
| 46 | var typeNames = map[int]string{ |
| 47 | STOP: "STOP", |
| 48 | VOID: "VOID", |
| 49 | BOOL: "BOOL", |
| 50 | BYTE: "BYTE", |
| 51 | DOUBLE: "DOUBLE", |
| 52 | I16: "I16", |
| 53 | I32: "I32", |
| 54 | I64: "I64", |
| 55 | STRING: "STRING", |
| 56 | STRUCT: "STRUCT", |
| 57 | MAP: "MAP", |
| 58 | SET: "SET", |
| 59 | LIST: "LIST", |
| 60 | UTF8: "UTF8", |
| 61 | UTF16: "UTF16", |
| 62 | } |
| 63 | |
| 64 | func (p TType) String() string { |
| 65 | if s, ok := typeNames[int(p)]; ok { |
| 66 | return s |
| 67 | } |
| 68 | return "Unknown" |
| 69 | } |