eRPC Generator (erpcgen)  Rev. 1.7.2
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 #include <string>
15 
17 // Classes
19 
20 namespace erpcgen {
21 
25 class BuiltinType : public DataType
26 {
27 public:
32  {
33  kBoolType,
34  kInt8Type,
35  kInt16Type,
36  kInt32Type,
37  kInt64Type,
38  kUInt8Type,
39  kUInt16Type,
40  kUInt32Type,
41  kUInt64Type,
42  kFloatType,
43  kDoubleType,
44  kStringType,
45  kBinaryType
46  };
47 
56  BuiltinType(const std::string &name, _builtin_type builtinType)
57  : DataType(name, kBuiltinType)
58  , m_builtinType(builtinType)
59  {
60  }
61 
68 
74  virtual bool isBuiltin() const { return true; }
75 
82  virtual bool isScalar() const { return (isInt() || isFloat() || isBool()) && !(isString() || isBinary()); }
83 
90  virtual bool isInt() const { return kInt8Type <= m_builtinType && m_builtinType <= kUInt64Type; }
91 
98  virtual bool isFloat() const { return m_builtinType == kFloatType || m_builtinType == kDoubleType; }
99 
106  virtual bool isBool() const { return m_builtinType == kBoolType; }
107 
114  virtual bool isString() const { return m_builtinType == kStringType; }
115 
122  virtual bool isBinary() const { return m_builtinType == kBinaryType; }
123 
124 protected:
126 };
127 
128 } // namespace erpcgen
129 
130 #endif // _EMBEDDED_RPC__BUILTINTYPE_H_
_builtin_type
Atomic builtin types.
Definition: BuiltinType.h:31
virtual bool isScalar() const
This function return "true" value for identify scalar type.
Definition: BuiltinType.h:82
Represents the builtin atomic types.
Definition: BuiltinType.h:25
virtual bool isString() const
This function return true/false value for identify string type.
Definition: BuiltinType.h:114
virtual bool isFloat() const
This function return "true" value for identify float type.
Definition: BuiltinType.h:98
virtual bool isBuiltin() const
This function return "true" value for identify builtin type.
Definition: BuiltinType.h:74
Base class for data types.
Definition: DataType.h:25
virtual bool isBool() const
This function return "true" value for identify bool type.
Definition: BuiltinType.h:106
_builtin_type getBuiltinType() const
This function returns builtin type.
Definition: BuiltinType.h:67
virtual bool isInt() const
This function return "true" value for identify int type.
Definition: BuiltinType.h:90
virtual bool isBinary() const
This function return true/false value for identify binary type.
Definition: BuiltinType.h:122
BuiltinType(const std::string &name, _builtin_type builtinType)
Constructor.
Definition: BuiltinType.h:56
Definition: AstNode.h:25
_builtin_type m_builtinType
Definition: BuiltinType.h:125