40 if (!
open(filename,
false))
std::cout<<
"Error while opening file: "<<filename<<std::endl;
64 position = paramString.find(searchString);
65 if (position == std::string::npos)
return false;
66 paramString.replace(position,searchString.length(),replaceString);
74 const char paramIndicator=
'#';
75 const char commentIndicator=
'%';
77 std::string stringBuffer;
89 if (stringBuffer[stringBuffer.length()-1]==13)
91 stringBuffer.replace(stringBuffer.length()-1,1,
"");
94 lines_.push_back(stringBuffer);
103 std::vector<std::string>::iterator iter =
lines_.begin();
104 while( iter !=
lines_.end() )
106 while ((*iter)[0]==commentIndicator && (*iter)[1]==commentIndicator)
109 if ((*iter)[0]==paramIndicator)
111 std::vector<std::string>::iterator iter2 = iter;
116 while (iter2!=
lines_.end())
118 if ((*iter2)[0]==paramIndicator && (*iter2)[1]==paramIndicator)
129 std::vector<std::string>::iterator tmpIter= iter2;
133 if (!((*tmpIter)[0]==paramIndicator && (*tmpIter)[1]==paramIndicator))
147 lines_.erase(iter,iter2 );
152 if (iter!=
lines_.end()) iter++;
157 while( iter !=
lines_.end() )
159 if ((*iter)==
"" || (*iter).length()==0 || (*iter)==
" ")
lines_.erase(iter);
else
173 std::vector<std::string>::iterator iter =
lines_.begin();
176 while( iter !=
lines_.end() )
195 std::vector<std::string>::iterator iter =
lines_.begin();
196 while( iter !=
lines_.end())
215 std::vector<std::string>::iterator iter =
lines_.begin();
218 while( iter !=
lines_.end() )
221 if ((*iter).find(atLine)!=std::string::npos)
224 iter =
lines_.erase(iter);
226 lines_.insert(iter,content.begin(),content.end());
241 std::vector<std::string>::iterator iter =
lines_.begin();
244 if (
insert(atLine,temp))
return true;
259 std::vector<std::string>::iterator iter =
lines_.begin();
260 while( iter !=
lines_.end())
277 std::cout<<
"Enter parametermap"<<std::endl;
279 std::map<std::string,std::string>::iterator iter =
parameterMap_.begin();
283 std::cout<<(*iter).first<<
": "<<(*iter).second<<std::endl;
300 if (
int pos1=str.find(
"$(")!=std::string::npos && str.substr(0,2)!=
"--")
302 int pos2=str.find(
")");
304 std::string tempStr=(str.substr(pos1+1,(pos2-pos1-1)));
311 parameters.push_back(tempStr);
328 std::vector<std::string>
temp;
329 std::vector<std::string>::iterator iter =
lines_.begin();
332 while( iter !=
lines_.end() )
351 for (
unsigned int i=0;
i<file.
lines_.size();
i++)
362 std::vector<std::string>::iterator iter =
lines_.begin();
363 while( iter !=
lines_.end())
366 position = (*iter).find(str);
368 if (position != std::string::npos)
380 std::vector<std::string>::iterator iter =
lines_.begin();
382 while( iter !=
lines_.end() )
384 if ((*iter)==
"" || (*iter).length()==0 || (*iter)==
" ")
lines_.erase(iter);
else
394 if (chr==
' ')
return true;
408 std::string
temp = param.substr(i);
409 std::size_t
pos = temp.find(
" ");
411 if (pos != std::string::npos)
413 std::string temp2 = temp.substr(0, pos);
414 result.push_back(temp2);
417 }
else if (!
isBlank(temp[pos+1]))
419 result.push_back(temp);
430 std::vector<std::string> operators;
432 operators.push_back(
"AND");
433 operators.push_back(
"OR");
434 operators.push_back(
"NOT");
435 operators.push_back(
"(");
436 operators.push_back(
")");
438 for (
unsigned int i =0;
i<operators.size();
i++)
443 split(condString,result);
450 std::vector<std::string>::iterator iter =
lines_.begin();
451 std::ostringstream buffer;
453 while( iter !=
lines_.end() )
455 buffer<<(*iter)<<std::endl;
std::map< std::string, std::string > returnParameterMap()
returns parameter map
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
bool isBlank(const char &chr)
checks weather a char is a blank
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...
~L1GtVhdlTemplateFile()
destructor
std::map< std::string, std::string > parameterMap_
containing the header information of internal files
static int position[TOTALCHAMBERS][3]
bool removeLineWithContent(const std::string &str)
removes all lines that contain the str
L1GtVhdlTemplateFile()
standard constructor
bool insert(const std::string &atLine, std::vector< std::string > content)
replaces the whole line containing atLine and inserts content instead of it
void append(const std::string &str)
adds a line at the end of the the file with the content of str
void print()
prints the content of the VHDL File (only lines_)
std::vector< std::string > returnLines()
returns a string vector with the current content of the VHDL File
std::string getInternalParameter(const std::string &indentifier)
returns a parameter of a internal template file
std::string lines2String()
returns a string with the content of vector lines
std::vector< std::string > lines_
containing the content of the VHDL file
bool split(const std::string ¶m, std::vector< std::string > &result)
seperates a string at all blanks and saves the elements in result
void getConditionsFromAlgo(std::string condString, std::vector< std::string > &result)
extracts all conditions from a algorithm
bool extractParametersFromString(const std::string &str, std::vector< std::string > ¶meters)
void printParameterMap()
prints the parameter map
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::vector< std::string > getSubstitutionParametersFromTemplate()
returns a vector with all substitution parameters that are found in the template file ...