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());
243 if (
insert(atLine,temp))
return true;
258 std::vector<std::string>::iterator iter =
lines_.begin();
259 while( iter !=
lines_.end())
276 std::cout<<
"Enter parametermap"<<std::endl;
278 std::map<std::string,std::string>::iterator iter =
parameterMap_.begin();
282 std::cout<<(*iter).first<<
": "<<(*iter).second<<std::endl;
299 if (
int pos1=str.find(
"$(")!=std::string::npos && str.substr(0,2)!=
"--")
301 int pos2=str.find(
")");
303 std::string tempStr=(str.substr(pos1+1,(pos2-pos1-1)));
310 parameters.push_back(tempStr);
327 std::vector<std::string>
temp;
328 std::vector<std::string>::iterator iter =
lines_.begin();
331 while( iter !=
lines_.end() )
350 for (
unsigned int i=0;
i<file.
lines_.size();
i++)
361 std::vector<std::string>::iterator iter =
lines_.begin();
362 while( iter !=
lines_.end())
365 position = (*iter).find(str);
367 if (position != std::string::npos)
379 std::vector<std::string>::iterator iter =
lines_.begin();
381 while( iter !=
lines_.end() )
383 if ((*iter)==
"" || (*iter).length()==0 || (*iter)==
" ")
lines_.erase(iter);
else
393 if (chr==
' ')
return true;
407 std::string
temp = param.substr(i);
408 std::size_t
pos = temp.find(
" ");
410 if (pos != std::string::npos)
412 std::string temp2 = temp.substr(0, pos);
413 result.push_back(temp2);
416 }
else if (!
isBlank(temp[pos+1]))
418 result.push_back(temp);
429 std::vector<std::string> operators;
431 operators.push_back(
"AND");
432 operators.push_back(
"OR");
433 operators.push_back(
"NOT");
434 operators.push_back(
"(");
435 operators.push_back(
")");
437 for (
unsigned int i =0;
i<operators.size();
i++)
442 split(condString,result);
449 std::vector<std::string>::iterator iter =
lines_.begin();
450 std::ostringstream buffer;
452 while( iter !=
lines_.end() )
454 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
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
static int position[264][3]
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 ...