| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

- File List

SymbolScope.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__SYMBOLSCOPE_H_
11 #define _EMBEDDED_RPC__SYMBOLSCOPE_H_
12
13 #include "Symbol.h"
14
15 #include <map>
16 #include <string>
17 #include <vector>
18
20 // Classes
22
23 namespace erpcgen {
24
28 class SymbolScope
29 {
30 public:
31 typedef std::map<std::string, Symbol *> symbol_map_t;
32 typedef std::vector<Symbol *> symbol_vector_t;
34 class typed_iterator
35 {
36 public:
37 typedef symbol_vector_t::iterator vit;
38 typedef vit::value_type value_type;
39
40 operator value_type &() { return *m_vec; }
41 value_type &operator*() { return *m_vec; }
42 value_type &operator->() { return *m_vec; }
43
47 typed_iterator &operator++();
48
49 bool operator==(const typed_iterator &other) { return (m_vec == other.m_vec); }
50 bool operator!=(const typed_iterator &other) { return !(*this == other); }
51
52 private:
53 symbol_vector_t::iterator m_vec;
54 symbol_vector_t::iterator m_endvec;
55 Symbol::symbol_type_t m_predicateType;
56
64 typed_iterator(const vit &bv, const vit &ev, Symbol::symbol_type_t predicateType);
65
66 friend class SymbolScope;
67 };
68
72 SymbolScope()
73 : m_symbolMap()
74 , m_symbolVector()
75 , m_parent(nullptr)
76 {
77 }
78
82 virtual ~SymbolScope() {}
83
99 bool hasSymbol(const std::string &name, bool recursive = true);
100
116 Symbol *getSymbol(const std::string &name, bool recursive = true);
117
131 void addSymbol(Symbol *sym, int32_t pos = -1);
132
145 void replaceSymbol(Symbol *oldSym, Symbol *newSym);
146
159 int32_t getSymbolPos(Symbol *sym);
160
167 bool hasParent() const { return m_parent != nullptr; }
168
174 SymbolScope *getParent() { return m_parent; }
175
181 void setParent(SymbolScope *parent) { m_parent = parent; }
182
188 symbol_vector_t::iterator begin() { return m_symbolVector.begin(); }
189
195 symbol_vector_t::iterator end() { return m_symbolVector.end(); }
196
202 typed_iterator tbegin(Symbol::symbol_type_t predicateType);
203
209 typed_iterator tend(Symbol::symbol_type_t predicateType);
210
221 symbol_vector_t getSymbolsOfType(Symbol::symbol_type_t predicateType);
222
228 symbol_vector_t getSymbolVector() { return m_symbolVector; }
229
244 void dump();
245
249 void clear();
250
251 protected:
252 symbol_map_t m_symbolMap;
253 symbol_vector_t m_symbolVector;
254 SymbolScope *m_parent;
255 };
256
257 } // namespace erpcgen
258
259 #endif // _EMBEDDED_RPC__SYMBOLSCOPE_H_
erpcgen::SymbolScope::end
symbol_vector_t::iterator end()
Return end of symbol vector.
Definition: SymbolScope.h:195
erpcgen::SymbolScope::replaceSymbol
void replaceSymbol(Symbol *oldSym, Symbol *newSym)
This function will replace old symbol with new symbol in the symbol scope.
Definition: Type.cpp:225
erpcgen::SymbolScope::tend
typed_iterator tend(Symbol::symbol_type_t predicateType)
Definition: Type.cpp:147
erpcgen::SymbolScope::addSymbol
void addSymbol(Symbol *sym, int32_t pos=-1)
This function will add symbol to the symbol scope.
Definition: Type.cpp:192
erpcgen::SymbolScope::~SymbolScope
virtual ~SymbolScope()
Destructor.
Definition: SymbolScope.h:82
erpcgen::SymbolScope::getSymbol
Symbol * getSymbol(const std::string &name, bool recursive=true)
This function will return symbol.
Definition: Type.cpp:175
erpcgen::SymbolScope::hasParent
bool hasParent() const
Return boolean representation about existence of parent.
Definition: SymbolScope.h:167
erpcgen::SymbolScope::clear
void clear()
Erase data from m_symbolMap and m_symbolVector.
Definition: Type.cpp:263
erpcgen::Symbol
Base class for all named declarations in the IDL.
Definition: Symbol.h:28
erpcgen::SymbolScope::begin
symbol_vector_t::iterator begin()
Return begin of symbol vector.
Definition: SymbolScope.h:188
erpcgen::SymbolScope::m_symbolVector
symbol_vector_t m_symbolVector
Definition: SymbolScope.h:253
erpcgen::SymbolScope::setParent
void setParent(SymbolScope *parent)
This function set parent for this object.
Definition: SymbolScope.h:181
erpcgen::SymbolScope::SymbolScope
SymbolScope()
Constructor.
Definition: SymbolScope.h:72
erpcgen::SymbolScope::getSymbolsOfType
symbol_vector_t getSymbolsOfType(Symbol::symbol_type_t predicateType)
This function returns symbol vector with symbols.
Definition: Type.cpp:152
erpcgen::SymbolScope::tbegin
typed_iterator tbegin(Symbol::symbol_type_t predicateType)
Definition: Type.cpp:142
erpcgen::SymbolScope::hasSymbol
bool hasSymbol(const std::string &name, bool recursive=true)
This function returns true when name is found in symbol map.
Definition: Type.cpp:165
erpcgen::SymbolScope
A scoped namespace containing symbols.
Definition: SymbolScope.h:28
erpcgen::SymbolScope::symbol_vector_t
std::vector< Symbol * > symbol_vector_t
Definition: SymbolScope.h:32
erpcgen::SymbolScope::getParent
SymbolScope * getParent()
Return pointer to parent.
Definition: SymbolScope.h:174
erpcgen::SymbolScope::typed_iterator
Definition: SymbolScope.h:34
erpcgen::SymbolScope::getSymbolVector
symbol_vector_t getSymbolVector()
This function returns symbol vector.
Definition: SymbolScope.h:228
erpcgen::SymbolScope::m_symbolMap
symbol_map_t m_symbolMap
Definition: SymbolScope.h:252
erpcgen::SymbolScope::getSymbolPos
int32_t getSymbolPos(Symbol *sym)
This function will return symbol position.
Definition: Type.cpp:241
erpcgen::SymbolScope::dump
void dump()
This function show debug description about the all symbols.
Definition: Type.cpp:253
erpcgen::SymbolScope::m_parent
SymbolScope * m_parent
Definition: SymbolScope.h:254
erpcgen::Symbol::symbol_type_t
symbol_type_t
Supported symbol types.
Definition: Symbol.h:34
erpcgen
Definition: AstNode.h:26
erpcgen::SymbolScope::symbol_map_t
std::map< std::string, Symbol * > symbol_map_t
Definition: SymbolScope.h:31