eRPC Generator (erpcgen)  Rev. 1.7.0
NXP Semiconductors
DataType.h
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2014, Freescale Semiconductor, Inc.
4  * Copyright 2016 NXP
5  * All rights reserved.
6  *
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted (subject to the limitations in the disclaimer below) provided
10  * that the following conditions are met:
11  *
12  * o Redistributions of source code must retain the above copyright notice, this list
13  * of conditions and the following disclaimer.
14  *
15  * o Redistributions in binary form must reproduce the above copyright notice, this
16  * list of conditions and the following disclaimer in the documentation and/or
17  * other materials provided with the distribution.
18  *
19  * o Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from this
21  * software without specific prior written permission.
22  *
23  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef _EMBEDDED_RPC__DATATYPE_H_
37 #define _EMBEDDED_RPC__DATATYPE_H_
38 
39 #include "Symbol.h"
40 #include <string>
41 
43 // Classes
45 
46 namespace erpcgen {
47 
51 class DataType : public Symbol
52 {
53 public:
58  {
59  kAliasType,
60  kArrayType,
61  kBuiltinType,
62  kEnumType,
63  kFunctionType,
64  kListType,
65  kStructType,
66  kUnionType,
67  kVoidType
68  };
69 
77  DataType(_data_type dataType)
78  : Symbol(kTypenameSymbol)
79  , m_dataType(dataType)
80  {
81  }
82 
91  DataType(const std::string &name, _data_type dataType)
92  : Symbol(kTypenameSymbol, name)
93  , m_dataType(dataType)
94  {
95  }
96 
106  DataType(const std::string &name, _data_type dataType, symbol_type_t symbolType)
107  : Symbol(symbolType, name)
108  , m_dataType(dataType)
109  {
110  }
111 
121  DataType(const Token &tok, _data_type dataType, symbol_type_t symbolType)
122  : Symbol(symbolType, tok)
123  , m_dataType(dataType)
124  {
125  }
126 
132  _data_type getDataType() const { return m_dataType; }
133 
142 
152 
158  virtual bool isAlias() const { return false; }
159 
165  virtual bool isArray() const { return false; }
166 
172  virtual bool isBinary() const { return false; }
173 
179  virtual bool isBool() const { return false; }
180 
186  virtual bool isBuiltin() const { return false; }
187 
193  virtual bool isEnum() const { return false; }
194 
200  virtual bool isFunction() const { return false; }
201 
207  virtual bool isList() const { return false; }
208 
214  virtual bool isScalar() const { return false; }
215 
221  virtual bool isString() const { return false; }
222 
228  virtual bool isStruct() const { return false; }
229 
235  virtual bool isUnion() const { return false; }
236 
242  virtual bool isVoid() const { return false; }
243 
244 protected:
246 };
247 
248 } // namespace erpcgen
249 
250 #endif // _EMBEDDED_RPC__DATATYPE_H_
DataType(const std::string &name, _data_type dataType, symbol_type_t symbolType)
Constructor.
Definition: DataType.h:106
virtual bool isBool() const
This function return "false" value as default for identify bool type.
Definition: DataType.h:179
virtual bool isString() const
This function return "false" value as default for identify string type.
Definition: DataType.h:221
virtual bool isVoid() const
This function return "false" value as default for identify void type.
Definition: DataType.h:242
_data_type m_dataType
Definition: DataType.h:245
Base class for all named declarations in the IDL.
Definition: Symbol.h:53
virtual bool isScalar() const
This function return "false" value as default for identify scalar builtin type.
Definition: DataType.h:214
DataType * getTrueContainerDataType()
This function returns pointer to true data type (enum, builtin, structs) except lists and arrays...
Definition: Type.cpp:499
DataType * getTrueDataType()
This function returns pointer to true data type instead of alias.
Definition: Type.cpp:485
virtual bool isFunction() const
This function return "false" value as default for identify function type.
Definition: DataType.h:200
virtual bool isStruct() const
This function return "false" value as default for identify struct type.
Definition: DataType.h:228
virtual bool isBinary() const
This function return "false" value as default for identify binary type.
Definition: DataType.h:172
_data_type getDataType() const
This function returns data type.
Definition: DataType.h:132
Base class for data types.
Definition: DataType.h:51
Encapsulates all information about a token.
Definition: Token.h:86
DataType(_data_type dataType)
Constructor.
Definition: DataType.h:77
virtual bool isBuiltin() const
This function return "false" value as default for identify builtin type.
Definition: DataType.h:186
DataType(const std::string &name, _data_type dataType)
Constructor.
Definition: DataType.h:91
virtual bool isAlias() const
This function return "false" value as default for identify alias type.
Definition: DataType.h:158
_data_type
Supported data types.
Definition: DataType.h:57
virtual bool isEnum() const
This function return "false" value as default for identify enum type.
Definition: DataType.h:193
virtual bool isArray() const
This function return "false" value as default for identify array type.
Definition: DataType.h:165
virtual bool isList() const
This function return "false" value as default for identify list type.
Definition: DataType.h:207
virtual bool isUnion() const
This function return "false" value as default for identify union type.
Definition: DataType.h:235
symbol_type_t
Supported symbol types.
Definition: Symbol.h:59
Definition: AstNode.h:51
DataType(const Token &tok, _data_type dataType, symbol_type_t symbolType)
Constructor.
Definition: DataType.h:121