GemaLib
The GeMA library
gmSharedCodeLoader.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
24 #ifndef _GEMA_SHARED_CODE_LOADER_H_
25 #define _GEMA_SHARED_CODE_LOADER_H_
26 
27 class GmLogCategory;
28 class GmSimulationData;
29 
30 class LuaTable;
31 class QString;
33 
34 #include <QVector>
35 
38 {
39 public:
40  GmSharedCodeLoader(const GmLogCategory& logger, GmSimulationData* simData,
41  const QStringList& pluginDataAliases);
43 
44  bool load(LuaTable& sharedCodeData);
45 
46 private:
47  bool loadFileCode(QString fileName, const QVector<QPair<int, int> >& blockList, QString& code);
48 
49  QString removePrefix (QString line, bool isImplicit) const;
50  int findParPos (QString line, bool isImplicit) const;
51  QString removeComments(QString line) const;
53 
57 };
58 
59 #endif
60 
Auxiliary class responsible for loading shared code information from a Lua table.
Definition: gmSharedCodeLoader.h:37
bool loadFileCode(QString fileName, const QVector< QPair< int, int > > &blockList, QString &code)
Loads shared blocks / function definitions from the given file, appending the data to code....
Definition: gmSharedCodeLoader.cpp:213
const GmLogCategory & _logger
Reference to the logger object used to emmit messages.
Definition: gmSharedCodeLoader.h:54
QStringList readParameter(GmSharedCodeLoaderReadBuffer &b, QString line) const
Reads and returns the text for a function parameter list, either enclosed in () or {},...
Definition: gmSharedCodeLoader.cpp:360
GmSharedCodeLoader(const GmLogCategory &logger, GmSimulationData *simData, const QStringList &pluginDataAliases)
Constructor. Receives as a parameters the logger object that will be used to emmit messages,...
Definition: gmSharedCodeLoader.cpp:131
QString removeComments(QString line) const
Remove comments from the line. Only handles line comments (– ones), not block comments.
Definition: gmSharedCodeLoader.cpp:327
QStringList _implicitBlockNames
The list with names that implicitely start a shared block.
Definition: gmSharedCodeLoader.h:56
int findParPos(QString line, bool isImplicit) const
Finds the position in string where the SharedCodeEnd/NodeFunction/CellFunction/pluginObject tag ends ...
Definition: gmSharedCodeLoader.cpp:299
bool load(LuaTable &sharedCodeData)
Loads shared code block data from the Lua table received as a parameter.
Definition: gmSharedCodeLoader.cpp:163
GmSimulationData * _simData
Simulation data object.
Definition: gmSharedCodeLoader.h:55
An auxiliar class to implement a simple form of look ahead while reading file data.
Definition: gmSharedCodeLoader.cpp:43
QString removePrefix(QString line, bool isImplicit) const
Removes data from the line before the block start.
Definition: gmSharedCodeLoader.cpp:275
~GmSharedCodeLoader()
Destructor.
Definition: gmSharedCodeLoader.cpp:145