eRPC Generator (erpcgen)  Rev. 1.11.0
NXP Semiconductors
DataType.hpp
1 /*
2  * Copyright (c) 2014, Freescale Semiconductor, Inc.
3  * Copyright 2016 NXP
4  * All rights reserved.
5  *
6  *
7  * SPDX-License-Identifier: BSD-3-Clause
8  */
9 
10 #ifndef _EMBEDDED_RPC__DATATYPE_H_
11 #define _EMBEDDED_RPC__DATATYPE_H_
12 
13 #include "Symbol.hpp"
14 
15 #include <string>
16 
18 // Classes
20 
21 namespace erpcgen {
22 
26 class DataType : public Symbol
27 {
28 public:
33  {
34  kAliasType,
35  kArrayType,
36  kBuiltinType,
37  kEnumType,
38  kFunctionType,
39  kListType,
40  kStructType,
41  kUnionType,
42  kVoidType
43  };
44 
52  explicit DataType(data_type_t dataType)
53  : Symbol(kTypenameSymbol)
54  , m_dataType(dataType)
55  {
56  }
57 
66  DataType(const std::string &name, data_type_t dataType)
67  : Symbol(kTypenameSymbol, name)
68  , m_dataType(dataType)
69  {
70  }
80  DataType(const Token &tok, data_type_t dataType)
81  : Symbol(kTypenameSymbol, tok)
82  , m_dataType(dataType)
83  {
84  }
85 
91  data_type_t getDataType() const { return m_dataType; }
92 
101 
111 
118  bool isAlias() const { return (m_dataType == kAliasType); }
119 
126  bool isArray() const { return (m_dataType == kArrayType); }
127 
133  virtual bool isBinary() const { return false; }
134 
140  virtual bool isBool() const { return false; }
141 
148  bool isBuiltin() const { return (m_dataType == kBuiltinType); }
149 
156  bool isEnum() const { return (m_dataType == kEnumType); }
157 
164  bool isFunction() const { return (m_dataType == kFunctionType); }
165 
172  bool isList() const { return (m_dataType == kListType); }
173 
179  virtual bool isScalar() const { return false; }
180 
186  virtual bool isInt() const { return false; }
187 
193  virtual bool isFloat() const { return false; }
194 
200  virtual bool isString() const { return false; }
201 
207  virtual bool isUString() const { return false; }
208 
215  bool isStruct() const { return (m_dataType == kStructType); }
216 
223  bool isUnion() const { return (m_dataType == kUnionType); }
224 
231  bool isVoid() const { return (m_dataType == kVoidType); }
232 
233 protected:
235 };
236 
237 } // namespace erpcgen
238 
239 #endif // _EMBEDDED_RPC__DATATYPE_H_
DataType(data_type_t dataType)
Constructor.
Definition: DataType.hpp:52
DataType(const Token &tok, data_type_t dataType)
Constructor.
Definition: DataType.hpp:80
bool isBuiltin() const
This function is testing data type.
Definition: DataType.hpp:148
virtual bool isBool() const
This function return "false" value as default for identify bool type.
Definition: DataType.hpp:140
virtual bool isString() const
This function return "false" value as default for identify string type.
Definition: DataType.hpp:200
Base class for all named declarations in the IDL.
Definition: Symbol.hpp:28
bool isVoid() const
This function is testing data type.
Definition: DataType.hpp:231
virtual bool isScalar() const
This function return "false" value as default for identify scalar builtin type.
Definition: DataType.hpp:179
DataType * getTrueContainerDataType()
This function returns pointer to true data type (enum, builtin, structs) except lists and arrays...
Definition: Type.cpp:475
bool isList() const
This function is testing data type.
Definition: DataType.hpp:172
DataType * getTrueDataType()
This function returns pointer to true data type instead of alias.
Definition: Type.cpp:461
bool isFunction() const
This function is testing data type.
Definition: DataType.hpp:164
virtual bool isInt() const
This function return "true" value for identify int type.
Definition: DataType.hpp:186
data_type_t getDataType() const
This function returns data type.
Definition: DataType.hpp:91
virtual bool isFloat() const
This function return "true" value for identify float type.
Definition: DataType.hpp:193
virtual bool isBinary() const
This function return "false" value as default for identify binary type.
Definition: DataType.hpp:133
Base class for data types.
Definition: DataType.hpp:26
Encapsulates all information about a token.
Definition: Token.hpp:60
data_type_t
Supported data types.
Definition: DataType.hpp:32
bool isUnion() const
This function is testing data type.
Definition: DataType.hpp:223
bool isAlias() const
This function is testing data type.
Definition: DataType.hpp:118
bool isEnum() const
This function is testing data type.
Definition: DataType.hpp:156
bool isStruct() const
This function is testing data type.
Definition: DataType.hpp:215
DataType(const std::string &name, data_type_t dataType)
Constructor.
Definition: DataType.hpp:66
data_type_t m_dataType
Definition: DataType.hpp:234
virtual bool isUString() const
This function return "false" value as default for identify ustring type.
Definition: DataType.hpp:207
Definition: AstNode.hpp:26
bool isArray() const
This function is testing data type.
Definition: DataType.hpp:126