33 if (!
open(filename,
false))
34 std::cout <<
"Error while opening file: " << filename << std::endl;
53 position = paramString.find(searchString);
54 if (position == std::string::npos)
56 paramString.replace(position, searchString.length(),
replaceString);
61 const char paramIndicator =
'#';
62 const char commentIndicator =
'%';
76 if (stringBuffer[stringBuffer.length() - 1] == 13) {
77 stringBuffer.replace(stringBuffer.length() - 1, 1,
"");
80 lines_.push_back(stringBuffer );
87 std::vector<std::string>::iterator iter =
lines_.begin();
88 while (iter !=
lines_.end()) {
89 while ((*iter)[0] == commentIndicator && (*iter)[1] == commentIndicator)
92 if ((*iter)[0] == paramIndicator) {
93 std::vector<std::string>::iterator iter2 = iter;
98 while (iter2 !=
lines_.end()) {
99 if ((*iter2)[0] == paramIndicator && (*iter2)[1] == paramIndicator) {
107 std::vector<std::string>::iterator tmpIter = iter2;
111 if (!((*tmpIter)[0] == paramIndicator && (*tmpIter)[1] == paramIndicator))
119 if (iter2 ==
lines_.end())
124 lines_.erase(iter, iter2);
134 while (iter !=
lines_.end()) {
135 if ((*iter).empty() || (*iter).length() == 0 || (*iter) ==
" ")
147 std::vector<std::string>::iterator iter =
lines_.begin();
150 while (iter !=
lines_.end()) {
164 std::vector<std::string>::iterator iter =
lines_.begin();
165 while (iter !=
lines_.end()) {
179 std::vector<std::string>::iterator iter =
lines_.begin();
182 while (iter !=
lines_.end()) {
184 if ((*iter).find(atLine) != std::string::npos) {
186 iter =
lines_.erase(iter);
188 lines_.insert(iter, content.begin(), content.end());
215 std::vector<std::string>::const_iterator iter =
lines_.begin();
216 while (iter !=
lines_.end()) {
225 std::cout <<
"Enter parametermap" << std::endl;
227 std::map<std::string, std::string>::const_iterator iter =
parameterMap_.begin();
230 std::cout << (*iter).first <<
": " << (*iter).second << std::endl;
243 if (
int pos1 = str.find(
"$(") != std::string::npos && str.substr(0, 2) !=
"--") {
244 int pos2 = str.find(
')');
246 std::string tempStr = (str.substr(pos1 + 1, (pos2 - pos1 - 1)));
253 parameters.push_back(tempStr);
267 std::vector<std::string>
temp;
268 std::vector<std::string>::const_iterator iter =
lines_.begin();
271 while (iter !=
lines_.end()) {
282 for (
unsigned int i = 0;
i < file.
lines_.size();
i++) {
290 std::vector<std::string>::iterator iter =
lines_.begin();
291 while (iter !=
lines_.end()) {
293 position = (*iter).find(str);
295 if (position != std::string::npos) {
305 std::vector<std::string>::iterator iter =
lines_.begin();
307 while (iter !=
lines_.end()) {
308 if ((*iter).empty() || (*iter).length() == 0 || (*iter) ==
" ")
330 std::size_t pos = temp.find(
' ');
332 if (pos != std::string::npos) {
334 result.push_back(temp2);
338 }
else if (!
isBlank(temp[pos + 1])) {
339 result.push_back(temp);
348 std::vector<std::string> operators;
350 operators.push_back(
"AND");
351 operators.push_back(
"OR");
352 operators.push_back(
"NOT");
353 operators.push_back(
"(");
354 operators.push_back(
")");
356 for (
unsigned int i = 0;
i < operators.size();
i++) {
361 split(condString, result);
365 std::vector<std::string>::const_iterator iter =
lines_.begin();
366 std::ostringstream
buffer;
368 while (iter !=
lines_.end()) {
369 buffer << (*iter) << std::endl;
bool split(const std::string ¶m, std::vector< std::string > &result) const
seperates a string at all blanks and saves the elements in result
std::string lines2String() const
returns a string with the content of vector lines
bool extractParametersFromString(const std::string &str, std::vector< std::string > ¶meters) const
std::map< std::string, std::string > parameterMap_
containing the header information of internal files
static const bool findAndReplaceString(std::string ¶mString, const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString at it's first occurance in string
bool substitute(const std::string &searchString, const std::string &replaceString)
replaces searchString with replaceString
void printParameterMap() const
prints the parameter map
bool save(const std::string &fileName)
saves the content of the template file to a local file (the content of parameterMap_ will not be save...
std::vector< std::string > getSubstitutionParametersFromTemplate() const
returns a vector with all substitution parameters that are found in the template file ...
void replaceString(std::string &demangledName, std::string const &from, std::string const &to)
~L1GtVhdlTemplateFile()
destructor
bool removeLineWithContent(const std::string &str)
removes all lines that contain the str
L1GtVhdlTemplateFile()
standard constructor
void append(const std::string &str)
adds a line at the end of the the file with the content of str
bool isBlank(const char &chr) const
checks weather a char is a blank
std::string getInternalParameter(const std::string &indentifier)
returns a parameter of a internal template file
bool insert(const std::string &atLine, const std::vector< std::string > &content)
replaces the whole line containing atLine and inserts content instead of it
std::vector< std::string > lines_
containing the content of the VHDL file
std::vector< std::string > returnLines() const
returns a string vector with the current content of the VHDL File
static int position[264][3]
bool removeEmptyLines()
deletes all empty lines in a template file
bool open(const std::string &fileName, bool internal=false)
opens a template file. If the header information shall be parsed intern has to be set to true ...
std::map< std::string, std::string > returnParameterMap() const
returns parameter map
void getConditionsFromAlgo(std::string condString, std::vector< std::string > &result) const
extracts all conditions from a algorithm
void print() const
prints the content of the VHDL File (only lines_)