eRPC Generator (erpcgen)  Rev. 1.9.0
NXP Semiconductors
Annotation.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__ANNOTATION_H_
11 #define _EMBEDDED_RPC__ANNOTATION_H_
12 
13 #include "AstNode.h"
14 #include "Token.h"
15 #include "Value.h"
16 
17 #include <string>
18 
20 // Classes
22 
23 namespace erpcgen {
24 
29 {
30 public:
31  enum program_lang_t
32  {
33  kAll,
34  kC,
35  kPython
36  };
37 
47  Annotation(const Token &token, Value *val, program_lang_t lang)
48  : m_name(token.getStringValue())
49  , m_value(val)
50  , m_location(token.getLocation())
51  , m_lang(lang)
52  {
53  }
54 
62  Annotation(const Token &token)
63  : m_name(token.getStringValue())
64  , m_value(nullptr)
65  , m_location(token.getLocation())
66  , m_lang(kAll)
67  {
68  }
69 
78  : m_name(a.m_name)
79  , m_value(a.m_value)
80  , m_location(a.m_location)
81  , m_lang(a.m_lang)
82  {
83  }
84 
90  std::string getName() const { return m_name; }
91 
97  bool hasValue() { return nullptr != m_value; }
98 
107 
113  program_lang_t getLang() const { return m_lang; }
114 
120  std::string toString() { return m_name + " = " + m_value->toString(); }
121 
127  token_loc_t &getLocation() { return m_location; }
128 
129 private:
130  std::string m_name;
131  Value *m_value;
132  token_loc_t m_location;
133  program_lang_t m_lang;
134 };
135 
136 } // namespace erpcgen
137 
138 #endif // _EMBEDDED_RPC__ANNOTATION_H_
Annotation(const Token &token, Value *val, program_lang_t lang)
Constructor.
Definition: Annotation.h:47
Annotation class.
Definition: Annotation.h:28
Annotation(const Annotation &a)
Constructor.
Definition: Annotation.h:77
std::string toString()
This function returns toString representation.
Definition: Annotation.h:120
virtual std::string toString() const =0
Get Value type string representation.
bool hasValue()
Checks to see if value instance member is null.
Definition: Annotation.h:97
Abstract base class for values of arbitrary types.
Definition: Value.h:27
program_lang_t getLang() const
This function returns programming language type for which is annotation intended. ...
Definition: Annotation.h:113
Encapsulates all information about a token.
Definition: Token.h:60
std::string getName() const
This function returns annotation name.
Definition: Annotation.h:90
token_loc_t & getLocation()
This function returns location for symbol.
Definition: Annotation.h:127
Token location in the source file.
Definition: Token.h:25
Annotation(const Token &token)
Constructor.
Definition: Annotation.h:62
Value * getValueObject()
This function returns annotation value.
Definition: Type.cpp:49
Definition: AstNode.h:26