eRPC Generator (erpcgen)  Rev. 1.7.0
NXP Semiconductors
BuiltinType.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__BUILTINTYPE_H_
37 #define _EMBEDDED_RPC__BUILTINTYPE_H_
38 
39 #include "DataType.h"
40 #include <string>
41 
43 // Classes
45 
46 namespace erpcgen {
47 
51 class BuiltinType : public DataType
52 {
53 public:
58  {
59  kBoolType,
60  kInt8Type,
61  kInt16Type,
62  kInt32Type,
63  kInt64Type,
64  kUInt8Type,
65  kUInt16Type,
66  kUInt32Type,
67  kUInt64Type,
68  kFloatType,
69  kDoubleType,
70  kStringType,
71  kBinaryType
72  };
73 
82  BuiltinType(const std::string &name, _builtin_type builtinType)
83  : DataType(name, kBuiltinType)
84  , m_builtinType(builtinType)
85  {
86  }
87 
94 
100  virtual bool isBuiltin() const { return true; }
101 
108  virtual bool isScalar() const { return (isInt() || isFloat() || isBool()) && !(isString() || isBinary()); }
109 
116  virtual bool isInt() const { return kInt8Type <= m_builtinType && m_builtinType <= kUInt64Type; }
117 
124  virtual bool isFloat() const { return m_builtinType == kFloatType || m_builtinType == kDoubleType; }
125 
132  virtual bool isBool() const { return m_builtinType == kBoolType; }
133 
140  virtual bool isString() const { return m_builtinType == kStringType; }
141 
148  virtual bool isBinary() const { return m_builtinType == kBinaryType; }
149 
150 protected:
152 };
153 
154 } // namespace erpcgen
155 
156 #endif // _EMBEDDED_RPC__BUILTINTYPE_H_
_builtin_type
Atomic builtin types.
Definition: BuiltinType.h:57
virtual bool isScalar() const
This function return "true" value for identify scalar type.
Definition: BuiltinType.h:108
Represents the builtin atomic types.
Definition: BuiltinType.h:51
virtual bool isString() const
This function return true/false value for identify string type.
Definition: BuiltinType.h:140
virtual bool isFloat() const
This function return "true" value for identify float type.
Definition: BuiltinType.h:124
virtual bool isBuiltin() const
This function return "true" value for identify builtin type.
Definition: BuiltinType.h:100
Base class for data types.
Definition: DataType.h:51
virtual bool isBool() const
This function return "true" value for identify bool type.
Definition: BuiltinType.h:132
_builtin_type getBuiltinType() const
This function returns builtin type.
Definition: BuiltinType.h:93
virtual bool isInt() const
This function return "true" value for identify int type.
Definition: BuiltinType.h:116
virtual bool isBinary() const
This function return true/false value for identify binary type.
Definition: BuiltinType.h:148
BuiltinType(const std::string &name, _builtin_type builtinType)
Constructor.
Definition: BuiltinType.h:82
Definition: AstNode.h:51
_builtin_type m_builtinType
Definition: BuiltinType.h:151