eRPC Generator (erpcgen)  Rev. 1.11.0
NXP Semiconductors
BuiltinType.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__BUILTINTYPE_H_
11 #define _EMBEDDED_RPC__BUILTINTYPE_H_
12 
13 #include "DataType.hpp"
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 
77  virtual bool isScalar() const override { return (isInt() || isFloat() || isBool()) && !(isString() || isBinary()); }
78 
85  virtual bool isInt() const override { return ((kInt8Type <= m_builtinType) && (m_builtinType <= kUInt64Type)); }
86 
93  virtual bool isFloat() const override { return ((m_builtinType == kFloatType) || (m_builtinType == kDoubleType)); }
94 
101  virtual bool isBool() const override { return m_builtinType == kBoolType; }
102 
109  virtual bool isString() const override
110  {
111  return ((m_builtinType == kStringType) || (m_builtinType == kUStringType));
112  }
113 
120  virtual bool isUString() const override { return m_builtinType == kUStringType; }
121 
128  virtual bool isBinary() const override { return m_builtinType == kBinaryType; }
129 
130 protected:
132 };
133 
134 } // namespace erpcgen
135 
136 #endif // _EMBEDDED_RPC__BUILTINTYPE_H_
virtual bool isUString() const override
This function return true/false value for identify ustring type.
Definition: BuiltinType.hpp:120
virtual bool isScalar() const override
This function return "true" value for identify scalar type.
Definition: BuiltinType.hpp:77
virtual bool isFloat() const override
This function return "true" value for identify float type.
Definition: BuiltinType.hpp:93
_builtin_type
Atomic builtin types.
Definition: BuiltinType.hpp:32
Represents the builtin atomic types.
Definition: BuiltinType.hpp:26
virtual bool isBinary() const override
This function return true/false value for identify binary type.
Definition: BuiltinType.hpp:128
virtual bool isInt() const override
This function return "true" value for identify int type.
Definition: BuiltinType.hpp:85
virtual bool isString() const override
This function return true/false value for identify string type.
Definition: BuiltinType.hpp:109
Base class for data types.
Definition: DataType.hpp:26
_builtin_type getBuiltinType() const
This function returns builtin type.
Definition: BuiltinType.hpp:69
virtual bool isBool() const override
This function return "true" value for identify bool type.
Definition: BuiltinType.hpp:101
BuiltinType(const std::string &name, _builtin_type builtinType)
Constructor.
Definition: BuiltinType.hpp:58
Definition: AstNode.hpp:26
_builtin_type m_builtinType
Definition: BuiltinType.hpp:131