]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/compiler/cpp/src/thrift/parse/t_type.h
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
27 #include "thrift/parse/t_doc.h"
32 * Generic representation of a thrift type. These objects are used by the
33 * parser module to build up a tree of object that are all explicitly typed.
34 * The generic t_type class exports a variety of useful methods that are
35 * used by the code generator to branch based upon different handling for the
39 class t_type
: public t_doc
{
41 ~t_type() override
= default;
43 virtual void set_name(const std::string
& name
) { name_
= name
; }
45 virtual const std::string
& get_name() const { return name_
; }
47 virtual bool is_void() const { return false; }
48 virtual bool is_base_type() const { return false; }
49 virtual bool is_string() const { return false; }
50 virtual bool is_binary() const { return false; }
51 virtual bool is_bool() const { return false; }
52 virtual bool is_typedef() const { return false; }
53 virtual bool is_enum() const { return false; }
54 virtual bool is_struct() const { return false; }
55 virtual bool is_xception() const { return false; }
56 virtual bool is_container() const { return false; }
57 virtual bool is_list() const { return false; }
58 virtual bool is_set() const { return false; }
59 virtual bool is_map() const { return false; }
60 virtual bool is_service() const { return false; }
62 t_program
* get_program() { return program_
; }
64 const t_program
* get_program() const { return program_
; }
66 t_type
* get_true_type();
67 const t_type
* get_true_type() const;
69 // This function will break (maybe badly) unless 0 <= num <= 16.
70 static char nybble_to_xdigit(int num
) {
74 return 'A' + num
- 10;
78 static std::string
byte_to_hex(uint8_t byte
) {
80 rv
+= nybble_to_xdigit(byte
>> 4);
81 rv
+= nybble_to_xdigit(byte
& 0x0f);
85 std::map
<std::string
, std::string
> annotations_
;
88 t_type() : program_(nullptr) { ; }
90 t_type(t_program
* program
) : program_(program
) { ; }
92 t_type(t_program
* program
, std::string name
) : program_(program
), name_(name
) { ; }
94 t_type(std::string name
) : program_(nullptr), name_(name
) { ; }
101 * Placeholder struct for returning the key and value of an annotation
104 struct t_annotation
{