NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
stringvarfactory.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2019 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#ifndef STRINGVARFACTORY_HPP
20#define STRINGVARFACTORY_HPP
21
22#include <string>
23#include <map>
24#include <vector>
26
27namespace NumeRe
28{
34 {
35 private:
36 std::map<std::string,StringVector> m_mStringVectorVars;
37 std::map<std::string,StringVector> m_mTempStringVectorVars;
38 std::map<std::string,std::string> m_mStringVars;
39
40 bool isNumericCandidate(const std::string& sComponent);
41 bool checkStringvarDelimiter(const std::string& sToken) const;
42 void replaceStringVectorVars(std::map<std::string,StringVector>& mVectorVarMap, std::string& currentline, size_t nCurrentComponent, bool& bHasComponents);
43 std::string findVectorInMap(const std::map<std::string,StringVector>& mVectorVarMap, const std::vector<std::string>& vStringVector);
44
45 protected:
46 StringVector evaluateStringVectors(std::string sLine);
47 StringVector expandStringVectorComponents(std::vector<StringVector>& vStringVector);
49 std::string createStringVectorVar(const std::vector<std::string>& vStringVector);
50 bool isStringVectorVar(const std::string& sVarName) const;
51 const StringVector& getStringVectorVar(const std::string& sVarName) const;
52 void getStringValuesAsInternalVar(std::string& sLine, unsigned int nPos = 0);
53
54 public:
55 bool containsStringVectorVars(const std::string& sLine);
56 std::string createTempStringVectorVar(const std::vector<std::string>& vStringVector);
58 bool containsStringVars(const std::string& sLine) const;
59 bool isStringVar(const std::string& sVarName) const;
60 void getStringValues(std::string& sLine);
61 std::string getStringValue(const std::string& sVar) const;
62 void setStringValue(const std::string& sVar, const std::string& sValue);
63 void removeStringVar(const std::string& sVar);
64
65 // Returns a reference to the internal string variable map
66 inline const std::map<std::string, std::string>& getStringVars() const
67 {
68 return m_mStringVars;
69 }
70 };
71}
72
73
74#endif // STRINGVARFACTORY_HPP
75
This class handles the creation and deletion of string vector variables.
std::map< std::string, StringVector > m_mTempStringVectorVars
StringVector evaluateStringVectors(std::string sLine)
This member function evaluates the passed string vector and returns it's evaluated components in sepa...
const StringVector & getStringVectorVar(const std::string &sVarName) const
Return a reference to the identified string vector variable or throw if it does not exist.
bool containsStringVars(const std::string &sLine) const
This public member function determines, whether the passed string line contains string variables as p...
void removeStringVectorVars()
This member function removes all internal string vector variables.
std::map< std::string, StringVector > m_mStringVectorVars
bool isStringVectorVar(const std::string &sVarName) const
Check, whether the passed string identifies a string vector variable.
bool isStringVar(const std::string &sVarName) const
Determine, whether the passed string is the identifier of a string variable.
bool checkStringvarDelimiter(const std::string &sToken) const
This private member function examines the first and the last character of the passed string and deter...
std::map< std::string, std::string > m_mStringVars
StringVector expandStringVectorComponents(std::vector< StringVector > &vStringVector)
This member function expands the internal multi-expressions in the veector into separate components b...
bool containsStringVectorVars(const std::string &sLine)
This member function determines, whether there are string vector variables in the passed command line...
void setStringValue(const std::string &sVar, const std::string &sValue)
This public member function creates or updates a string variable and fills it with the passed value.
void replaceStringVectorVars(std::map< std::string, StringVector > &mVectorVarMap, std::string &currentline, size_t nCurrentComponent, bool &bHasComponents)
Replaces all found vectors of the passed map with their nCurrentComponent component.
std::string findVectorInMap(const std::map< std::string, StringVector > &mVectorVarMap, const std::vector< std::string > &vStringVector)
Searches for the passed string in the passed map and returns the key string from the map,...
void getStringValues(std::string &sLine)
This public member function resolves all string variable occurences and replaces them with their valu...
std::string createStringVectorVar(const std::vector< std::string > &vStringVector)
This member function is used to create a string vector variable.
void removeTempStringVectorVars()
This member function removes all temporary string vector variables.
std::string createTempStringVectorVar(const std::vector< std::string > &vStringVector)
This member function is used to create a temporary string vector variable.
bool isNumericCandidate(const std::string &sComponent)
This member function is used to determine, whether a string vector component is numerical parsable.
std::string getStringValue(const std::string &sVar) const
Returns the value of the selected string variable.
const std::map< std::string, std::string > & getStringVars() const
void removeStringVar(const std::string &sVar)
This public member function removes the selected string variable from memory.
void getStringValuesAsInternalVar(std::string &sLine, unsigned int nPos=0)
This public member function resolves all string variable occurences and replaces them with an interna...
This class is an extension to the std::vector<std::string> to provide the vector-like functionalities...