TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / external / android-emugl / host / tools / emugen / VarType.h
1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #ifndef __VARTYPE__H__
17 #define __VARTYPE__H__
18
19 #include <string>
20
21 // VarType models the types of values used on the wire protocol by
22 // both encoders and decoders. Each type is identified by a unique id,
23 // and a name, and provides a size in bytes for the values, a printf-like
24 // formatter string, and a flag telling if the value corresponds to a
25 // pointer.
26 class VarType {
27 public:
28     VarType() :
29             m_id(0),
30             m_name("default_constructed"),
31             m_byteSize(0),
32             m_printFormat("0x%x"),
33             m_isPointer(false) {}
34
35     VarType(size_t id,
36             const std::string& name,
37             size_t byteSize,
38             const std::string& printFormat,
39             bool isPointer) :
40             m_id(id),
41             m_name(name),
42             m_byteSize(byteSize),
43             m_printFormat(printFormat),
44             m_isPointer(isPointer) {}
45
46     ~VarType() {}
47
48     size_t id() const { return m_id; }
49     const std::string& name() const { return m_name; }
50     size_t bytes() const { return m_byteSize; }
51     const std::string& printFormat() const { return m_printFormat; }
52     bool isPointer() const { return m_isPointer; }
53
54 private:
55     size_t m_id;
56     std::string m_name;
57     size_t m_byteSize;
58     std::string m_printFormat;
59     bool m_isPointer;
60 };
61
62 #endif