]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/compiler/cpp/src/thrift/parse/t_typedef.h
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / compiler / cpp / src / thrift / parse / t_typedef.h
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 #ifndef T_TYPEDEF_H
21 #define T_TYPEDEF_H
22
23 #include <string>
24 #include "thrift/parse/t_type.h"
25
26 /**
27 * A typedef is a mapping from a symbolic name to another type. In dymanically
28 * typed languages (i.e. php/python) the code generator can actually usually
29 * ignore typedefs and just use the underlying type directly, though in C++
30 * the symbolic naming can be quite useful for code clarity.
31 *
32 */
33 class t_typedef : public t_type {
34 public:
35 t_typedef(t_program* program, t_type* type, const std::string& symbolic)
36 : t_type(program, symbolic), type_(type), symbolic_(symbolic), forward_(false) {}
37
38 /**
39 * This constructor is used to refer to a type that is lazily
40 * resolved at a later time, like for forward declarations or
41 * recursive types.
42 */
43 t_typedef(t_program* program, const std::string& symbolic, bool forward)
44 : t_type(program, symbolic),
45 type_(nullptr),
46 symbolic_(symbolic),
47 forward_(forward)
48 {}
49
50 ~t_typedef() override = default;
51
52 t_type* get_type();
53
54 const t_type* get_type() const;
55
56 const std::string& get_symbolic() const { return symbolic_; }
57
58 bool is_forward_typedef() const { return forward_; }
59
60 bool is_typedef() const override { return true; }
61
62 private:
63 t_type* type_;
64 std::string symbolic_;
65 bool forward_;
66 };
67
68 #endif