38 if (!
open(filename,
false))
std::cout<<
"Error while opening file: "<<filename<<std::endl;
62 position = paramString.find(searchString);
63 if (position == std::string::npos)
return false;
64 paramString.replace(position,searchString.length(),
replaceString);
72 const char paramIndicator=
'#';
73 const char commentIndicator=
'%';
87 if (stringBuffer[stringBuffer.length()-1]==13)
89 stringBuffer.replace(stringBuffer.length()-1,1,
"");
92 lines_.push_back(stringBuffer);
101 std::vector<std::string>::iterator iter =
lines_.begin();
102 while( iter !=
lines_.end() )
104 while ((*iter)[0]==commentIndicator && (*iter)[1]==commentIndicator)
107 if ((*iter)[0]==paramIndicator)
109 std::vector<std::string>::iterator iter2 = iter;
114 while (iter2!=
lines_.end())
116 if ((*iter2)[0]==paramIndicator && (*iter2)[1]==paramIndicator)
127 std::vector<std::string>::iterator tmpIter= iter2;
131 if (!((*tmpIter)[0]==paramIndicator && (*tmpIter)[1]==paramIndicator))
145 lines_.erase(iter,iter2 );
150 if (iter!=
lines_.end()) iter++;
155 while( iter !=
lines_.end() )
157 if ((*iter)==
"" || (*iter).length()==0 || (*iter)==
" ")
lines_.erase(iter);
else
171 std::vector<std::string>::iterator iter =
lines_.begin();
174 while( iter !=
lines_.end() )
193 std::vector<std::string>::iterator iter =
lines_.begin();
194 while( iter !=
lines_.end())
213 std::vector<std::string>::iterator iter =
lines_.begin();
216 while( iter !=
lines_.end() )
219 if ((*iter).find(atLine)!=std::string::npos)
222 iter =
lines_.erase(iter);
224 lines_.insert(iter,content.begin(),content.end());
241 if (
insert(atLine,temp))
return true;
256 std::vector<std::string>::const_iterator iter =
lines_.begin();
257 while( iter !=
lines_.end())
274 std::cout<<
"Enter parametermap"<<std::endl;
276 std::map<std::string,std::string>::const_iterator iter =
parameterMap_.begin();
280 std::cout<<(*iter).first<<
": "<<(*iter).second<<std::endl;
297 if (
int pos1=str.find(
"$(")!=std::string::npos && str.substr(0,2)!=
"--")
299 int pos2=str.find(
")");
301 std::string tempStr=(str.substr(pos1+1,(pos2-pos1-1)));
308 parameters.push_back(tempStr);
325 std::vector<std::string>
temp;
326 std::vector<std::string>::const_iterator iter =
lines_.begin();
329 while( iter !=
lines_.end() )
348 for (
unsigned int i=0;
i<file.
lines_.size();
i++)
359 std::vector<std::string>::iterator iter =
lines_.begin();
360 while( iter !=
lines_.end())
363 position = (*iter).find(str);
365 if (position != std::string::npos)
377 std::vector<std::string>::iterator iter =
lines_.begin();
379 while( iter !=
lines_.end() )
381 if ((*iter)==
"" || (*iter).length()==0 || (*iter)==
" ")
lines_.erase(iter);
else
391 if (chr==
' ')
return true;
406 std::size_t pos = temp.find(
" ");
408 if (pos != std::string::npos)
411 result.push_back(temp2);
414 }
else if (!
isBlank(temp[pos+1]))
416 result.push_back(temp);
427 std::vector<std::string> operators;
429 operators.push_back(
"AND");
430 operators.push_back(
"OR");
431 operators.push_back(
"NOT");
432 operators.push_back(
"(");
433 operators.push_back(
")");
435 for (
unsigned int i =0;
i<operators.size();
i++)
440 split(condString,result);
447 std::vector<std::string>::const_iterator iter =
lines_.begin();
448 std::ostringstream buffer;
450 while( iter !=
lines_.end() )
452 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
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 ...
~L1GtVhdlTemplateFile()
destructor
std::map< std::string, std::string > parameterMap_
containing the header information of internal files
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
static void replaceString(std::string &name, std::string const &from, std::string const &to)
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_)