20#include "../symdef.hpp"
21#include "../ui/error.hpp"
22#include "../../kernel.hpp"
36 std::string sIncludeFileName;
38 if (sIncludingString.front() ==
'@' && sIncludingString[1] !=
' ')
43 if (sIncludingString[1] ==
'"')
44 sIncludeFileName = sIncludingString.substr(2, sIncludingString.find(
'"', 2)-2);
46 sIncludeFileName = sIncludingString.substr(1, sIncludingString.find(
' ')-1);
51 if (sIncludingString.find(
':', offset) != std::string::npos)
53 if (sIncludingString.find(
"defines", sIncludingString.find(
':', offset)+1) != std::string::npos)
55 else if (sIncludingString.find(
"globals", sIncludingString.find(
':', offset)+1) != std::string::npos)
57 else if (sIncludingString.find(
"declarations", sIncludingString.find(
':', offset)+1) != std::string::npos)
62 if (sIncludeFileName.find(
':') != std::string::npos)
64 for (
int __i = sIncludeFileName.length()-1; __i >= 0; __i--)
66 if (sIncludeFileName[__i] ==
':'
68 || (__i == 1 && sIncludeFileName.length() > (
unsigned int)__i+1 && sIncludeFileName[__i+1] !=
'/')))
70 sIncludeFileName.erase(__i);
77 if (sIncludeFileName.length())
82 else if (_mMatch.
sString ==
"include")
84 sIncludeFileName = sIncludingString.substr(_mMatch.
nPos+1+_mMatch.
sString.length());
87 if (sIncludeFileName.find(
"::") != std::string::npos)
88 sIncludeFileName.erase(sIncludeFileName.find(
"::"));
92 if (sIncludeFileName.front() ==
'"')
93 sIncludeFileName = sIncludeFileName.substr(1, sIncludeFileName.find(
'"', 1)-1);
95 size_t offset = _mMatch.
nPos+1+_mMatch.
sString.length()+3;
98 if (sIncludingString.find(
"::", offset) != std::string::npos)
100 if (sIncludingString.find(
"defines", sIncludingString.find(
"::", offset)+1) != std::string::npos)
102 else if (sIncludingString.find(
"globals", sIncludingString.find(
"::", offset)+1) != std::string::npos)
104 else if (sIncludingString.find(
"declarations", sIncludingString.find(
"::", offset)+1) != std::string::npos)
109 if (sIncludeFileName.length())
137Includer::Includer(
const std::string& sIncludingString,
const std::string& sSearchPath) : m_include(nullptr), nIncludeLine(-1), m_type(
Includer::INCLUDE_ALL)
141 if (sIncludingString.front() ==
'@')
173 std::string sIncludedLine;
177 while (nIncludeLine < m_include->getLinesCount() && !sIncludedLine.length())
179 std::string sCurrentLine;
188 if (sIncludedLine.length() > 2 && sIncludedLine.substr(sIncludedLine.length()-2) ==
"\\\\")
189 sIncludedLine.erase(sIncludedLine.length()-2);
191 sIncludedLine += sCurrentLine;
193 while (nIncludeLine < m_include->getLinesCount()
194 && sIncludedLine.length() > 2
195 && sIncludedLine.substr(sIncludedLine.length()-2) ==
"\\\\");
198 if (!sIncludedLine.length())
202 if (sIncludedLine.substr(0,9) ==
"<install>"
203 || (
findCommand(sIncludedLine).sString ==
"global" && sIncludedLine.find(
"<install>") != std::string::npos))
205 while (nIncludeLine < m_include->getLinesCount())
211 if (sIncludedLine.substr(0,12) ==
"<endinstall>"
212 || (
findCommand(sIncludedLine).sString ==
"global" && sIncludedLine.find(
"<endinstall>") != std::string::npos))
216 sIncludedLine.clear();
224 if (_mMatch.
sString !=
"define"
226 && _mMatch.
sString !=
"ifndefined"
227 && _mMatch.
sString !=
"redefine"
229 && _mMatch.
sString !=
"lclfunc"
233 sIncludedLine.clear();
242 && (_mMatch.
sString ==
"define"
244 || _mMatch.
sString ==
"ifndefined"
245 || _mMatch.
sString ==
"redefine"
247 || _mMatch.
sString ==
"lclfunc"))
249 sIncludedLine.clear();
253 && _mMatch.
sString ==
"global")
255 sIncludedLine.clear();
261 sIncludedLine.clear();
274 return sIncludedLine;
320 if (sLine.length() > 1 && sLine.front() ==
'@' && sLine[1] !=
' ')
std::string getProgramPath() const
void initializeFromKernel()
Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up...
std::string getPath() const
Returns the default path of this FileSystem instance.
std::string ValidFileName(std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
This member function evaluates, whether the passed filename is a valid filename. One may supply a pre...
int setPath(std::string _sPath, bool bMkDir, std::string _sExePath)
This member function may be used to set the preferred file path of the current FileSystem instance.
This class represents a file, which can be included into other files using the @ syntax.
std::string getIncludedFileName() const
Returns the embedded file name.
Includer(const std::string &sIncludingString, const std::string &sSearchPath)
Includer class constructor. Opens the included file defined by the passed including string.
void openIncludedFile(const std::string &sIncludingString)
Opens the included file and determines the including type.
~Includer()
Includer class destructor. Frees up internal memory if needed.
bool is_open() const
Determine, if the internal included file is open and valid.
StyledTextFile * m_include
static bool is_including_syntax(const std::string &sLine)
Static member function which determines, whether the passed line is actually a including syntax.
std::string getNextLine()
Return the next line of the included string.
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
static void issueWarning(std::string sWarningMessage)
This static function may be used to issue a warning to the user. The warning will be printed by the t...
This class represents a text file in memory (e.g. a code file). This class will try to lex the loaded...
int getLastPosition() const
Returns the last printable character position in the currently loaded file.
std::string getStrippedLine(size_t line) const
Returns the selected line (without the line termination characters and without any comments).
int getLinesCount() const
Returns the number of lines in the current loaded file.
std::string getFileName() const
Returns the filename of the respresented file in memory.
Common exception class for all exceptions thrown in NumeRe.
static size_t invalid_position
void StripSpaces(std::string &)
Removes leading and trailing white spaces and tabulator characters.
Structure for the findCommand function.