Blame view

src/InternLib/Parser.hh 4.24 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
 * Parser.hh
 *
 *  Created on: Dec 11, 2012
 *      Author: AKKA IS
 */

#ifndef PARSER_HH_
#define PARSER_HH_
#include <string>
#include <set>
#include <vector>
#include <map>

namespace AMDA {
namespace Parameters {
/**
 * @brief parser ofclassic  process  expression
 */
class Parser {
	/**
	 * @brief List of attributes
	 */
	typedef  std::vector<std::string> AttributList;

	/**
	 * @brief Information of a process
	 */
	struct ProcessInfo {
		/**
		 * default constructor
		 */
		ProcessInfo() {}
		/**
		 * constructor by parameter
		 */
		ProcessInfo(std::string pName, std::string pExpression, AttributList pAttribut) : name(pName), expression(pExpression), attribut(pAttribut) {}

		/**
		 * @brief Process name
		 */
		std::string name;

		/**
		 * @brief Process expression
		 */
		std::string expression;

		/**
		 * @brief Process attributes list
		 */
		AttributList attribut;
	};

public:
	/**
	 * @brief List of parameter name
	 */
	typedef std::set<std::string>  ListParameterName ;

	/**
	 * @brief List of parameter name
	 */
	typedef std::set<std::string>  ListFctName ;

	/**
	 * @brief List of for key name a ProcessInfo
	 */
	typedef std::map<std::string, ProcessInfo>  ListProcessName ;

	/**
	 * @brief Default constructor
	 */
	Parser();

	/**
	 * destructor
	 */
	virtual ~Parser();

	/**
	 * @brief _formulaCC getter
	 */
	const std::string& getFormulaCc() const {
		return _formulaCC;
	}

	/**
	 * @brief _constructorCC getter
	 */
	const std::string& getContructorCc() const {
		return _constructorCC;
	}

	const ListParameterName& getListParameterName() const {
		return _listParameterName;
	}

	/**
	 * @brief _listProcessName getter
	 */
	const ListProcessName& getListProcessName() const {
		return _listProcessName;
	}

	/**
	 * @brief _listFctName getter
	 */
	const ListFctName& getListFctName() const {
		return _listFctName;
	}

	/**
	 * @brief Parse process start
	 * @param expression expression to parse
	 * @details state algorithm used
	 *  read expression by one character after character.
	 */
	void process(std::string expression);

	/**
	 * @brief  Search SemiColon with parenthesis counter.
	 */
	static size_t searchSemiColon(const char* expression);

1ddc0f12   Benjamin Renard   Fix expression pa...
126
127
128
129
130
131
132
133
	bool isParamOnly() {
		return _paramOnly;
	}

	bool isProcessOnly() {
		return _processOnly;
	}

fbe3c2bb   Benjamin Renard   First commit
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
private:

	/**
	 * @brief Parse a parameter name
	 * @detail Search the first non alphanum character and store the paramName in _listParameterName
	 *  @param it iterator on current character
	 */
	void processParameterName(std::string::iterator &it);

	/**
	 * @brief Parse a process name
	 * @detail Search the first non alphanum character
	 *  and launch processProcessExpression()
	 *  then store the processName with attributes  in _listProcessName
	 *  @param it iterator on current character
	 */
	void processProcessName(std::string::iterator &it);

	/**
	 * @brief Parse a parameter expression
	 * @detail Search the last parenthesis   with interne parenthesis counter
	 *  and return attribut list and sub process expression string
	 *  @param it iterator on current character
	 *  @param attribut output attributes ist
	 *  @return intern process expression string
	 */
	std::string processProcessExpression(std::string::iterator &it, AttributList &attribut);

	/**
		 * @brief Parse a function name
		 * @detail Search the first open parenthesis character and store the function in _listFctName
	 *  @param it iterator on current character
		 */
	void processFctName(std::string::iterator &it);

	/**
	 * @brief  Search the first non alphanum character and return the string between it and non alphanum character
	 *  @param it iterator on current character
	 */
	std::string findAlphaNum_(std::string::iterator &it);

	/**
	 * @brief List of parameter name
	 */
	ListParameterName _listParameterName;

	/**
	 * @brief List of for key name a ProcessInfo
	 */
	ListProcessName _listProcessName;

	/**
	 * @brief List of parameter name
	 */
	ListFctName _listFctName;

	/**
	 * @brief expression to parse;
	 */
	std::string _expression;

	/**
	 *@brief  _formula string to put in CC file
	 */
	std::string _formulaCC;

	/**
	 * @brief _constructor string to put in CC file
	 */
	std::string _constructorCC;

1ddc0f12   Benjamin Renard   Fix expression pa...
205
	bool _paramOnly;
fbe3c2bb   Benjamin Renard   First commit
206

1ddc0f12   Benjamin Renard   Fix expression pa...
207
	bool _processOnly;
fbe3c2bb   Benjamin Renard   First commit
208
209
210
211
212
};

} /* namespace Parameters */
} /* namespace AMDA */
#endif /* PARSER_HH_ */