eRPC Generator (erpcgen)  Rev. 1.9.0
NXP Semiconductors
BuiltinType.h
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__BUILTINTYPE_H_
11 #define _EMBEDDED_RPC__BUILTINTYPE_H_
12 
13 #include "DataType.h"
14 
15 #include <string>
16 
18 // Classes
20 
21 namespace erpcgen {
22 
26 class BuiltinType : public DataType
27 {
28 public:
33  {
34  kBoolType,
35  kInt8Type,
36  kInt16Type,
37  kInt32Type,
38  kInt64Type,
39  kUInt8Type,
40  kUInt16Type,
41  kUInt32Type,
42  kUInt64Type,
43  kFloatType,
44  kDoubleType,
45  kStringType,
46  kUStringType,
47  kBinaryType
48  };
49 
58  BuiltinType(const std::string &name, _builtin_type builtinType)
59  : DataType(name, kBuiltinType)
60  , m_builtinType(builtinType)
61  {
62  }
63 
70 
76  virtual bool isBuiltin() const { return true; }
77 
84  virtual bool isScalar() const { return (isInt() || isFloat() || isBool()) && !(isString() || isBinary()); }
85 
92  virtual bool isInt() const { return kInt8Type <= m_builtinType && m_builtinType <= kUInt64Type; }
93 
100  virtual bool isFloat() const { return m_builtinType == kFloatType || m_builtinType == kDoubleType; }
101 
108  virtual bool isBool() const { return m_builtinType == kBoolType; }
109 
116  virtual bool isString() const { return m_builtinType == kStringType || m_builtinType == kUStringType; }
117 
124  virtual bool isUString() const { return m_builtinType == kUStringType; }
125 
132  virtual bool isBinary() const { return m_builtinType == kBinaryType; }
133 
134 protected:
136 };
137 
138 } // namespace erpcgen
139 
140 #endif // _EMBEDDED_RPC__BUILTINTYPE_H_
_builtin_type
Atomic builtin types.
Definition: BuiltinType.h:32
virtual bool isScalar() const
This function return "true" value for identify scalar type.
Definition: BuiltinType.h:84
Represents the builtin atomic types.
Definition: BuiltinType.h:26
virtual bool isUString() const
This function return true/false value for identify ustring type.
Definition: BuiltinType.h:124
virtual bool isString() const
This function return true/false value for identify string type.
Definition: BuiltinType.h:116
virtual bool isFloat() const
This function return "true" value for identify float type.
Definition: BuiltinType.h:100
virtual bool isBuiltin() const
This function return "true" value for identify builtin type.
Definition: BuiltinType.h:76
Base class for data types.
Definition: DataType.h:26
virtual bool isBool() const
This function return "true" value for identify bool type.
Definition: BuiltinType.h:108
_builtin_type getBuiltinType() const
This function returns builtin type.
Definition: BuiltinType.h:69
virtual bool isInt() const
This function return "true" value for identify int type.
Definition: BuiltinType.h:92
virtual bool isBinary() const
This function return true/false value for identify binary type.
Definition: BuiltinType.h:132
BuiltinType(const std::string &name, _builtin_type builtinType)
Constructor.
Definition: BuiltinType.h:58
Definition: AstNode.h:26
_builtin_type m_builtinType
Definition: BuiltinType.h:135