eRPC Generator (erpcgen)  Rev. 1.7.2
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 #include <string>
17 
19 // Classes
21 
22 namespace erpcgen {
23 
28 {
29 public:
30  enum program_lang_t
31  {
32  kAll,
33  kC,
34  kPython
35  };
36 
46  Annotation(const Token &token, Value *val, program_lang_t lang)
47  : m_name(token.getStringValue())
48  , m_value(val)
49  , m_location(token.getLocation())
50  , m_lang(lang)
51  {
52  }
53 
61  Annotation(const Token &token)
62  : m_name(token.getStringValue())
63  , m_value(nullptr)
64  , m_location(token.getLocation())
65  , m_lang(kAll)
66  {
67  }
68 
77  : m_name(a.m_name)
78  , m_value(a.m_value)
79  , m_location(a.m_location)
80  , m_lang(a.m_lang)
81  {
82  }
83 
89  std::string getName() const { return m_name; }
90 
96  bool hasValue() { return nullptr != m_value; }
97 
106 
112  program_lang_t getLang() const { return m_lang; }
113 
119  std::string toString() { return m_name + " = " + m_value->toString(); }
120 
126  token_loc_t &getLocation() { return m_location; }
127 
128 private:
129  std::string m_name;
130  Value *m_value;
131  token_loc_t m_location;
132  program_lang_t m_lang;
133 };
134 
135 } // namespace erpcgen
136 
137 #endif // _EMBEDDED_RPC__ANNOTATION_H_
Annotation(const Token &token, Value *val, program_lang_t lang)
Constructor.
Definition: Annotation.h:46
Annotation class.
Definition: Annotation.h:27
Annotation(const Annotation &a)
Constructor.
Definition: Annotation.h:76
std::string toString()
This function returns toString representation.
Definition: Annotation.h:119
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:96
Abstract base class for values of arbitrary types.
Definition: Value.h:21
program_lang_t getLang() const
This function returns programming language type for which is annotation intended. ...
Definition: Annotation.h:112
Encapsulates all information about a token.
Definition: Token.h:60
std::string getName() const
This function returns annotation name.
Definition: Annotation.h:89
token_loc_t & getLocation()
This function returns location for symbol.
Definition: Annotation.h:126
Token location in the source file.
Definition: Token.h:25
Annotation(const Token &token)
Constructor.
Definition: Annotation.h:61
Value * getValueObject()
This function returns annotation value.
Definition: Type.cpp:48
Definition: AstNode.h:25