#include <lateq.hh>
Public Member Functions | |
Lateq (const int &numInputs, const int &numOutputs) | |
~Lateq () | |
void | addInputSigFormula (const string &str) |
Add a line of a latex equation code corresponding to a signal. | |
void | addConstSigFormula (const string &str) |
void | addParamSigFormula (const string &str) |
void | addStoreSigFormula (const string &str) |
void | addRecurSigFormula (const string &str) |
void | addRDTblSigFormula (const string &str) |
void | addRWTblSigFormula (const string &str) |
void | addSelectSigFormula (const string &str) |
void | addPrefixSigFormula (const string &str) |
void | addOutputSigFormula (const string &str) |
void | addUISigFormula (const string &path, const string &str) |
void | println (ostream &docout) |
Top-level method to print a whole set of compiled LaTeX formulas. | |
int | inputs () const |
int | outputs () const |
Private Member Functions | |
string | makeItemTitle (const unsigned int formulasListSize, const string &titleName) |
string | makeSignamesList (const list< string > &formulasList, const string &ending) |
string | makeSignamesList (const vector< list< string > > &formulasListsVector, const string &ending) |
For all "internal" signals. | |
string | getSigName (const string &s) |
string | makeSigDomain (const list< string > &formulasList) |
string | getUISigName (const string &s) |
char | getUISigType (const string &s) |
vector< list< string > > | makeUISignamesVector (const multimap< string, string > &field) |
void | printOneLine (const string §ion, ostream &docout) |
Print a sorted list of input signals names ("x_i"), on a single line, separated by commas. | |
void | printHierarchy (const string §ion, multimap< string, string > &field, ostream &docout) |
Print formulas for user interface signals. | |
void | printDGroup (const string §ion, list< string > &field, ostream &docout) |
Print a dgroup environment to auto-break long formulas. | |
void | printMath (const string §ion, list< string > &field, ostream &docout) |
Print formulas for select2, select3 and prefix signals. | |
bool | hasNotOnlyEmptyKeys (multimap< string, string > &mm) |
Find out whether all keys of the multimap are empty or not. | |
void | tab (int n, ostream &docout) const |
Simple handling of indentation. | |
Private Attributes | |
const int | fNumInputs |
const int | fNumOutputs |
list< string > | fInputSigsFormulas |
LaTeX formulas to print. | |
list< string > | fConstSigsFormulas |
list< string > | fParamSigsFormulas |
list< string > | fStoreSigsFormulas |
list< string > | fRecurSigsFormulas |
list< string > | fRDTblSigsFormulas |
list< string > | fRWTblSigsFormulas |
list< string > | fSelectSigsFormulas |
list< string > | fPrefixSigsFormulas |
list< string > | fOutputSigsFormulas |
multimap< string, string > | fUISigsFormulas |
Definition at line 56 of file lateq.hh.
Lateq::Lateq | ( | const int & | numInputs, | |
const int & | numOutputs | |||
) | [inline] |
Definition at line 60 of file lateq.hh.
00061 : fNumInputs(numInputs), fNumOutputs(numOutputs) 00062 {}
void Lateq::addConstSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 68 of file lateq.hh.
References fConstSigsFormulas.
Referenced by DocCompiler::generateVariableStore().
00068 { fConstSigsFormulas.push_back(str); }
void Lateq::addInputSigFormula | ( | const string & | str | ) | [inline] |
Add a line of a latex equation code corresponding to a signal.
Definition at line 67 of file lateq.hh.
References fInputSigsFormulas.
Referenced by DocCompiler::generateInput().
00067 { fInputSigsFormulas.push_back(str); }
void Lateq::addOutputSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 76 of file lateq.hh.
References fOutputSigsFormulas.
Referenced by DocCompiler::compileLateq(), and DocCompiler::generateOutput().
00076 { fOutputSigsFormulas.push_back(str); }
void Lateq::addParamSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 69 of file lateq.hh.
References fParamSigsFormulas.
Referenced by DocCompiler::generateVariableStore().
00069 { fParamSigsFormulas.push_back(str); }
void Lateq::addPrefixSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 75 of file lateq.hh.
References fPrefixSigsFormulas.
Referenced by DocCompiler::generatePrefix().
00075 { fPrefixSigsFormulas.push_back(str); }
void Lateq::addRDTblSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 72 of file lateq.hh.
References fRDTblSigsFormulas.
Referenced by DocCompiler::generateDocConstantTbl().
00072 { fRDTblSigsFormulas.push_back(str); }
void Lateq::addRecurSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 71 of file lateq.hh.
References fRecurSigsFormulas.
Referenced by DocCompiler::generateDelayLine(), and DocCompiler::generateDelayVecNoTemp().
00071 { fRecurSigsFormulas.push_back(str); }
void Lateq::addRWTblSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 73 of file lateq.hh.
References fRWTblSigsFormulas.
Referenced by DocCompiler::generateDocWriteTbl().
00073 { fRWTblSigsFormulas.push_back(str); }
void Lateq::addSelectSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 74 of file lateq.hh.
References fSelectSigsFormulas.
Referenced by DocCompiler::generateSelect2(), and DocCompiler::generateSelect3().
00074 { fSelectSigsFormulas.push_back(str); }
void Lateq::addStoreSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 70 of file lateq.hh.
References fStoreSigsFormulas.
Referenced by DocCompiler::generateVariableStore().
00070 { fStoreSigsFormulas.push_back(str); }
void Lateq::addUISigFormula | ( | const string & | path, | |
const string & | str | |||
) | [inline] |
Definition at line 77 of file lateq.hh.
References fUISigsFormulas.
Referenced by DocCompiler::generateButton(), DocCompiler::generateCheckbox(), DocCompiler::generateHSlider(), DocCompiler::generateNumEntry(), and DocCompiler::generateVSlider().
00077 { fUISigsFormulas.insert(make_pair(path, str)); };
string Lateq::getSigName | ( | const string & | s | ) | [private] |
< Looking for a left member.
< Strip "(t)" argument if exists.
< Strip "[t]" argument if exists (for tables).
< Strip indice if exists.
Definition at line 206 of file lateq.cpp.
Referenced by makeSigDomain().
00207 { 00208 size_t found; 00209 string signame; 00210 00211 found = s.find(" ="); 00212 if (found != string::npos) { 00213 signame = s.substr (0, found); 00214 } 00215 found = s.find("(t)"); 00216 if (found != string::npos) { 00217 signame = s.substr (0, found); 00218 } 00219 found = signame.find("[t]"); 00220 if (found != string::npos) { 00221 signame = s.substr (0, found); 00222 } 00223 found = signame.find_last_of("_"); 00224 if (found != string::npos) { 00225 signame = signame.substr (0, found); 00226 } 00227 00228 return signame; 00229 }
string Lateq::getUISigName | ( | const string & | s | ) | [private] |
< Looking for a UI signal name "{u_?}_{i}(t)".
Definition at line 261 of file lateq.cpp.
Referenced by makeUISignamesVector().
00262 { 00263 size_t found; 00264 string signame; 00265 00266 found = s.find("${u_"); 00267 if (found != string::npos) { 00268 signame = s.substr (found+1, 12); 00269 } 00270 00271 return signame; 00272 }
char Lateq::getUISigType | ( | const string & | s | ) | [private] |
< Looking for a UI signal name "{u_?}_{i}".
Definition at line 275 of file lateq.cpp.
Referenced by makeUISignamesVector().
00276 { 00277 size_t found; 00278 char sigtype = '0'; 00279 00280 found = s.find("${u_"); 00281 if (found != string::npos) { 00282 sigtype = s.at (found+4); 00283 } 00284 00285 return sigtype; 00286 }
bool Lateq::hasNotOnlyEmptyKeys | ( | multimap< string, string > & | mm | ) | [private] |
Find out whether all keys of the multimap are empty or not.
In other words : Check that some UIs have a path (non empty).
In other other words : Check that all UIs are not at top-level.
< Look for pairs with empty keys.
Definition at line 454 of file lateq.cpp.
Referenced by printHierarchy().
00455 { 00456 typedef multimap<string,string>::iterator MMIT; 00457 pair<MMIT,MMIT> range; 00458 range = mm.equal_range(""); 00459 bool hasOnlyEmptyPaths = (range.first == mm.begin()) && (range.second == mm.end()); 00460 return !hasOnlyEmptyPaths; 00461 }
int Lateq::inputs | ( | ) | const [inline] |
Definition at line 82 of file lateq.hh.
References fNumInputs.
Referenced by DocCompiler::generateInput().
00082 { return fNumInputs; }
string Lateq::makeItemTitle | ( | const unsigned int | formulasListSize, | |
const string & | titleName | |||
) | [private] |
Definition at line 143 of file lateq.cpp.
References gDocMathStringMap.
Referenced by println().
00144 { 00145 string item = "\\item "; 00146 00147 /* Plural handling for titles of sub-sets of formulas. */ 00148 string title = formulasListSize > 1 ? gDocMathStringMap[titleName + "2"] : gDocMathStringMap[titleName + "1"]; 00149 00150 return item + title; 00151 }
string Lateq::makeSigDomain | ( | const list< string > & | formulasList | ) | [private] |
< No indices for single input neither single output.
< Indices "1" for all other single signal.
Definition at line 154 of file lateq.cpp.
References gDocMathStringMap, getSigName(), and to_string().
Referenced by makeSignamesList().
00155 { 00156 string signame = ""; 00157 string sigDomain = ""; 00158 00159 if (formulasList.size() > 0) { 00160 string firstEq = *(formulasList.begin()); 00161 signame = getSigName(firstEq); 00162 00163 if(formulasList.size() > 1) { 00164 sigDomain = " $" + signame + "_i$ " + gDocMathStringMap["for"] + " $i \\in [1," + to_string(formulasList.size()) + "]$"; 00165 } else { 00166 if(signame == "x" || signame == "y") { 00167 sigDomain = " $" + signame + "$"; 00168 } else { 00169 sigDomain = " $" + signame + "_1$"; 00170 } 00171 } 00172 } else { 00173 sigDomain = gDocMathStringMap["emptyformulafield"]; 00174 } 00175 return sigDomain; 00176 }
string Lateq::makeSignamesList | ( | const vector< list< string > > & | formulasListsVector, | |
const string & | ending | |||
) | [private] |
For all "internal" signals.
Definition at line 189 of file lateq.cpp.
References gDocMathStringMap, and makeSigDomain().
00190 { 00191 if (formulasListsVector.size() > 0) { 00192 vector<list<string> >::const_iterator it; 00193 string signames = ""; 00194 string sep = " "; 00195 for (it = formulasListsVector.begin(); it != formulasListsVector.end(); ++it) { 00196 signames += sep + makeSigDomain(*it); 00197 (it != (formulasListsVector.end() - 2)) ? sep = ", " : sep = " " + gDocMathStringMap["and"] + " "; 00198 } 00199 return signames + " " + ending; 00200 } else { 00201 return " (" + gDocMathStringMap["emptyformulafield"] + ")"; 00202 } 00203 }
string Lateq::makeSignamesList | ( | const list< string > & | formulasList, | |
const string & | ending | |||
) | [private] |
Definition at line 179 of file lateq.cpp.
References gDocMathStringMap, and makeSigDomain().
Referenced by println().
00180 { 00181 if (formulasList.size() > 0) { 00182 return makeSigDomain(formulasList) + " " + ending; 00183 } else { 00184 return " (" + gDocMathStringMap["emptyformulafield"] + ")"; 00185 } 00186 }
vector< list< string > > Lateq::makeUISignamesVector | ( | const multimap< string, string > & | field | ) | [private] |
Definition at line 232 of file lateq.cpp.
References getUISigName(), and getUISigType().
Referenced by println().
00233 { 00234 map<char,unsigned int> uiTypesMap; 00235 vector<list<string> > uiSignamesVector; 00236 unsigned int vIndex = 0; 00237 00238 multimap<string,string>::const_iterator it; 00239 00240 for (it = field.begin(); it != field.end(); ++it) { 00241 char type = getUISigType(it->second); 00242 string signame = getUISigName(it->second); 00243 00244 map<char,unsigned int>::iterator uiTypesIt; 00245 uiTypesIt = uiTypesMap.find(type); 00246 if( uiTypesIt != uiTypesMap.end()) { 00247 uiSignamesVector[uiTypesMap[uiTypesIt->second]].push_back(signame); 00248 } else { 00249 ++vIndex; 00250 uiTypesMap.insert(pair<char,unsigned int>(type, vIndex)); 00251 list<string>* tmpList = new(list<string>); 00252 tmpList->push_back(signame); 00253 uiSignamesVector.push_back(*tmpList); 00254 } 00255 } 00256 00257 return uiSignamesVector; 00258 }
int Lateq::outputs | ( | ) | const [inline] |
Definition at line 83 of file lateq.hh.
References fNumOutputs.
Referenced by DocCompiler::compileLateq(), and DocCompiler::generateOutput().
00083 { return fNumOutputs; }
void Lateq::printDGroup | ( | const string & | section, | |
list< string > & | field, | |||
ostream & | docout | |||
) | [private] |
Print a dgroup environment to auto-break long formulas.
[in] | section | The title to print for these formulas. |
[in] | field | The list of LaTeX formulas. |
[out] | docout | The LaTeX output file to print into. |
Definition at line 319 of file lateq.cpp.
References tab().
Referenced by println().
00320 { 00321 if (field.size() > 0) { 00322 docout << section << endl; 00323 tab(1,docout); docout << "\\begin{dgroup*}" << endl; 00324 list<string>::const_iterator s; 00325 for (s = field.begin(); s != field.end(); ++s) { 00326 tab(2,docout); docout << "\\begin{" << "dmath*" << "}" << endl; 00327 tab(3,docout); docout << "\t" << *s << endl; 00328 tab(2,docout); docout << "\\end{" << "dmath*" << "}" << endl; 00329 } 00330 tab(1,docout); docout << "\\end{dgroup*}" << endl; 00331 docout << endl; 00332 } 00333 }
void Lateq::printHierarchy | ( | const string & | section, | |
multimap< string, string > & | field, | |||
ostream & | docout | |||
) | [private] |
Print formulas for user interface signals.
[in] | section | The title to print for these formulas. |
[in] | field | This multimap contains pairs : 1. the path_string is printed as a sub-title item, when new; 2. each latex_string is printed as a preformated row of the supertabular environment (needed to handle long tables). |
[out] | docout | The LaTeX output file to print into. |
< Manage itemize printing for pathnames.
< Manage latex indentation offset.
Definition at line 359 of file lateq.cpp.
References gDocMathStringMap, hasNotOnlyEmptyKeys(), and tab().
Referenced by println().
00360 { 00361 if (field.size() > 0) { 00362 docout << section << endl; 00363 00364 bool hasSomePaths = hasNotOnlyEmptyKeys(field); 00365 unsigned int n; 00366 00367 if (hasSomePaths) { 00368 tab(0,docout); docout << "\\begin{itemize}" << endl; 00369 n = 1; 00370 } else { 00371 n = 0; 00372 } 00373 00374 multimap<string,string>::iterator it; 00375 string uidir = "improbable_starting_dirname"; 00376 bool startFlag = true; 00377 00378 for (it = field.begin(); it != field.end(); ++it) { 00379 /* Manage supertabular environment bounds and pathname printing. */ 00380 if (it->first != uidir) { 00381 if (!startFlag) { 00382 tab(n+2,docout); docout << "\\end{supertabular}" << endl; 00383 tab(n+1,docout); docout << "\\end{center}" << endl; 00384 } else { 00385 startFlag = false; 00386 } 00387 if (hasSomePaths) { 00388 /* Print the current pathname if new and if pathnames requested. */ 00389 if (it->first != "") { 00390 tab(n+0,docout); docout << "\\item \\textsf{" << it->first << "}" << endl; 00391 } else { 00392 tab(n+0,docout); docout << "\\item \\emph{" << gDocMathStringMap["rootlevel"] << "}" << endl; 00393 } 00394 } 00395 tab(n+1,docout); docout << "\\begin{center}" << endl; 00396 tab(n+2,docout); docout << "\\begin{supertabular}{lll}" << endl; 00397 } 00398 /* Print the current formula. */ 00399 tab(n+3,docout); docout << it->second << endl; 00400 uidir = it->first; 00401 } 00402 tab(n+2,docout); docout << "\\end{supertabular}" << endl; 00403 tab(n+1,docout); docout << "\\end{center}" << endl; 00404 if (hasSomePaths) { 00405 tab(n+0,docout); docout << "\\end{itemize}" << endl; 00406 } 00407 docout << endl; 00408 } 00409 }
void Lateq::println | ( | ostream & | docout | ) |
Top-level method to print a whole set of compiled LaTeX formulas.
Top-level method to print a whole set of compiled LaTeX formulas, corresponding to an <equation> faustdoc tag.
Definition at line 83 of file lateq.cpp.
References compLateqIndexes(), fConstSigsFormulas, fInputSigsFormulas, fOutputSigsFormulas, fParamSigsFormulas, fPrefixSigsFormulas, fRDTblSigsFormulas, fRecurSigsFormulas, fRWTblSigsFormulas, fSelectSigsFormulas, fStoreSigsFormulas, fUISigsFormulas, gDocMathStringMap, makeItemTitle(), makeSignamesList(), makeUISignamesVector(), printDGroup(), printHierarchy(), printMath(), printOneLine(), and to_string().
Referenced by printDocEqn().
00084 { 00085 /* 1. Make titles of sub-sets of formulas. */ 00086 string suchthat = gDocMathStringMap["suchthat"]; 00087 00088 string sInputs = makeItemTitle(fInputSigsFormulas.size(), "inputsigtitle") + makeSignamesList(fInputSigsFormulas, ""); 00089 string sOutputs = makeItemTitle(fOutputSigsFormulas.size(), "outputsigtitle") + makeSignamesList(fOutputSigsFormulas, suchthat); 00090 string sConstants = makeItemTitle(fConstSigsFormulas.size(), "constsigtitle") + makeSignamesList(fConstSigsFormulas, suchthat); 00091 00092 vector<list<string> > UISignamesVector = makeUISignamesVector(fUISigsFormulas); 00093 string sUIElements = makeItemTitle(fUISigsFormulas.size(), "uisigtitle") + makeSignamesList(UISignamesVector, suchthat); 00094 00095 unsigned int internalSigsCount = fParamSigsFormulas.size() + fStoreSigsFormulas.size() + fRecurSigsFormulas.size() + fRDTblSigsFormulas.size() + fRWTblSigsFormulas.size() + fSelectSigsFormulas.size() + fPrefixSigsFormulas.size(); 00096 00097 vector<list<string> > internalSigsFormulasList; 00098 if( ! fParamSigsFormulas.empty() ) internalSigsFormulasList.push_back(fParamSigsFormulas); 00099 if( ! fStoreSigsFormulas.empty() ) internalSigsFormulasList.push_back(fStoreSigsFormulas); 00100 if( ! fRecurSigsFormulas.empty() ) internalSigsFormulasList.push_back(fRecurSigsFormulas); 00101 if( ! fRDTblSigsFormulas.empty() ) internalSigsFormulasList.push_back(fRDTblSigsFormulas); 00102 if( ! fRWTblSigsFormulas.empty() ) internalSigsFormulasList.push_back(fRWTblSigsFormulas); 00103 if( ! fSelectSigsFormulas.empty() ) internalSigsFormulasList.push_back(fSelectSigsFormulas); 00104 if( ! fPrefixSigsFormulas.empty() ) internalSigsFormulasList.push_back(fPrefixSigsFormulas); 00105 00106 string sInternals = makeItemTitle(internalSigsCount, "intermedsigtitle") + makeSignamesList(internalSigsFormulasList, suchthat); 00107 00108 /* 2. Successively print each Lateq field containing LaTeX formulas, with a title. */ 00109 00110 docout << endl << gDocMathStringMap["lateqcomment"] << endl; 00111 docout << "\\begin{enumerate}" << endl << endl; 00112 00113 printDGroup (sOutputs, fOutputSigsFormulas, docout); 00114 printOneLine (sInputs, docout); 00115 const string outputsTitle = "\\item " + sOutputs + "\\ $y_i$\\ " + gDocMathStringMap["for"] + " $i \\in [1," + to_string(fOutputSigsFormulas.size()) + "]$: "; 00116 printHierarchy (sUIElements, fUISigsFormulas, docout); 00117 00118 /* The "Internal signals" item gather several fields, like a "super-item"... */ 00119 if( internalSigsCount > 0 ) { 00120 docout << sInternals; 00121 } 00122 fStoreSigsFormulas.sort(compLateqIndexes); 00123 printDGroup ("", fParamSigsFormulas, docout); 00124 printDGroup ("", fStoreSigsFormulas, docout); 00125 printDGroup ("", fRecurSigsFormulas, docout); 00126 printDGroup ("", fRDTblSigsFormulas, docout); 00127 printMath ("", fRWTblSigsFormulas, docout); 00128 printMath ("", fSelectSigsFormulas, docout); 00129 printMath ("", fPrefixSigsFormulas, docout); 00130 00131 printDGroup (sConstants, fConstSigsFormulas, docout); 00132 00133 docout << "\\end{enumerate}" << endl << endl; 00134 }
void Lateq::printMath | ( | const string & | section, | |
list< string > & | field, | |||
ostream & | docout | |||
) | [private] |
Print formulas for select2, select3 and prefix signals.
[in] | section | The title to print for these formulas. |
[in] | field | The list of LaTeX arrays (for braces with two lines). |
[out] | docout | The LaTeX output file to print into. |
Definition at line 423 of file lateq.cpp.
Referenced by println().
00424 { 00425 if (field.size() > 0) { 00426 docout << section; 00427 docout << "\\begin{displaymath}" << endl; 00428 list<string>::iterator s; 00429 for (s = field.begin(); s != field.end(); ++s) { 00430 docout << *s << endl; 00431 } 00432 docout << "\\end{displaymath}" << endl; 00433 docout << endl; 00434 } 00435 }
void Lateq::printOneLine | ( | const string & | section, | |
ostream & | docout | |||
) | [private] |
Print a sorted list of input signals names ("x_i"), on a single line, separated by commas.
[in] | section | The title to print for these formulas. |
[out] | docout | The LaTeX output file to print into. |
Definition at line 302 of file lateq.cpp.
Referenced by println().
void Lateq::tab | ( | int | n, | |
ostream & | docout | |||
) | const [private] |
Simple handling of indentation.
Definition at line 439 of file lateq.cpp.
Referenced by printDGroup(), and printHierarchy().
list<string> Lateq::fConstSigsFormulas [private] |
Definition at line 93 of file lateq.hh.
Referenced by addConstSigFormula(), and println().
list<string> Lateq::fInputSigsFormulas [private] |
LaTeX formulas to print.
Definition at line 92 of file lateq.hh.
Referenced by addInputSigFormula(), and println().
const int Lateq::fNumInputs [private] |
const int Lateq::fNumOutputs [private] |
list<string> Lateq::fOutputSigsFormulas [private] |
Definition at line 101 of file lateq.hh.
Referenced by addOutputSigFormula(), and println().
list<string> Lateq::fParamSigsFormulas [private] |
Definition at line 94 of file lateq.hh.
Referenced by addParamSigFormula(), and println().
list<string> Lateq::fPrefixSigsFormulas [private] |
Definition at line 100 of file lateq.hh.
Referenced by addPrefixSigFormula(), and println().
list<string> Lateq::fRDTblSigsFormulas [private] |
Definition at line 97 of file lateq.hh.
Referenced by addRDTblSigFormula(), and println().
list<string> Lateq::fRecurSigsFormulas [private] |
Definition at line 96 of file lateq.hh.
Referenced by addRecurSigFormula(), and println().
list<string> Lateq::fRWTblSigsFormulas [private] |
Definition at line 98 of file lateq.hh.
Referenced by addRWTblSigFormula(), and println().
list<string> Lateq::fSelectSigsFormulas [private] |
Definition at line 99 of file lateq.hh.
Referenced by addSelectSigFormula(), and println().
list<string> Lateq::fStoreSigsFormulas [private] |
Definition at line 95 of file lateq.hh.
Referenced by addStoreSigFormula(), and println().
multimap<string,string> Lateq::fUISigsFormulas [private] |
Definition at line 102 of file lateq.hh.
Referenced by addUISigFormula(), and println().