ref2html.cpp
Go to the documentation of this file.
1 /** ref2html.cpp Utility to generate a html documents from fref files */
2 
3 /* FAU Discrete Event Systems Library (libfaudes)
4 
5 Copyright (C) 2011 Thomas Moor
6 
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11 
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
20 
21 
22 /*
23 
24 Note: in its current state, this utility is badly organized.
25 
26 Issues include
27 - preformance (linear searchs)
28 - normalised section labels etc
29 - global configuration data
30 - embedded HTML fragments
31 ... however, it does its job
32 
33 */
34 
35 
36 
37 #include <string>
38 #include <cctype>
39 #include <ctime>
40 #include <iostream>
41 #include <fstream>
42 #include "corefaudes.h"
43 
44 
45 using namespace faudes;
46 
47 // ******************************************************************
48 // error exit
49 // ******************************************************************
50 
51 void usage_exit(const std::string& rMessage="") {
52  // ui hints
53  if(rMessage!="") {
54  std::cerr << rMessage << std::endl;
55  std::cout << "" << std::endl;
56  }
57  std::cerr << "ref2html: " << VersionString() << std::endl;
58  std::cout << "" << std::endl;
59  std::cerr << "utility to generate HTML from libFAUDES reference pages (*.fref)" << std::endl;
60  std::cerr << std::endl << "usage: " << std::endl;
61  std::cerr << " ref2html [options...] <fref-file> <html-file>" << std::endl;
62  std::cerr << " ref2html [options...] <fref-file 1> [...] <fref-file n> <html-dir>" << std::endl;
63  std::cerr << " ref2html [options...] <fref-dir> <html-dir>" << std::endl;
64  std::cerr << "with options as follows:" << std::endl;
65  std::cerr << " -rti <rti-file> use specified run-time-interface definition" << std::endl;
66  std::cerr << " -flx <flx-file> use specified lua-extension file" << std::endl;
67  std::cerr << " -css <css-file> use specified style sheet" << std::endl;
68  std::cerr << " -cnav <fref-file> use specified chapter navigation file" << std::endl;
69  std::cerr << " -chapter <label> overwrite chapter label" << std::endl;
70  std::cerr << " -section <label> overwrite section label" << std::endl;
71  std::cerr << " -rel <prefix> prefix to chapter documentation base" << std::endl;
72  std::cerr << " -inc <fref-file> include table of contents" << std::endl;
73  std::cerr << std::endl << std::endl;
74  std::cerr << " ref2html -toc <fref-files> <output-file>" << std::endl;
75  std::cerr << "to generate table of contents file" << std::endl;
76  std::cerr << std::endl << std::endl;
77  std::cerr << " ref2html -doxheader <output-file>" << std::endl;
78  std::cerr << " ref2html -doxfooter <output-file>" << std::endl;
79  std::cerr << "to generate header/footer for c++ api documentation" << std::endl;
80  std::cerr << std::endl << std::endl;
81  std::cerr << " ref2html -extract <input-file> <output-directory>" << std::endl;
82  std::cerr << "to extract multiple reference pages from one file" << std::endl;
83  std::cerr << std::endl;
84  std::cerr << std::endl << "note: use \"-\" as output file for console output" << std::endl;
85  exit(1);
86 }
87 
88 
89 // ******************************************************************
90 // configuration
91 // ******************************************************************
92 
93 bool mStandaloneReference = false;
94 
95 std::string mFrefTitle="";
96 std::string mFrefChapter="";
97 std::string mFrefSection="";
98 std::string mFrefPage="";
99 std::string mFrefLink="";
100 std::string mFrefSummary="";
101 
102 std::string mRtiFile="";
103 std::string mFlxFile="";
104 std::string mDstFile="";
105 std::set< std::string > mSrcFiles;
106 std::string mChapterFile="";
107 std::string mIncludeFile="";
108 
109 std::string mBooksPrefix="../";
110 std::string mChaptersPrefix="./";
111 std::string mImagePrefix="./images/";
112 std::string mReferencePrefix="./reference/";
113 std::string mCsourcePrefix="./csource/";
114 std::string mLuafaudesPrefix="./luafaudes/";
115 
116 /*
117 std::string mDownloadLink="http://www.rt.eei.uni-erlangen.de/FGdes/download.html";
118 std::string mFaudesLink="http://www.rt.eei.uni-erlangen.de/FGdes/faudes";
119 std::string mDestoolLink="http://www.rt.eei.uni-erlangen.de/FGdes/destool";
120 std::string mLuafaudesLink="http://www.rt.eei.uni-erlangen.de/FGdes/faudes/luafaudes/";
121 std::string mCsourceLink="http://www.rt.eei.uni-erlangen.de/FGdes/faudes/csource/";
122 std::string mCssFile="faudes.css";
123 */
124 
125 std::string mDownloadLink="http://www.rt.techfak.fau.de/FGdes/download.html";
126 std::string mFaudesLink="http://www.rt.techfak.fau.de/FGdes/faudes";
127 std::string mDestoolLink="http://www.rt.techfak.fau.de/FGdes/destool";
128 std::string mLuafaudesLink="http://www.rt.techfak.fau.de/FGdes/faudes/luafaudes/";
129 std::string mCsourceLink="http://www.rt.techfak.fau.de/FGdes/faudes/csource/";
130 std::string mCssFile="faudes.css";
131 
132 std::string mThisChapterClass="chapter_this";
133 std::string mOtherChapterClass="chapter_other";
134 std::string mExitChapterClass="chapter_exit";
135 
136 // ******************************************************************
137 // configure: set my chapter prefix
138 // ******************************************************************
139 
140 void ChaptersPrefix(const std::string& prefix) {
141  mChaptersPrefix=prefix;
142  mBooksPrefix=prefix+"../";
143  mImagePrefix=prefix+"images/";
144  mReferencePrefix=prefix+"reference/";
145  mCsourcePrefix=prefix+"csource/";
146  mLuafaudesPrefix=prefix+"luafaudes/";
147  mCssFile=prefix+mCssFile;
148 }
149 
150 // ******************************************************************
151 // helper: time stamp
152 // ******************************************************************
153 
154 std::string TimeStamp(void) {
155  time_t now;
156  struct tm * local;
157  char buffer[80];
158  time(&now );
159  local=localtime(&now);
160  strftime(buffer,80,"%Y.%m.%d",local);
161  return std::string(buffer);
162 }
163 
164 
165 // ******************************************************************
166 // helper: convert page to printable
167 // ******************************************************************
168 
169 std::string PrettyPage(const std::string page){
170  // swallow page number
171  std::string ppage = page;
172  std::size_t upos = ppage.find_first_of("_");
173  std::size_t spos = ppage.find_first_of(" ");
174  std::size_t dpos = 0;
175  for(; dpos < ppage.size();dpos++)
176  if(!isdigit(ppage.at(dpos))) break;
177  if(upos!=std::string::npos)
178  if(upos==dpos)
179  if(upos+1<ppage.size())
180  ppage=ppage.substr(upos+1,ppage.size()-upos-1);
181  if(spos!=std::string::npos)
182  if(spos==dpos)
183  if(spos+1<ppage.size())
184  ppage=ppage.substr(spos+1,ppage.size()-spos-1);
185  // turn underscore to space
186  ppage=StringSubstitute(ppage,"_"," ");
187  // done
188  return ppage;
189 }
190 
191 
192 // ******************************************************************
193 // helper: bottom line
194 // ******************************************************************
195 
196 void BottomLineHtml(std::ostream* pStream) {
197  *pStream << "<p class=\"bottom_line\"> " << std::endl;
198  *pStream << "<a href=\"" << mFaudesLink << "\" target=\"_top\">" << VersionString() << "</a> " << std::endl;
199  *pStream << "--- " << TimeStamp() << " " << std::endl;
200  if(PluginsString()!="" && mFrefChapter!="cppapi")
201  *pStream << "--- with &quot;" << PluginsString() << "&quot; " << std::endl;
202  if(mFrefChapter=="cppapi")
203  *pStream << "--- c++ api documentaion by <a href=\"http://www.doxygen.org\" target=\"_top\">doxygen</a>" << std::endl;
204  *pStream << "</p>" << std::endl;
205  if(mFrefChapter=="reference") {
206  *pStream << "<!--[if IE]>" << std::endl;
207  *pStream << "<p class=\"bottom_line_warning\">" << std::endl;
208  *pStream << "If MS Internet Explorer fails to display certain mathematical symbols," << std::endl;
209  *pStream << "your system misses the corresponding unicode fonts." << std::endl;
210  *pStream << "<br>" << std::endl;
211  *pStream << "You may either install &quot;Arial Unicode MS&quot; from a recent MS Office package" << std::endl;
212  *pStream << "or the freely available" << std::endl;
213  *pStream << "&quot;<a href=\"http://greekfonts.teilar.gr/\">Symbola</a>&quot;" << std::endl;
214  *pStream << "<br>" << std::endl;
215  *pStream << "See also <a href=\"http://www.alanwood.net/\">Allan Woods</a> unicode page." << std::endl;
216  *pStream << "B.t.w.: <a href=\"http://www.mozilla.com\">Firefox</a> will display" << std::endl;
217  *pStream << "all relevant symbols out-of-the-box and nicely render SVG diagrams." << std::endl;
218  *pStream << "<br>" << std::endl;
219  *pStream << "<br>" << std::endl;
220  *pStream << "</p>" << std::endl;
221  *pStream << "<![endif]-->" << std::endl;
222  }
223 }
224 
225 
226 // ******************************************************************
227 // helper: html header
228 // ******************************************************************
229 
230 void HeaderHtml(std::ostream* pStream) {
231  *pStream << "<!doctype html>" << std::endl;
232  *pStream << "<html xmlns=\"http://www.w3.org/1999/xhtml\">" << std::endl;
233  *pStream << "<head>" << std::endl;
234  *pStream << "<title>" << mFrefTitle << "</title>" << std::endl;
235  *pStream << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />" << std::endl;
236  *pStream << "<meta name=\"contents\" content=\"discrete event systems, libFAUDES, supervisory control, controller synthesis, automata, software library, regular languages, open source, GPL.\"/>" << std::endl;
237  *pStream << "<link href=\"" << mCssFile << "\" rel=\"stylesheet\" type=\"text/css\" />" << std::endl;
238  *pStream << "<link rel=\"shortcut icon\" href=\""<< mImagePrefix << "des.ico\">" << std::endl;
239  *pStream << "</head>" << std::endl;
240  *pStream << "<body>" << std::endl;
241  *pStream << "<div id=\"cwrapper1000\">" << std::endl;
242  *pStream << "<div id=\"dwrapper1000\">" << std::endl;
243 }
244 
245 // ******************************************************************
246 // helper: html footer
247 // ******************************************************************
248 
249 void FooterHtml(std::ostream* pStream) {
250  *pStream << "</div>" << std::endl;
251  *pStream << "</div>" << std::endl;
252  *pStream << "</body>" << std::endl;
253  *pStream << "</html>" << std::endl;
254 }
255 
256 // ******************************************************************
257 // helper: html for image
258 // ******************************************************************
259 
260 void ImageHtml(std::ostream* pStream, const std::string& rFileName) {
261  *pStream << "<a class=\"faudes_image\" href=\"" << mImagePrefix << rFileName << ".html\">";
262  *pStream << "<img src=\"" << mImagePrefix << rFileName << ".png\"/>";
263  *pStream << "</a>";
264 }
265 
266 // ******************************************************************
267 // helper: fancy reference for resgistry list
268 // ******************************************************************
269 
270 
271 void ListItemHtml(std::ostream* pStream, const std::string& rLink, const std::string& rText) {
272  *pStream << "<li class=\"registry_item\">" << std::endl
273  << "<a href=\"" << rLink << "\">" << rText << "</a>" << std::endl
274  << "<a href=\"" << rLink << "\" class=\"registry_blinda\">&nbsp;</a>" << std::endl
275  << "</li>" << std::endl;
276  }
277 
278 // ******************************************************************
279 // helper: html for linked type name
280 // ******************************************************************
281 
282 void TypeHtml(std::ostream* pStream, const std::string& rTypeName) {
283 
284  // just text if unknown
285  if(!TypeRegistry::G()->Exists(rTypeName)) {
286  *pStream << rTypeName;
287  return;
288  }
289 
290  // retrieve definition
291  const TypeDefinition& tdef=TypeRegistry::G()->Definition(rTypeName);
292  std::string tyname = tdef.Name();
293  std::string tyhtml = tdef.HtmlDoc();
294  if(tyhtml=="" || tyhtml=="none") {
295  *pStream << tyname;
296  } else {
297  *pStream << "<a href=\"" << mReferencePrefix << tyhtml << "\">" << tyname << "</a>";
298  }
299 }
300 
301 
302 // ******************************************************************
303 // helper: html for linked function name
304 // ******************************************************************
305 
306 void FunctionHtml(std::ostream* pStream, const std::string& rFunctionName) {
307 
308  // just text if unknown
309  if(!FunctionRegistry::G()->Exists(rFunctionName)) {
310  *pStream << rFunctionName;
311  return;
312  }
313 
314  // retrieve definition
315  const FunctionDefinition& fdef=FunctionRegistry::G()->Definition(rFunctionName);
316  std::string fname = fdef.Name();
317  std::string fhtml = fdef.HtmlDoc();
318  if(fhtml=="" || fhtml=="none") {
319  *pStream << fname;
320  } else {
321  *pStream << "<a href=\"" << mReferencePrefix << fhtml << "\">" << fname << "</a>";
322  }
323 }
324 
325 // ******************************************************************
326 // helper: html for ascii text
327 // ******************************************************************
328 
329 void TextHtml(std::ostream* pStream, const std::string& rText) {
330  std::string buff;
331  buff=StringSubstitute(buff,"<","&lt;");
332  buff=StringSubstitute(buff,">","&gt;");
333  buff=StringSubstitute(buff,"&","&amp;");
334  *pStream << buff;
335 }
336 
337 // ******************************************************************
338 // helper: html for math
339 // (we really need at least regex here!)
340 // ******************************************************************
341 
342 // resolve simple one-arg macros
343 std::string TexMacroSubstitute1(const std::string& rTexString, const std::string& rMacro, const std::string& rSubst) {
344  // prep result
345  std::string res;
346  std::size_t pos=0;
347  // loop over occurences of "macro"
348  while(pos<rTexString.length()) {
349  std::size_t next=rTexString.find(rMacro,pos);
350  if(next==std::string::npos) break;
351  res.append(rTexString.substr(pos,next-pos));
352  std::string arg;
353  pos=next+rMacro.length();
354  if(!(pos+1<rTexString.length())) continue;
355  if(rTexString.at(pos)!='{') continue;
356  std::size_t aend=rTexString.find('}',pos);
357  if(aend==std::string::npos) break;
358  arg=rTexString.substr(pos+1,aend-pos-1);
359  arg=StringSubstitute(rSubst,"#1",arg);
360  res.append(arg);
361  pos=aend+1;
362  }
363  // get end
364  if(pos<rTexString.length())
365  res.append(rTexString.substr(pos));
366  // done
367  return res;
368 }
369 
370 
371 // mimique tex spacing
372 std::string TexSpacing(const std::string& rTexString) {
373  // prep result
374  std::string res;
375  std::size_t pos=0;
376  bool math=true;
377  // traverse string
378  while(pos<rTexString.length()) {
379  // explict: "\ "
380  if(pos+1 < rTexString.length())
381  if(rTexString.substr(pos,2)=="\\ ")
382  {pos+=2; res.append("&nbsp;"); continue;}
383  // explicit: "\,"
384  if(pos+1 < rTexString.length())
385  if(rTexString.substr(pos,2)=="\\,")
386  {pos+=2; res.append("&ensp;"); continue;}
387  // explicit: "\;"
388  if(pos+1 < rTexString.length())
389  if(rTexString.substr(pos,2)=="\\;")
390  {pos+=2; res.append("&ensp;"); continue;}
391  // explict: "\quad"
392  if(pos+4 < rTexString.length())
393  if(rTexString.substr(pos,5)=="\\quad")
394  {pos+=5; res.append("&nbsp;&nbsp;&nbsp;&nbsp;"); continue;}
395  // math swallow space
396  if(math)
397  if(isspace(rTexString.at(pos)))
398  { pos+=1; continue;}
399  // sense end of math mode
400  if(math)
401  if(pos+5 < rTexString.length())
402  if(rTexString.substr(pos,6)=="\\text{")
403  {pos+=6; math=false; continue;};
404  // sense end of text mode
405  if(!math)
406  if(rTexString.at(pos)=='}')
407  { pos+=1; math=true; continue;}
408  // default: copy
409  res.append(1,rTexString.at(pos));
410  pos+=1;
411  }
412  return res;
413 }
414 
415 // mimique tex scripts
416 std::string TexScripts(const std::string& rTexString) {
417  // prep result
418  std::string res;
419  std::size_t pos=0;
420  int c0=-1;
421  int cm1=-1;
422  int cm2=-1;
423  // traverse string
424  while(pos<rTexString.length()) {
425  // fill buffer
426  cm2=cm1; cm1=c0; c0=rTexString.at(pos);
427  // full script
428  if(cm1=='^' || cm1=='_')
429  if(c0=='{') {
430  std::size_t aend=rTexString.find('}',pos);
431  if(aend==std::string::npos) break;
432  std::string script=rTexString.substr(pos+1,aend-pos-1);
433  res.append(1,cm1);
434  res.append(script);
435  cm1=-1; cm2=-1; pos=aend+1;
436  continue;
437  }
438  // superscript uparrow
439  if(cm1=='^')
440  if(c0=='\\') {
441  size_t mpos=rTexString.find("\\uparrow",pos);
442  if(mpos==pos) {
443  res.append("<span class=\"faudes_sup\">&uarr;</span>");
444  cm1=-1; cm2=-1; pos+=8;
445  continue;
446  }
447  }
448  // superscript uparrow
449  if(cm1=='^')
450  if(c0=='\\') {
451  size_t mpos=rTexString.find("\\Uparrow",pos);
452  if(mpos==pos) {
453  res.append("<span class=\"faudes_sup\">&#x21e7;</span>");
454  cm1=-1; cm2=-1; pos+=8;
455  continue;
456  }
457  }
458  // digit subscript
459  if(cm1=='_')
460  if(isalpha(cm2))
461  if(isdigit(c0)) {
462  res.append(1,c0);
463  cm1=-1; cm2=-1; pos+=1;
464  continue;
465  }
466  // lower subscript
467  if(cm1=='_')
468  if(islower(c0))
469  if(isupper(cm2)) {
470  res.append(1,c0);
471  cm1=-1; cm2=-1; pos+=1;
472  continue;
473  }
474  // super star
475  if(cm1=='^')
476  if(c0=='*' || c0=='+') {
477  res.append(1,c0);
478  cm1=-1; cm2=-1; pos+=1;
479  continue;
480  }
481  // other script
482  if(cm1=='^' || cm1=='_') {
483  res.append(1,cm1);
484  res.append(1,c0);
485  cm1=-1; cm2=-1; pos+=1;
486  continue;
487  }
488  // plain copy default
489  if(c0!='_')
490  if(c0!='^') {
491  res.append(1,c0);
492  }
493  // continue
494  pos+=1;
495  }
496  return res;
497 }
498 
499 
500 // over all tex processing
501 void MathHtml(std::ostream* pStream, const std::string& rMathString) {
502  std::string buff=rMathString;
503  // xml quote
504  buff=StringSubstitute(buff,"&","&amp;");
505  // tex quote
506  buff=StringSubstitute(buff,"#","&hash;");
507  // greek letters
508  buff=StringSubstitute(buff,"\\Sigma","Sigma");
509  buff=StringSubstitute(buff,"\\sigma","o");
510  buff=StringSubstitute(buff,"\\delta","delta");
511  buff=StringSubstitute(buff,"\\epsilon","epsilon");
512  buff=StringSubstitute(buff,"\\omega","w");
513  // one-arg macros
514  buff=TexMacroSubstitute1(buff,"\\ProInv","Pinv#1");
515  buff=TexMacroSubstitute1(buff,"\\Pro","P#1");
516  buff=TexMacroSubstitute1(buff,"\\Closure","Closure(#1)");
517  buff=TexMacroSubstitute1(buff,"\\Prefix","Prefix(#1)");
518  // tex math spacing and plain text
519  buff=TexMacroSubstitute1(buff,"\\texttt","\\text{<tt>#1</tt>}");
520  buff=TexMacroSubstitute1(buff,"\\mathtt","\\text{<tt>#1</tt>}");
521  buff=TexMacroSubstitute1(buff,"\\textit","\\text{<i>#1</i>}");
522  buff=TexMacroSubstitute1(buff,"\\mathit","\\text{<i>#1</i>}");
523  buff=TexMacroSubstitute1(buff,"\\mathsf","\\text{<sf>#1</i>}");
524  buff=TexSpacing(buff);
525  // super- and subscripts
526  buff=TexScripts(buff);
527  // symbols
528  buff=StringSubstitute(buff,"\\{","{");
529  buff=StringSubstitute(buff,"\\}","}");
530  buff=StringSubstitute(buff,"\\[","[");
531  buff=StringSubstitute(buff,"\\]","]");
532  buff=StringSubstitute(buff,"=","&nbsp;=&nbsp;");
533  buff=StringSubstitute(buff,"class&nbsp;=&nbsp;","class="); // fix csss class
534  buff=StringSubstitute(buff,":&nbsp;=&nbsp;","&nbsp;:=&nbsp;"); //fix :=
535  buff=StringSubstitute(buff,"\\neq","&nbsp&ne;&nbsp;");
536  buff=StringSubstitute(buff,"\\lt","&nbsp;&lt;&nbsp;");
537  buff=StringSubstitute(buff,"\\gt","&nbsp;&gt;&nbsp;");
538  buff=StringSubstitute(buff,"\\le","&nbsp;&le;&nbsp;");
539  buff=StringSubstitute(buff,"\\ge","&nbsp;&ge;&nbsp;");
540  buff=StringSubstitute(buff,"\\emptyset","0");
541  buff=StringSubstitute(buff,"\\times","&nbsp;x&nbsp;");
542  buff=StringSubstitute(buff,"\\ldots","...");
543  buff=StringSubstitute(buff,"\\cdots","...");
544  buff=StringSubstitute(buff,"\\cdot",".");
545  buff=StringSubstitute(buff,"\\infty","&infin;");
546  buff=StringSubstitute(buff,"\\nin","&nbsp;&notin;&nbsp;");
547  buff=StringSubstitute(buff,"\\not\\in","&nbsp;&notin;&nbsp;");
548  buff=StringSubstitute(buff,"\\in","&nbsp;&isin;&nbsp;");
549  buff=StringSubstitute(buff,"\\subseteq","&nbsp;&sube;&nbsp;");
550  buff=StringSubstitute(buff,"\\subset","&nbsp;&sub;&nbsp;");
551  buff=StringSubstitute(buff,"\\supseteq","&nbsp;&supe;&nbsp;");
552  buff=StringSubstitute(buff,"\\supset","&nbsp;&sup;&nbsp;");
553  buff=StringSubstitute(buff,"\\cup","&cup;");
554  buff=StringSubstitute(buff,"\\dcup","&cup;"); // should be "&cup;&#775;" for "dot above"
555  buff=StringSubstitute(buff,"\\cap","&cap;");
556  buff=StringSubstitute(buff,"\\sup","sup");
557  buff=StringSubstitute(buff,"\\inf","inf");
558  buff=StringSubstitute(buff,"\\max","max");
559  buff=StringSubstitute(buff,"\\min","min");
560  buff=StringSubstitute(buff,"\\parallel","||");
561  buff=StringSubstitute(buff,"\\forall","&forall;&nbsp;");
562  buff=StringSubstitute(buff,"\\exists","&exist;&nbsp;");
563  buff=StringSubstitute(buff,"\\leftarrow","&larr;");
564  buff=StringSubstitute(buff,"\\rightarrow","&rarr;");
565  buff=StringSubstitute(buff,"\\leftrightarrow","&harr;");
566  buff=StringSubstitute(buff,"\\Leftarrow","&lArr;");
567  buff=StringSubstitute(buff,"\\Rightarrow","&rArr;");
568  buff=StringSubstitute(buff,"\\Leftrightarrow","&hArr;");
569  buff=StringSubstitute(buff,"\\uparrow","&uarr;");
570  buff=StringSubstitute(buff,"\\downarrow","&darr;");
571  buff=StringSubstitute(buff,"\\Uparrow","&#x21e7;");
572  buff=StringSubstitute(buff,"\\Downarrow","&#x21e9;");
573  // ie7 fallback symbols
574  buff=StringSubstitute(buff,"&isin;","<span class=\"faudes_fmath\">&isin;</span>");
575  buff=StringSubstitute(buff,"&notin;","<span class=\"faudes_fmath\">&notin;</span>");
576  buff=StringSubstitute(buff,"&exist;","<span class=\"faudes_fmath\">&exist;</span>");
577  buff=StringSubstitute(buff,"&forall;","<span class=\"faudes_fmath\">&forall;</span>");
578  buff=StringSubstitute(buff,"&cup;","<span class=\"faudes_fmath\">&cup;</span>");
579  buff=StringSubstitute(buff,"&dcup;","<span class=\"faudes_fmath\">&cup;</span>"); // see above
580  buff=StringSubstitute(buff,"&cap;","<span class=\"faudes_fmath\">&cap;</span>");
581  buff=StringSubstitute(buff,"&larr;","<span class=\"faudes_fmath\">&larr;</span>");
582  buff=StringSubstitute(buff,"&rarr;","<span class=\"faudes_fmath\">&rarr;</span>");
583  buff=StringSubstitute(buff,"&harr;","<span class=\"faudes_fmath\">&harr;</span>");
584  buff=StringSubstitute(buff,"&lArr;","<span class=\"faudes_fmath\">&lArr;</span>");
585  buff=StringSubstitute(buff,"&rArr;","<span class=\"faudes_fmath\">&rArr;</span>");
586  buff=StringSubstitute(buff,"&hArr;","<span class=\"faudes_fmath\">&hArr;</span>");
587  buff=StringSubstitute(buff,"&sub;","<span class=\"faudes_fmath\">&sub;</span>");
588  buff=StringSubstitute(buff,"&sube;","<span class=\"faudes_fmath\">&sube;</span>");
589  buff=StringSubstitute(buff,"&sup;","<span class=\"faudes_fmath\">&sup;</span>");
590  buff=StringSubstitute(buff,"&supe;","<span class=\"faudes_fmath\">&supe;</span>");
591  // done
592  *pStream << buff;
593 }
594 
595 
596 // ******************************************************************
597 // record pages
598 // ******************************************************************
599 
600 
601 // section lists (from reading rti/flx)
602 std::set< std::string > mExclLuaSections;
603 std::set< std::string > mInclLuaSections;
604 
605 // page data
606 class PageRecord {
607 public:
608  std::string mTitle;
609  std::string mChapter;
610  std::string mSection;
611  std::string mPage;
612  std::string mLink;
613  std::string mSummary;
614 };
615 
616 
617 // record all pages
618 std::vector<PageRecord> mAllPages;
619 
620 // record all pages within reference section (keys to lower)
621 std::map< std::string , std::map< std::string , PageRecord > > mRefSectPages;
622 
623 // extract page data (works with both, *.flx and *.ftoc)
625  // record my level
626  int clevel = rTr.Level();
627  // std::cerr << "process level " << clevel << "\n";
628  // token loop
629  while(true) {
630  // skip plain text
631  std::string text;
632  rTr.ReadCharacterData(text);
633  if(text.size()>0) continue;
634  // break on no token or end of my level
635  Token token;
636  if(!rTr.Peek(token)) break;
637  if(token.IsEnd() && !token.IsBegin() && rTr.Level()==clevel)
638  break;
639  // ignore irrelevant
640  if(!token.IsBegin("ReferencePage")) {
641  rTr.Get(token);
642  continue;
643  }
644  // take my section
645  rTr.ReadBegin("ReferencePage");
646  // extract page data
647  mFrefChapter="";
648  if(token.ExistsAttributeString("chapter"))
649  mFrefChapter=token.AttributeStringValue("chapter");
650  mFrefSection="";
651  if(token.ExistsAttributeString("section"))
652  mFrefSection=token.AttributeStringValue("section");
653  mFrefPage="";
654  if(token.ExistsAttributeString("page"))
655  mFrefPage=token.AttributeStringValue("page");
656  mFrefTitle="";
657  if(token.ExistsAttributeString("title"))
658  mFrefTitle=token.AttributeStringValue("title");
659  mFrefLink=ExtractBasename(rTr.FileName())+".html";;
660  if(token.ExistsAttributeString("link"))
661  mFrefLink=token.AttributeStringValue("link");
662  // find optional findexdoc
663  mFrefSummary="";
664  if(rTr.ExistsBegin("fsummary")) {
665  rTr.ReadBegin("fsummary");
667  rTr.ReadEnd("fsummary");
668  }
669  // autodetect misslabled index pages
670  if(mFrefPage=="") {
671  std::string indexfile=mFrefSection + "_index.fref";
672  std::transform(indexfile.begin(), indexfile.end(), indexfile.begin(), tolower);
673  if(ExtractFilename(rTr.FileName())==indexfile)
674  mFrefPage="0_Index";
675  }
676  // ensure page number for index page
677  if(mFrefPage=="index") mFrefPage="Index";
678  if(mFrefPage=="Index") mFrefPage="0_Index";
679  // autogenerate page name
680  if(mFrefPage=="") {
682  std::string title=mFrefTitle;
683  std::transform(mFrefTitle.begin(), mFrefTitle.end(), title.begin(), tolower);
684  std::string section=mFrefSection;
685  std::transform(mFrefSection.begin(), mFrefSection.end(), section.begin(), tolower);
686  std::size_t spos = title.find(section);
687  if(spos==0 && title.size()>section.size())
688  mFrefPage=mFrefPage.substr(section.size(),mFrefPage.size()-section.size());
689  for(spos=0; spos<mFrefPage.size(); spos++){
690  int c= mFrefPage.at(spos);
691  if(c==' ') continue;
692  if(c=='-') continue;
693  if(c=='_') continue;
694  break;
695  }
696  if(spos<mFrefPage.size())
697  mFrefPage=mFrefPage.substr(spos,mFrefPage.size()-spos);
698  if(mFrefPage=="Index") mFrefPage="";
699  }
700  // read end
701  rTr.ReadEnd("ReferencePage");
702  // report
703  // std::cerr << "ref2html: found chapter \"" << mFrefChapter << "\" section \"" << mFrefSection << "\"" << std::endl;
704  // record
705  PageRecord pagerec;
706  pagerec.mChapter = mFrefChapter;
707  pagerec.mSection = mFrefSection;
708  pagerec.mPage = mFrefPage;
709  pagerec.mTitle = mFrefTitle;
710  pagerec.mLink = mFrefLink;
711  pagerec.mSummary=mFrefSummary;
712  // normalize
713  std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
714  std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
715  std::transform(mFrefPage.begin(), mFrefPage.end(), mFrefPage.begin(), tolower);
716  // insert entry
717  if(mFrefChapter!="")
718  if(mFrefChapter!="none")
719  mAllPages.push_back(pagerec);
720  // insert entry to section pages of reference
721  if(mFrefChapter=="reference")
722  if(mFrefPage!="")
723  if(mFrefPage!="none")
725  }
726 }
727 
728 
729 // dump page records to include file
730 void DumpPages(TokenWriter& rTw) {
731  // loop records
732  std::vector<PageRecord>::iterator pit;
733  for(pit=mAllPages.begin(); pit!=mAllPages.end(); pit++) {
734  Token btag;
735  btag.SetEmpty("ReferencePage");
736  btag.InsAttributeString("title",pit->mTitle);
737  btag.InsAttributeString("chapter",pit->mChapter);
738  btag.InsAttributeString("section",pit->mSection);
739  btag.InsAttributeString("page",pit->mPage);
740  btag.InsAttributeString("link",pit->mLink);
741  // if we have no summary, that's it
742  if(pit->mSummary=="") {
743  rTw << btag;
744  continue;
745  }
746  // summary present
747  btag.ClrEnd();
748  rTw << btag;
749  rTw.WriteBegin("fsummary");
750  rTw.WriteCharacterData(pit->mSummary);
751  rTw.WriteEnd("fsummary");
752  rTw.WriteEnd("ReferencePage");
753  }
754 }
755 
756 
757 // ******************************************************************
758 // search for types
759 // ******************************************************************
760 
761 void ListTypesHtml(std::ostream* pIndexFile, const std::string& key="") {
762 
763  // table output
764  *pIndexFile << "<table class=\"registry_toc\">" << std::endl;
765  // traverse type registry
766  bool found=false;
767  for(TypeRegistry::Iterator tit=TypeRegistry::G()->Begin();
768  tit!=TypeRegistry::G()->End(); tit++) {
769  // test for exact key
770  if(key!="") {
771  std::string section= tit->second->Name();
772  std::transform(section.begin(), section.end(), section.begin(), tolower);
773  if(section!=key) continue;
774  }
775  // test for user doc
776  if(tit->second->TextDoc()=="") continue;
777  // table row
778  *pIndexFile << "<tr><td valign=\"top\">";
779  TypeHtml(pIndexFile,tit->second->Name());
780  *pIndexFile << "</td><td valign=\"top\">";
781  TypeHtml(pIndexFile,tit->second->TextDoc());
782  *pIndexFile << "</td></tr>" << std::endl;
783  // record success
784  found=true;
785  }
786  // no matches
787  if(!found) *pIndexFile << "<tr><td><i>no matches found</i></td></tr>" << std::endl;
788  // table output
789  *pIndexFile << "</table>" << std::endl;
790 }
791 
792 // ******************************************************************
793 // search for functions
794 // ******************************************************************
795 
796 void ListFunctionsHtml(std::ostream* pIndexFile, const std::string& key="") {
797 
798  // table output
799  *pIndexFile << "<table class=\"registry_toc\">" << std::endl;
800  // traverse function registry
801  bool found=false;
803  fit!=FunctionRegistry::G()->End(); fit++) {
804  // test for exact key
805  if(key!="") {
806  std::string section= fit->second->Name();
807  std::transform(section.begin(), section.end(), section.begin(), tolower);
808  if(section!=key) continue;
809  }
810  // test for user doc
811  if(fit->second->TextDoc()=="") continue;
812  // table row
813  *pIndexFile << "<tr><td valign=\"top\">";
814  FunctionHtml(pIndexFile,fit->second->Name());
815  *pIndexFile << "</td><td valign=\"top\">";
816  TypeHtml(pIndexFile,fit->second->TextDoc());
817  *pIndexFile << "</td></tr>" << std::endl;
818  // record success
819  found=true;
820  }
821  // no matches
822  if(!found) *pIndexFile << "<tr><td><i>no matches found</i></td></tr>" << std::endl;
823  // table output
824  *pIndexFile << "</table>" << std::endl;
825 }
826 
827 // ******************************************************************
828 // search for sections
829 // ******************************************************************
830 
831 void ListSectionsHtml(std::ostream* pIndexFile, const std::string& key="") {
832 
833  // here: use special key "luaext" to filter lua-extensions"
834 
835  // traverse pages
836  std::set< std::string > sections;
837  std::map< std::string , std::string > link;
838  std::map< std::string , std::string > summary;
839  std::vector< PageRecord >::iterator pit;
840  for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
841  std::string chap=pit->mChapter;
842  std::transform(chap.begin(), chap.end(), chap.begin(), tolower);
843  std::string sect=pit->mSection;
844  std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
845  std::string page=pit->mPage;
846  std::transform(page.begin(), page.end(), page.begin(), tolower);
847  page=PrettyPage(page);
848  // my chapter only
849  if(chap!="reference") continue;
850  if(sect=="none") continue;
851  if(sect=="") continue;
852  if(page!="index") continue;
853  // lua ext only
854  if(key=="luaext") {
855  if(mExclLuaSections.find(sect)!=mExclLuaSections.end()) continue;
856  if(mInclLuaSections.find(sect)==mInclLuaSections.end()) continue;
857  }
858  // get nice name
859  std::string pname = pit->mSection;
860  // use title as fallback summary
861  std::string psumm = pit->mSummary;
862  if(psumm=="") psumm = pit->mTitle;
863  // record
864  sections.insert(pname);
865  link[pname]=pit->mLink;
866  summary[pname]=psumm;
867  }
868 
869  // produce sorted index with corefaudes first
870  std::vector< std::string > sortvec;
871  if(sections.find("CoreFaudes")!=sections.end())
872  sortvec.push_back("CoreFaudes");
873  std::set< std::string >::iterator sit;
874  for(sit=sections.begin(); sit != sections.end(); sit++) {
875  if(*sit=="CoreFaudes") continue;
876  sortvec.push_back(*sit);
877  }
878 
879  // table output
880  *pIndexFile << "<table class=\"registry_toc\">" << std::endl;
881 
882  // populate table
883  std::vector< std::string >::iterator vit;
884  bool found=false;
885  for(vit=sortvec.begin(); vit != sortvec.end(); vit++) {
886  // get nice name
887  std::string sname = *vit;
888  std::string shtml = mReferencePrefix+link[sname];
889  std::string ssumm = summary[sname];
890  // table row
891  *pIndexFile << "<tr>" << std::endl;
892  *pIndexFile << "<td valign=\"top\"><a href=\"" << shtml << "\">" << sname << "</a></td>";
893  *pIndexFile << "<td valign=\"top\">";
894  *pIndexFile << ssumm;
895  *pIndexFile << "</td></tr>"<< std::endl;
896  // record success
897  found=true;
898  }
899  // no matches
900  if(!found) *pIndexFile << "<tr><td><i>no matches found</i></td></tr>" << std::endl;
901 
902  // table output
903  *pIndexFile << "</table>" << std::endl;
904 }
905 
906 
907 
908 
909 
910 // ******************************************************************
911 // Type index by keyword (aka section name)
912 // ******************************************************************
913 
914 void TypeIndexHtml(std::ostream* pIndexFile, const std::string& key="") {
915 
916  // traverse type registry
917  bool head=false;
918  for(TypeRegistry::Iterator tit=TypeRegistry::G()->Begin();
919  tit!=TypeRegistry::G()->End(); tit++)
920  {
921  // test for exact key
922  if(key!="") {
923  std::string section= tit->second->KeywordAt(0);
924  std::transform(section.begin(), section.end(), section.begin(), tolower);
925  if(section!=key) continue;
926  }
927  // get name and reference
928  std::string tyname = tit->second->Name();
929  std::string tyhtml = tit->second->HtmlDoc();
930  // no doc
931  if(tyhtml=="") continue;
932  if(tyhtml=="none") continue;
933  // head line
934  if(!head) {
935  head=true;
936  *pIndexFile << "<li class=\"registry_heading\">Types</li>" << std::endl;
937  }
938  // index entry for this type
939  ListItemHtml(pIndexFile, tyhtml, tyname);
940  }
941  // done
942  if(head) *pIndexFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
943 }
944 
945 // ******************************************************************
946 // Function index by keyword (aka plugin)
947 // ******************************************************************
948 
949 void FunctionIndexHtml(std::ostream* pIndexFile, const std::string& key="") {
950 
951  // have lower case key
952  std::string lkey=key;
953  std::transform(lkey.begin(), lkey.end(), lkey.begin(), tolower);
954 
955  // traverse function registry
956  bool head=false;
958  fit!=FunctionRegistry::G()->End(); fit++)
959  {
960  // test for key
961  if(lkey!="") {
962  std::string section= fit->second->KeywordAt(0);
963  std::transform(section.begin(), section.end(), section.begin(), tolower);
964  if(section!=lkey) continue;
965  }
966  // test for user doc
967  if(fit->second->TextDoc()=="") continue;
968  // index entry for this function
969  std::string fname = fit->second->Name();
970  std::string fhtml = fit->second->HtmlDoc();
971  if(fhtml=="") continue;
972  // head line
973  if(!head){
974  head=true;
975  *pIndexFile << "<li class=\"registry_heading\">Functions</li>" << std::endl;
976  }
977  // list entry: no doc
978  if(fhtml=="none") {
979  *pIndexFile << "<li class=\"registry_item\"> "<< fname << "</li>" << std::endl;
980  continue;
981  }
982  // list entry: link
983  ListItemHtml(pIndexFile, fhtml, fname);
984  }
985 
986  // done
987  if(head) *pIndexFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
988 
989 }
990 
991 // ******************************************************************
992 // Reference index by keyword (aka section)
993 // ******************************************************************
994 
995 void ReferenceIndexHtml(std::ostream* pIndexFile, const std::string& key="") {
996 
997  // prepare list of all sections
998  std::map< std::string , std::string > sectlink;
999  std::vector< PageRecord >::iterator pit;
1000  for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
1001  std::string chap=pit->mChapter;
1002  std::transform(chap.begin(), chap.end(), chap.begin(), tolower);
1003  std::string sect=pit->mSection;
1004  std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
1005  // my chapter only
1006  if(chap!="reference") continue;
1007  if(sect=="none") continue;
1008  if(sect=="") continue;
1009  // get nice name
1010  std::string pname = pit->mSection;
1011  // have link
1012  std::string phtml = sect+"_index.html";
1013  // record
1014  sectlink[pname]=phtml;
1015  }
1016 
1017  // produce sorted index, have corefaudes first
1018  std::vector< std::string > sections;
1019  if(sectlink["CoreFaudes"]!="") sections.push_back("CoreFaudes");
1020  std::map< std::string , std::string >::iterator sit;
1021  for(sit=sectlink.begin(); sit!=sectlink.end(); sit++) {
1022  std::string psect=sit->first;
1023  if(psect=="CoreFaudes") continue;
1024  sections.push_back(psect);
1025  }
1026 
1027  // sections headline
1028  if(sections.size()!=0)
1029  *pIndexFile << "<li class=\"registry_heading\">Sections</li>" << std::endl;
1030 
1031  // iterate sections
1032  std::size_t vit;
1033  for(vit=0; vit<sections.size(); vit++) {
1034  std::string psect=sections.at(vit);
1035  std::string plink=sectlink[psect];
1036  if(plink=="") continue;
1037  // find all pages within reference that match this section (keys to lower, skip index)
1038  std::string sect=psect;
1039  std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
1040  std::map< std::string , std::map< std::string , PageRecord > > ::iterator spit = mRefSectPages.find(sect);
1041  int pcnt=0;
1042  if(spit!=mRefSectPages.end()) {
1043  std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1044  for(;pit!=spit->second.end();pit++) {
1045  std::string ppage = pit->second.mPage;
1046  std::transform(ppage.begin(), ppage.end(), ppage.begin(), tolower);
1047  if(ppage=="index") continue;
1048  if(ppage=="0_index") continue;
1049  if(ppage=="00_index") continue;
1050  pcnt++;
1051  }
1052  }
1053  // case a) no pages: just a link
1054  if(pcnt==0) {
1055  ListItemHtml(pIndexFile, plink, psect);
1056  continue;
1057  }
1058  // case b) generate link for sub menu for pages (do this my self)
1059  *pIndexFile << "<li class=\"registry_pitem\">" << std::endl
1060  << "<a href=\"" << plink << "\">" << psect << "</a>" << std::endl
1061  << "<a href=\"" << plink << "\" class=\"registry_blinda\">&nbsp;</a>" << std::endl
1062  << "<ul>" << std::endl
1063  << "<li class=\"registry_heading\">" << psect << "</li>" << std::endl;
1064  std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1065  for(;pit!=spit->second.end();pit++) {
1066  // swallow page number
1067  std::string ppage = PrettyPage(pit->second.mPage);
1068  // normalize
1069  std::string ipage = ppage;
1070  std::transform(ipage.begin(), ipage.end(), ipage.begin(), tolower);
1071  // rename indes
1072  if(ipage=="index") ppage="Introduction";
1073  // page entry
1074  *pIndexFile << "<li class=\"registry_item\"><a href=\"" << pit->second.mLink << "\">"
1075  << ppage << "</a></li>" << std::endl;
1076  }
1077  // close page list
1078  *pIndexFile << "</ul></li>" << std::endl;
1079  }
1080 
1081  // sections done
1082  if(sections.size()!=0)
1083  *pIndexFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1084 
1085  // list types
1086  if(key!="") TypeIndexHtml(pIndexFile,key);
1087 
1088  // list functions
1089  if(key!="") FunctionIndexHtml(pIndexFile,key);
1090 }
1091 
1092 
1093 // ******************************************************************
1094 // Section index (aka bottom navigation for key section)
1095 // ******************************************************************
1096 
1097 
1098 void SectionIndexHtml(std::ostream* pIndexFile, const std::string& key) {
1099 
1100  // find all pages within reference that match this section (keys to lower, skip index)
1101  std::string sect=key;
1102  std::transform(sect.begin(), sect.end(), sect.begin(), tolower);
1103  std::string plink=sect+"_index.html";
1104  std::string psect=key;
1105  std::map< std::string , std::map< std::string , PageRecord > > ::iterator spit = mRefSectPages.find(sect);
1106  int pcnt=0;
1107  if(spit!=mRefSectPages.end()) {
1108  std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1109  for(;pit!=spit->second.end();pit++) {
1110  std::string ppage = pit->second.mPage;
1111  psect=pit->second.mSection;
1112  std::transform(ppage.begin(), ppage.end(), ppage.begin(), tolower);
1113  if(ppage=="index") continue;
1114  if(ppage=="0_index") continue;
1115  if(ppage=="00_index") continue;
1116  pcnt++;
1117  }
1118  }
1119 
1120  // bail out if there are no pages
1121  //if(pcnt==0) return;
1122 
1123  // tweak: key="" refers to the reference_index.html
1124  if(key=="") psect="Reference";
1125 
1126  // generate menu for pages
1127  *pIndexFile << "<li class=\"registry_heading\">" << psect << "</li>" << std::endl;
1128  std::map< std::string , PageRecord >::iterator pit = spit->second.begin();
1129  for(;pit!=spit->second.end();pit++) {
1130  // swallow page number
1131  std::string ppage = PrettyPage(pit->second.mPage);
1132  // normalize
1133  std::string ipage = ppage;
1134  std::transform(ipage.begin(), ipage.end(), ipage.begin(), tolower);
1135  // rename index
1136  if(ipage=="index") ppage="Introduction";
1137  // page entry
1138  *pIndexFile << "<li class=\"registry_item\"><a href=\"" << pit->second.mLink << "\">"
1139  << ppage << "</a></li>" << std::endl;
1140  }
1141 }
1142 
1143 
1144 // ******************************************************************
1145 // signature
1146 // ******************************************************************
1147 
1148 void SignatureHtml(std::ostream* pOutFile, std::string function) {
1149 
1150  // bail out on non existence
1151  if(!FunctionRegistry::G()->Exists(function)) return;
1152 
1153  // function definition
1154  const FunctionDefinition& fdef=FunctionRegistry::G()->Definition(function);
1155 
1156  // bail out if there is no signature
1157  if(fdef.VariantsSize()==0) return;
1158 
1159  // start signature box
1160  *pOutFile << "<div class=\"registry_signature\">" << std::endl;
1161  *pOutFile << "<h5><strong>Signature:</strong></h5>" << std::endl;
1162 
1163  // loop signatures
1164  for(int i=0; i< fdef.VariantsSize(); i++) {
1165  const Signature& sigi=fdef.Variant(i);
1166  *pOutFile << "<p>" << fdef.Name() << "(";
1167  // loop params
1168  for(int j=0; j < sigi.Size(); j++) {
1169  if(j!=0) *pOutFile << ", ";
1170  const Parameter& parj=sigi.At(j);
1171  *pOutFile << "<span>+" << Parameter::AStr(parj.Attribute()) << "+ ";
1172  TypeHtml(pOutFile,parj.Type());
1173  *pOutFile << " <i>" << parj.Name() << "</i></span>";
1174  }
1175  *pOutFile << ")</p>" << std::endl;
1176  }
1177 
1178 
1179  // close signature box
1180  *pOutFile << std::endl << "</div>" << std::endl;
1181 }
1182 
1183 // ******************************************************************
1184 // short doc
1185 // ******************************************************************
1186 
1187 void ShortdocHtml(std::ostream* pOutFile, std::string fname) {
1188 
1189  // its a function
1190  if(FunctionRegistry::G()->Exists(fname)) {
1191 
1192  // function definition
1193  const FunctionDefinition& fdef=FunctionRegistry::G()->Definition(fname);
1194 
1195  // stream doc
1196  //*pOutFile << "<div class=\"registry_signature\">" << std::endl;
1197  *pOutFile << "<p>" << fdef.TextDoc() << "</p>" << std::endl;
1198  //*pOutFile << "</div>" << std::endl;
1199 
1200  // stream signature
1201  SignatureHtml(pOutFile,fname);
1202  }
1203 
1204  // its a type
1205  if(TypeRegistry::G()->Exists(fname)) {
1206 
1207  // type definition
1208  const TypeDefinition& tdef=TypeRegistry::G()->Definition(fname);
1209 
1210  // stream doc
1211  //*pOutFile << "<div class=\"registry_signature\">" << std::endl;
1212  *pOutFile << "<p>" << tdef.TextDoc() << "<p>" << std::endl;
1213  //*pOutFile << "</div>" << std::endl;
1214 
1215  }
1216 
1217 }
1218 
1219 
1220 
1221 
1222 // ******************************************************************
1223 // record literature
1224 // ******************************************************************
1225 
1226 // record
1228 public:
1229  std::string mLabel;
1230  std::string mLink;
1231  std::string mAuthors;
1232  std::string mTitle;
1233  std::string mJournal;
1234  std::string mPublisher;
1235  std::string mYear;
1236 };
1237 
1238 // data
1239 std::map<std::string,LiteratureRecord> mLiterature;
1240 
1241 // extract all from a section
1243  // record my level
1244  int clevel = rTr.Level();
1245  // std::cerr << "process level " << clevel << "\n";
1246  // token loop
1247  while(true) {
1248  // skip plain text
1249  std::string text;
1250  rTr.ReadCharacterData(text);
1251  if(text.size()>0) continue;
1252  // break on no token or end of my level
1253  Token token;
1254  if(!rTr.Peek(token)) break;
1255  if(token.IsEnd() && !token.IsBegin() && rTr.Level()==clevel)
1256  break;
1257  // track where we are
1258  if(token.IsBegin("ReferencePage")) {
1259  mFrefChapter="";
1260  if(token.ExistsAttributeString("chapter"))
1261  mFrefChapter=token.AttributeStringValue("chapter");
1262  mFrefSection="";
1263  if(token.ExistsAttributeString("section"))
1264  mFrefSection=token.AttributeStringValue("section");
1265  std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
1266  std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
1267  // report
1268  // std::cerr << "ref2html: found chapter \"" << mFrefChapter << "\" section \"" << mFrefSection << "\"" << std::endl;
1269  }
1270  // ignore other tokens
1271  if(!token.IsBegin("fliterature")) {
1272  rTr.Get(token);
1273  continue;
1274  }
1275  // do my special tag: fliterature
1276  rTr.ReadBegin("fliterature");
1277  std::string label=token.AttributeStringValue("name");
1278  //std::cerr << "process literature " << label << "\n";
1279  LiteratureRecord litrec;
1280  litrec.mLabel=label;
1281  litrec.mLink = mFrefSection + "_index.html#lit_" + label;
1282  //process entries
1283  while(!rTr.Eos("fliterature")) {
1284  Token token;
1285  rTr.Peek(token);
1286  //std::cerr << "process literature peek " << token.Str() << "\n";
1287  if(token.IsBegin("fauthors")) {
1288  rTr.ReadBegin("fauthors");
1289  rTr.ReadSection(litrec.mAuthors);
1290  rTr.ReadEnd("fauthors");
1291  continue;
1292  }
1293  if(token.IsBegin("ftitle")) {
1294  rTr.ReadBegin("ftitle");
1295  rTr.ReadSection(litrec.mTitle);
1296  rTr.ReadEnd("ftitle");
1297  continue;
1298  }
1299  if(token.IsBegin("fjournal")) {
1300  rTr.ReadBegin("fjournal");
1301  rTr.ReadSection(litrec.mJournal);
1302  rTr.ReadEnd("fjournal");
1303  continue;
1304  }
1305  if(token.IsBegin("fyear")) {
1306  rTr.ReadBegin("fyear");
1307  rTr.ReadSection(litrec.mYear);
1308  rTr.ReadEnd("fyear");
1309  continue;
1310  }
1311  if(token.IsBegin("flink")) {
1312  rTr.ReadBegin("flink");
1313  rTr.ReadSection(litrec.mLink);
1314  rTr.ReadEnd("flink");
1315  continue;
1316  }
1317  if(token.IsBegin()) {
1318  rTr.ReadBegin(token.StringValue());
1319  rTr.ReadEnd(token.StringValue());
1320  continue;
1321  }
1322  rTr.Get(token);
1323  }
1324  // insert entry
1325  if(litrec.mLabel!="")
1326  mLiterature[litrec.mLabel]=litrec;
1327  // done
1328  rTr.ReadEnd("fliterature");
1329  }
1330 }
1331 
1332 
1333 // dump literature records to include file
1335  // loop records
1336  std::map<std::string,LiteratureRecord>::iterator lit;
1337  for(lit=mLiterature.begin(); lit!=mLiterature.end(); lit++) {
1338  Token btag;
1339  btag.SetBegin("fliterature");
1340  btag.InsAttributeString("name",lit->second.mLabel);
1341  rTw << btag;
1342  if(lit->second.mAuthors!="") {
1343  rTw.WriteBegin("fauthors");
1344  rTw.WriteCharacterData(lit->second.mAuthors);
1345  rTw.WriteEnd("fauthors");
1346  }
1347  if(lit->second.mTitle!="") {
1348  rTw.WriteBegin("ftitle");
1349  rTw.WriteCharacterData(lit->second.mTitle);
1350  rTw.WriteEnd("ftitle");
1351  }
1352  if(lit->second.mJournal!="") {
1353  rTw.WriteBegin("fjournal");
1354  rTw.WriteCharacterData(lit->second.mJournal);
1355  rTw.WriteEnd("fjournal");
1356  }
1357  if(lit->second.mPublisher!="") {
1358  rTw.WriteBegin("fpublisher");
1359  rTw.WriteCharacterData(lit->second.mPublisher);
1360  rTw.WriteEnd("fpublisher");
1361  }
1362  if(lit->second.mYear!="") {
1363  rTw.WriteBegin("fyear");
1364  rTw.WriteCharacterData(lit->second.mYear);
1365  rTw.WriteEnd("fyear");
1366  }
1367  if(lit->second.mLink!="") {
1368  rTw.WriteBegin("flink");
1369  rTw.WriteCharacterData(lit->second.mLink);
1370  rTw.WriteEnd("flink");
1371  }
1372  rTw.WriteEnd("fliterature");
1373  rTw.Endl();
1374  }
1375 }
1376 
1377 
1378 // html for (one) literature reference
1379 void LiteratureHtml(std::ostream* pStream, const std::string& rLabel="") {
1380  // loop records
1381  std::map<std::string,LiteratureRecord>::iterator lit;
1382  for(lit=mLiterature.begin(); lit!=mLiterature.end(); lit++) {
1383  // skip for no match
1384  if(rLabel!="")
1385  if(rLabel!=lit->second.mLabel) continue;
1386  // produce html
1387  *pStream << "<p>" << std::endl;
1388  *pStream << "<a id=\"" << "lit_" << lit->second.mLabel << "\">[" << lit->second.mLabel << "]</a>" << std::endl;
1389  *pStream << lit->second.mAuthors << ": ";
1390  *pStream << "<i>" << lit->second.mTitle << "</i>";
1391  if(lit->second.mJournal!="") *pStream << ", " << lit->second.mJournal;
1392  if(lit->second.mPublisher!="") *pStream << ", " << lit->second.mPublisher;
1393  if(lit->second.mYear!="") *pStream << ", " << lit->second.mYear;
1394  *pStream << ".</p>" << std::endl;
1395  }
1396 }
1397 
1398 
1399 // html for literature citation
1400 void CiteHtml(std::ostream* pStream, const std::string& rLabel) {
1401  // prepare
1402  std::string link="reference_literature.html";
1403  // find records
1404  std::map<std::string,LiteratureRecord>::iterator lit;
1405  lit=mLiterature.find(rLabel);
1406  if(lit!=mLiterature.end()) link=lit->second.mLink;
1407  // produce HTML
1408  *pStream << "<a href=\"" << link << "\">[" << rLabel << "]</a>";
1409 }
1410 
1411 
1412 // ******************************************************************
1413 // extract pages
1414 // ******************************************************************
1415 
1416 void XtractPages(TokenReader& src,const std::string& rDstDir) {
1417 
1418  // scan for reference page sections
1419  Token btag;
1420  while(src.Peek(btag)) {
1421  // skip tokens
1422  if(!btag.IsBegin("ReferencePage")) {
1423  src.Get(btag);
1424  continue;
1425  }
1426  // read begin tag
1427  src.ReadBegin("ReferencePage",btag);
1428  // extract title & friends
1429  mFrefTitle="libFAUDES Reference";
1430  if(btag.ExistsAttributeString("title"))
1431  mFrefTitle=btag.AttributeStringValue("title");
1432  mFrefChapter="Reference";
1433  if(btag.ExistsAttributeString("chapter"))
1434  mFrefChapter=btag.AttributeStringValue("chapter");
1435  mFrefSection="";
1436  if(btag.ExistsAttributeString("section"))
1437  mFrefSection=btag.AttributeStringValue("section");
1438  mFrefPage="";
1439  if(btag.ExistsAttributeString("page"))
1440  mFrefPage=btag.AttributeStringValue("page");
1441  // insist in page and section
1442  if(mFrefSection=="" || mFrefPage=="") {
1443  std::cerr << "ref2html: skipping undefined page at " << src.FileLine() << std::endl;
1444  src.ReadEnd("ReferencePage");
1445  continue;
1446  }
1447  // normalize & report
1448  std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
1449  std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
1450  std::transform(mFrefPage.begin(), mFrefPage.end(), mFrefPage.begin(), tolower);
1451  // dst file
1452  std::string dstfile=PrependPath(rDstDir,mFrefSection + "_" + mFrefPage +".fref");
1453  std::cerr << "ref2html: extracting page to \"" << dstfile << "\"" << std::endl;
1454  TokenWriter dst(dstfile);
1455  // copy section
1456  dst.Write(btag);
1457  std::string srctext;
1458  src.ReadSection(srctext);
1459  dst.WriteCharacterData(srctext);
1460  dst.WriteEnd("ReferencePage");
1461  // read end tag
1462  src.ReadEnd("ReferencePage");
1463  }
1464 }
1465 
1466 // ******************************************************************
1467 // extract files
1468 // ******************************************************************
1469 
1470 void XtractFiles(TokenReader& src,const std::string& rDstDir) {
1471 
1472  // scan for file sections
1473  Token btag;
1474  while(src.Peek(btag)) {
1475  // skip tokens
1476  if(!btag.IsBegin("ImageFile")) {
1477  src.Get(btag);
1478  continue;
1479  }
1480  // read begin tag
1481  src.ReadBegin("ImageFile",btag);
1482  std::string name=btag.AttributeStringValue("name");
1483  if(name==""){
1484  std::cerr << "ref2html: skipping undefined image file at " << src.FileLine() << std::endl;
1485  src.ReadEnd("ImageFile");
1486  continue;
1487  }
1488  // read data
1489  Token data;
1490  src.Get(data);
1491  if(!data.IsBinary()){
1492  std::cerr << "ref2html: skipping invalid image file at " << src.FileLine() << std::endl;
1493  src.ReadEnd("ImageFile");
1494  continue;
1495  }
1496  // dst file
1497  std::string dstfile;
1498  std::transform(name.begin(), name.end(), name.begin(), tolower);
1499  dstfile=PrependPath(rDstDir,"images");
1500  dstfile=PrependPath(dstfile,name);
1501  std::cerr << "ref2html: extracting image file to \"" << dstfile << "\"" << std::endl;
1502  // setup stream
1503  std::fstream fsout;
1504  fsout.exceptions(std::ios::badbit|std::ios::failbit);
1505  try{
1506  fsout.open(dstfile.c_str(), std::ios::out | std::ios::binary);
1507  fsout.write(data.StringValue().c_str(),data.StringValue().size());
1508  fsout.close();
1509  }
1510  catch (std::ios::failure&) {
1511  std::cerr << "ref2html: file io error when writing \"" << dstfile << "\"" << std::endl;
1512  }
1513  // read end tag
1514  src.ReadEnd("ImageFile");
1515  }
1516 }
1517 
1518 // ******************************************************************
1519 // luafaudes index
1520 // ******************************************************************
1521 
1522 void LuafaudesIndexHtml(std::ostream* pIndexFile) {
1523 
1524  // prepare list of all sections
1525  std::map< std::string , std::string > pages;
1526  std::vector< PageRecord >::iterator pit;
1527  for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
1528  // my chapter only
1529  if(pit->mChapter!="luafaudes") continue;
1530  if(pit->mSection=="none") continue;
1531  if(pit->mSection=="") continue;
1532  if(pit->mPage=="") continue;
1533  // get nice name
1534  std::string pname = pit->mPage;
1535  // have link
1536  std::string phtml = pit->mLink;
1537  // record
1538  pages[pname]=phtml;
1539  }
1540  // produce sorted index
1541  std::map< std::string , std::string >::iterator sit;
1542  for(sit=pages.begin(); sit!=pages.end(); sit++) {
1543  // have entry
1544  ListItemHtml(pIndexFile,sit->second, sit->first);
1545  }
1546  // empty
1547  if(pages.size()==0) {
1548  *pIndexFile << "<li class=\"registry_item\">" << "none" << "</li>" << std::endl;
1549  }
1550 }
1551 
1552 // ******************************************************************
1553 // process current section
1554 // ******************************************************************
1555 
1557 
1558  // record my level/mode
1559  int clevel = rTr.Level();
1560 
1561  // std::cerr << "process level " << clevel << "\n";
1562 
1563  // token copy loop
1564  while(true) {
1565  // see whether we can grab and copy some plain text
1566  std::string text;
1567  rTr.ReadCharacterData(text);
1568  if(text.size()>0) {
1569  //std::cerr << "copy text \"" << text << "\"\n";
1570  rTw.WriteCharacterData(text);
1571  continue;
1572  }
1573  // break on no token or end of my level
1574  Token token;
1575  if(!rTr.Peek(token)) break;
1576  if(token.IsEnd() && !token.IsBegin() && rTr.Level()==clevel)
1577  break;
1578  // do my special tags: ftype
1579  if(token.IsBegin("ftype")) {
1580  std::string ftype;
1581  rTr.ReadText("ftype",ftype);
1582  TypeHtml(rTw.Streamp(),ftype);
1583  continue;
1584  }
1585  // do my special tags: ffnct
1586  if(token.IsBegin("ffnct")) {
1587  std::string ffnct;
1588  rTr.ReadText("ffnct",ffnct);
1589  FunctionHtml(rTw.Streamp(),ffnct);
1590  continue;
1591  }
1592  // do my special tags: fimage
1593  if(token.IsBegin("fimage")) {
1594  rTr.ReadBegin("fimage", token);
1595  std::string fsrc=token.AttributeStringValue("fsrc");
1596  fsrc = StringSubstitute(fsrc,"FAUDES_IMAGES/",""); // be nice
1597  fsrc = ExtractBasename(fsrc); // be even niecer
1598  ImageHtml(rTw.Streamp(),fsrc);
1599  rTr.ReadEnd("fimage");
1600  continue;
1601  }
1602  // do my special tags: dmath
1603  if(token.IsBegin("fdmath")) {
1604  rTr.ReadBegin("fdmath", token);
1605  std::string mtext;
1606  rTr.ReadCharacterData(mtext);
1607  *rTw.Streamp() << "<span class=\"faudes_dmath\">";
1608  MathHtml(rTw.Streamp(),mtext);
1609  *rTw.Streamp()<< "</span>";
1610  rTr.ReadEnd("fdmath");
1611  continue;
1612  }
1613  // do my special tags: dmath
1614  if(token.IsBegin("fimath")) {
1615  rTr.ReadBegin("fimath", token);
1616  std::string mtext;
1617  rTr.ReadCharacterData(mtext);
1618  *rTw.Streamp()<< "<span class=\"faudes_imath\">";
1619  MathHtml(rTw.Streamp(),mtext);
1620  *rTw.Streamp()<< "</span>";
1621  rTr.ReadEnd("fimath");
1622  continue;
1623  }
1624  // do my special tags: ffnct_reference
1625  if(token.IsBegin("ffnct_reference")) {
1626  rTr.ReadBegin("ffnct_reference", token);
1627  std::string ffnct = token.AttributeStringValue("name");
1628  *rTw.Streamp() << "<div class=\"registry_function\"> " << std::endl;
1629  *rTw.Streamp() << "<h2>" << "<a id=\"" << ffnct << "\">" << ffnct << "</a></h2>" << std::endl;
1630  ShortdocHtml(rTw.Streamp(),ffnct);
1631  ProcessSection(rTw,rTr);
1632  *rTw.Streamp() << "</div>" << std::endl;
1633  rTr.ReadEnd("ffnct_reference");
1634  continue;
1635  }
1636  // do my special tags: ftype_reference
1637  if(token.IsBegin("ftype_reference")) {
1638  rTr.ReadBegin("ftype_reference", token);
1639  std::string ftype = token.AttributeStringValue("name");
1640  *rTw.Streamp() << "<div class=\"registry_type\"> " << std::endl;
1641  *rTw.Streamp() << "<h2>" << "<a id=\"" << ftype << "\">" << ftype << "</a></h2>" << std::endl;
1642  ShortdocHtml(rTw.Streamp(),ftype);
1643  ProcessSection(rTw,rTr);
1644  *rTw.Streamp() << "</div>" << std::endl;
1645  rTr.ReadEnd("ftype_reference");
1646  continue;
1647  }
1648  // do my special tags: fdetails
1649  if(token.IsBegin("fdetails")) {
1650  rTr.ReadBegin("fdetails", token);
1651  *rTw.Streamp() << "<h5>Detailed description:</h5>";
1652  rTr.ReadEnd("fdetails");
1653  continue;
1654  }
1655  // do my special tags: fconditions
1656  if(token.IsBegin("fconditions")) {
1657  rTr.ReadBegin("fconditions", token);
1658  *rTw.Streamp() << "<h5>Parameter Conditions:</h5>";
1659  rTr.ReadEnd("fconditions");
1660  continue;
1661  }
1662  // do my special tags: fexample
1663  if(token.IsBegin("fexample")) {
1664  rTr.ReadBegin("fexample", token);
1665  *rTw.Streamp() << "<h5>Example:</h5>";
1666  rTr.ReadEnd("fexample");
1667  continue;
1668  }
1669  // do my special tags: falltypes
1670  if(token.IsBegin("falltypes")) {
1671  rTr.ReadBegin("falltypes", token);
1672  ListTypesHtml(rTw.Streamp());
1673  rTr.ReadEnd("falltypes");
1674  continue;
1675  }
1676  // do my special tags: fallfncts
1677  if(token.IsBegin("fallfncts")) {
1678  rTr.ReadBegin("fallfncts", token);
1679  ListFunctionsHtml(rTw.Streamp());
1680  rTr.ReadEnd("fallfncts");
1681  continue;
1682  }
1683  // do my special tags: fallsects
1684  if(token.IsBegin("fallsects")) {
1685  rTr.ReadBegin("fallsects", token);
1686  ListSectionsHtml(rTw.Streamp());
1687  rTr.ReadEnd("fallsects");
1688  continue;
1689  }
1690  // do my special tags: fluasects
1691  if(token.IsBegin("fluasects")) {
1692  rTr.ReadBegin("fluasects", token);
1693  ListSectionsHtml(rTw.Streamp(),"luaext");
1694  rTr.ReadEnd("fluasects");
1695  continue;
1696  }
1697  // do my special tags: fliteratur (list all)
1698  if(token.IsBegin("falllit")) {
1699  rTr.ReadBegin("falllit");
1700  LiteratureHtml(rTw.Streamp());
1701  rTr.ReadEnd("falllit");
1702  continue;
1703  }
1704  // do my special tags: fliteratur (definition of)
1705  if(token.IsBegin("fliterature")) {
1706  rTr.ReadBegin("fliterature", token);
1707  std::string label=token.AttributeStringValue("name");
1708  LiteratureHtml(rTw.Streamp(),label);
1709  rTr.ReadEnd("fliterature");
1710  continue;
1711  }
1712  // do my special tags: fcontributors
1713  if(token.IsBegin("fcontributors")) {
1714  rTr.ReadBegin("fcontributors");
1715  *rTw.Streamp() << ContributorsString();
1716  rTr.ReadEnd("fcontributors");
1717  continue;
1718  }
1719  // do my special tags: flink
1720  if(token.IsBegin("fcite")) {
1721  rTr.ReadBegin("fcite", token);
1722  std::string label=token.AttributeStringValue("name");
1723  CiteHtml(rTw.Streamp(),label);
1724  rTr.ReadEnd("fcite");
1725  continue;
1726  }
1727  // do my special tags: fix br for HTML
1728  if(token.IsBegin("br")) {
1729  rTr.ReadBegin("br");
1730  Token etag;
1731  rTr.Peek(etag);
1732  if(etag.IsEnd("br")) rTr.ReadEnd("br"); // optionally accept balanced <br>
1733  token.ClrEnd();
1734  token.PreceedingSpace("n");
1735  rTw.Write(token); // intentionall write unbalanced <br> for HTML
1736  continue;
1737  }
1738  // do my special tags: fsummary
1739  if(token.IsBegin("fsummary")) {
1740  rTr.ReadBegin("fsummary");
1741  rTr.ReadEnd("fsummary");
1742  continue;
1743  }
1744  // get token to do my special attributes
1745  rTr.Get(token);
1746  //std::cerr << "copy token (lv " << rTr.Level() << "): " << token.Str() << "\n";
1747  // sense chapter classes
1748  if(token.ExistsAttributeString("ftcclass")) {
1749  mThisChapterClass=token.AttributeStringValue("ftcclass");
1750  token.ClrAttribute("ftcclass");
1751  }
1752  if(token.ExistsAttributeString("focclass")) {
1753  mOtherChapterClass=token.AttributeStringValue("focclass");
1754  token.ClrAttribute("focclass");
1755  }
1756  if(token.ExistsAttributeString("fxcclass")) {
1757  mExitChapterClass=token.AttributeStringValue("fxcclass");
1758  token.ClrAttribute("fxcclass");
1759  }
1760  // chapter attribute
1761  if(token.ExistsAttributeString("fchapter")) {
1762  std::string chapter = token.AttributeStringValue("fchapter");
1763  std::string cclass=mOtherChapterClass;
1764  if(chapter==mFrefChapter) cclass=mThisChapterClass;
1765  if(chapter=="exit") cclass=mExitChapterClass;
1766  token.InsAttributeString("class",cclass);
1767  token.ClrAttribute("fchapter");
1768  }
1769  // fhref attribute: ref only
1770  if(token.ExistsAttributeString("fhref") && mStandaloneReference) {
1771  std::string href = token.AttributeStringValue("fhref");
1772  href = StringSubstitute(href,"FAUDES_BOOKS/",mBooksPrefix);
1773  href = StringSubstitute(href,"FAUDES_CHAPTERS/",mChaptersPrefix);
1774  href = StringSubstitute(href,"FAUDES_IMAGES/",mImagePrefix);
1775  href = StringSubstitute(href,"FAUDES_REFERENCE/",mReferencePrefix);
1776  href = StringSubstitute(href,"FAUDES_CSOURCE/",mCsourceLink);
1777  href = StringSubstitute(href,"FAUDES_LUAFAUDES/",mLuafaudesLink);
1778  href = StringSubstitute(href,"FAUDES_ONLINE",mFaudesLink);
1779  href = StringSubstitute(href,"FAUDES_GETLINUX",mDownloadLink+"#Packages");
1780  href = StringSubstitute(href,"FAUDES_GETMSWIN",mDownloadLink+"#Packages");
1781  href = StringSubstitute(href,"DESTOOL_ONLINE",mDestoolLink);
1782  token.InsAttributeString("href",href);
1783  token.ClrAttribute("fhref");
1784  }
1785  // fhref attribute
1786  if(token.ExistsAttributeString("fhref") && !mStandaloneReference) {
1787  std::string href = token.AttributeStringValue("fhref");
1788  href = StringSubstitute(href,"FAUDES_BOOKS/",mBooksPrefix);
1789  href = StringSubstitute(href,"FAUDES_CHAPTERS/",mChaptersPrefix);
1790  href = StringSubstitute(href,"FAUDES_IMAGES/",mImagePrefix);
1791  href = StringSubstitute(href,"FAUDES_REFERENCE/",mReferencePrefix);
1792  href = StringSubstitute(href,"FAUDES_CSOURCE/",mCsourcePrefix);
1793  href = StringSubstitute(href,"FAUDES_LUAFAUDES/",mLuafaudesPrefix);
1794  href = StringSubstitute(href,"FAUDES_ONLINE",mFaudesLink);
1795  href = StringSubstitute(href,"FAUDES_GETLINUX",mDownloadLink+"#Packages");
1796  href = StringSubstitute(href,"FAUDES_GETMSWIN",mDownloadLink+"#Packages");
1797  href = StringSubstitute(href,"DESTOOL_ONLINE",mDestoolLink);
1798  token.InsAttributeString("href",href);
1799  token.ClrAttribute("fhref");
1800  }
1801  // fsrc attribute
1802  if(token.ExistsAttributeString("fsrc")) {
1803  std::string fsrc = token.AttributeStringValue("fsrc");
1804  fsrc = StringSubstitute(fsrc,"FAUDES_IMAGES/",mImagePrefix);
1805  fsrc = StringSubstitute(fsrc,"FAUDES_CSOURCE/",mCsourcePrefix);
1806  fsrc = StringSubstitute(fsrc,"FAUDES_LUAFAUDES/",mLuafaudesPrefix);
1807  token.InsAttributeString("src",fsrc);
1808  token.ClrAttribute("fsrc");
1809  }
1810  token.PreceedingSpace("n");
1811  rTw.Write(token);
1812  }
1813 }
1814 
1815 
1816 // ******************************************************************
1817 // reference page
1818 // ******************************************************************
1819 
1820 void RefpageHtml(std::ostream* pOutFile, std::string inputfile) {
1821 
1822  // setup token io
1823  TokenReader src(inputfile);
1824  TokenWriter dst(*pOutFile);
1825 
1826  // find the reference page section
1827  Token btag;
1828  src.SeekBegin("ReferencePage");
1829  src.ReadBegin("ReferencePage",btag);
1830 
1831  // extract title & friends
1832  mFrefTitle="libFAUDES Reference";
1833  if(btag.ExistsAttributeString("title"))
1834  mFrefTitle=btag.AttributeStringValue("title");
1835  mFrefChapter="";
1836  if(btag.ExistsAttributeString("chapter"))
1837  mFrefChapter=btag.AttributeStringValue("chapter");
1838  mFrefSection="";
1839  if(btag.ExistsAttributeString("section"))
1840  mFrefSection=btag.AttributeStringValue("section");
1841  std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
1842  std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
1843 
1844  // report
1845  // std::cerr << "ref2html: found chapter \"" << mFrefChapter << "\" section \"" << mFrefSection << "\"" << std::endl;
1846 
1847  // generate generic html header
1848  dst.Flush();
1849  HeaderHtml(pOutFile);
1850 
1851  // begin body
1852  dst.Flush();
1853 
1854  // include chapter level navigation
1855  if(mChapterFile!="") {
1856  //std::cerr << "using " << mChapterFile << std::endl;
1858  ProcessSection(dst,inc);
1859  }
1860 
1861  // include section level navigation, part 1
1862  if(mFrefChapter=="reference") {
1863  *pOutFile << "<table id=\"registry_page\">" << std::endl;
1864  *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1865  *pOutFile << "<td id=\"registry_index\">" << std::endl;
1866  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1867  *pOutFile << "<li class=\"registry_heading\">libFAUDES</li>" << std::endl;
1868  ListItemHtml(pOutFile,"reference_index.html", "Reference");
1869  ListItemHtml(pOutFile,"reference_types.html", "Type Index");
1870  ListItemHtml(pOutFile,"reference_functions.html", "Function Index");
1871  ListItemHtml(pOutFile,"reference_literature.html", "Literature");
1872  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1873  ReferenceIndexHtml(pOutFile, mFrefSection);
1874  *pOutFile << "</ul></td>" << std::endl;
1875  *pOutFile << "<td id=\"registry_content\">" << std::endl;
1876  }
1877 
1878  // include section level navigation, part 1
1879  if(mFrefChapter=="luafaudes") {
1880  *pOutFile << "<table id=\"registry_page\">" << std::endl;
1881  *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1882  *pOutFile << "<td id=\"registry_index\">" << std::endl;
1883  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1884  *pOutFile << "<li class=\"registry_heading\">luafaudes</li>" << std::endl;
1885  *pOutFile
1886  << "<script language=\"JavaScript\"> var luafaudes=function() { "
1887  << " popupWin = window.open('luafaudes_repl.html','open_window',"
1888  << " 'resizable,dependent, width=720, height=480, left=0, top=0'); } "
1889  << "</script>" << std::endl;
1890  ListItemHtml(pOutFile,"index.html", "Introduction");
1891  ListItemHtml(pOutFile,"javascript:luafaudes();", "Lua-Console");
1892  ListItemHtml(pOutFile,"faudes_luaext.html", "Lua-Extensions");
1893  ListItemHtml(pOutFile,"faudes_luatech.html", "Technical Detail");
1894  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1895  *pOutFile << "<li class=\"registry_heading\">Tutorials</li>" << std::endl;
1896  LuafaudesIndexHtml(pOutFile);
1897  *pOutFile << "</ul></td>" << std::endl;
1898  *pOutFile << "<td id=\"registry_content\">" << std::endl;
1899  }
1900 
1901  // process src
1902  ProcessSection(dst,src);
1903  src.ReadEnd("ReferencePage");
1904  dst.Flush();
1905 
1906  // track bottom line
1907  bool bottom=false;
1908 
1909  // include section level navigation, part 2
1910  if(mFrefChapter=="reference") {
1911  BottomLineHtml(pOutFile);
1912  bottom=true;
1913  *pOutFile << "</td>" << std::endl;
1914  *pOutFile << "</tr>" << std::endl;
1915  *pOutFile << "</table>" << std::endl;
1916  }
1917 
1918  // include section level navigation, part 2
1919  if(mFrefChapter=="luafaudes") {
1920  BottomLineHtml(pOutFile);
1921  bottom=true;
1922  *pOutFile << "</td>" << std::endl;
1923  *pOutFile << "</tr>" << std::endl;
1924  *pOutFile << "</table>" << std::endl;
1925  }
1926 
1927  // include section level navigation, part 3
1928  if(mFrefChapter=="reference") {
1929  *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
1930  *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
1931  *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
1932  *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
1933  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1934  SectionIndexHtml(pOutFile,mFrefSection);
1935  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1936  ListItemHtml(pOutFile,"#", "Top of Page");
1937  *pOutFile << "</ul></div>" << std::endl;
1938  }
1939 
1940  // include section level navigation, part 3
1941  if(mFrefChapter=="luafaudes" && mFrefSection=="tutorials") {
1942  *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
1943  *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
1944  *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
1945  *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
1946  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1947  *pOutFile << "<li class=\"registry_heading\">luafaudes</li>" << std::endl;
1948  *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luafaudes.html\">Introduction</a></li>" << std::endl;
1949  *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luaext.html\">Lua-Extansions</a></li>" << std::endl;
1950  *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luatech.html\">Techn. Details</a></li>" << std::endl;
1951  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1952  *pOutFile << "<li class=\"registry_item\"><a href=\"#\">Top of Page</a></li>" << std::endl;
1953  *pOutFile << "</ul></div>" << std::endl;
1954  }
1955 
1956  // bottom line
1957  if(!bottom) BottomLineHtml(pOutFile);
1958 
1959  // generic footer
1960  FooterHtml(pOutFile);
1961 
1962 }
1963 
1964 
1965 
1966 // ******************************************************************
1967 // Doxygen header and footer
1968 // ******************************************************************
1969 
1970 void DoxygenHeader(std::ostream* pOutFile) {
1971 
1972  // setup token io
1973  TokenWriter dst(*pOutFile);
1974 
1975  // configure
1976  mFrefTitle="C++ API";
1977  mFrefChapter="cppapi";
1978  mFrefSection="none";
1979 
1980  // generate generic html header
1981  dst.Flush();
1982  HeaderHtml(pOutFile);
1983 
1984  // include chapter level navigation
1985  if(mChapterFile!="") {
1987  ProcessSection(dst,inc);
1988  }
1989 
1990  // include section level navigation, part 1
1991  *pOutFile << "<table id=\"registry_page\">" << std::endl;
1992  *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1993  *pOutFile << "<td id=\"registry_index\">" << std::endl;
1994  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1995  *pOutFile << "<li class=\"registry_heading\">libFAUDES</li>" << std::endl;
1996  ListItemHtml(pOutFile, "index.html", "C++ API");
1997  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1998  *pOutFile << "<li class=\"registry_heading\">Sections</li>" << std::endl;
1999  ListItemHtml(pOutFile, "group__ContainerClasses.html", "Sets");
2000  ListItemHtml(pOutFile, "group__GeneratorClasses.html", "Generators");
2001  ListItemHtml(pOutFile, "group__GeneratorFunctions.html", "Functions");
2002  ListItemHtml(pOutFile, "group__AllPlugins.html", "PlugIns");
2003  ListItemHtml(pOutFile, "group__Tutorials.html", "Tutorials");
2004  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2005  *pOutFile << "<li class=\"registry_heading\">Index</li>" << std::endl;
2006  ListItemHtml(pOutFile, "classes.html", "Classes");
2007  ListItemHtml(pOutFile, "files.html", "Files");
2008  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2009  *pOutFile << "</ul></td>" << std::endl;
2010  *pOutFile << "<td id=\"registry_content\">" << std::endl;
2011 }
2012 
2013 
2014 void DoxygenFooter(std::ostream* pOutFile) {
2015 
2016  // setup token io
2017  TokenWriter dst(*pOutFile);
2018 
2019  // configure
2020  mFrefTitle="C++ API";
2021  mFrefChapter="cppapi";
2022  mFrefSection="none";
2023 
2024  // include section level navigation, part 2
2025  BottomLineHtml(pOutFile);
2026  *pOutFile << "</td>" << std::endl;
2027  *pOutFile << "</tr>" << std::endl;
2028  *pOutFile << "</table>" << std::endl;
2029 
2030  // include section level navigation, part 3
2031  *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
2032  *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
2033  *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
2034  *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
2035  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
2036  *pOutFile << "<li class=\"registry_heading\">C++ API</li>" << std::endl;
2037  *pOutFile << "<li class=\"registry_item\"><a href=\"index.html\">Introduction</a></li>" << std::endl;
2038  *pOutFile << "<li class=\"registry_item\"><a href=\"group__ContainerClasses.html\">Sets</a></li>" << std::endl;
2039  *pOutFile << "<li class=\"registry_item\"><a href=\"group__GeneratorClasses.html\">Generators</a></li>" << std::endl;
2040  *pOutFile << "<li class=\"registry_item\"><a href=\"group__GeneratorFunctions.html\">Functions</a></li>" << std::endl;
2041  *pOutFile << "<li class=\"registry_item\"><a href=\"group__AllPlugins.html\">PlugIns</a></li>" << std::endl;
2042  *pOutFile << "<li class=\"registry_item\"><a href=\"group__Tutorials.html\">Tutorials</a></li>" << std::endl;
2043  *pOutFile << "<li class=\"registry_item\"><a href=\"classes.html\">Classes</a></li>" << std::endl;
2044  *pOutFile << "<li class=\"registry_item\"><a href=\"files.html\">Files</a></li>" << std::endl;
2045  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2046  *pOutFile << "<li class=\"registry_item\"><a href=\"#\">Top of Page</a></li>" << std::endl;
2047  *pOutFile << "</ul></div>" << std::endl;
2048 
2049  // end page
2050  dst.Flush();
2051  FooterHtml(pOutFile);
2052 
2053 }
2054 
2055 // ******************************************************************
2056 // command line ui
2057 // ******************************************************************
2058 
2059 
2060 int main(int argc, char *argv[]) {
2061 
2062  // local config
2063  bool dotoc=false;
2064  bool dodhd=false;
2065  bool dodft=false;
2066  bool xpage=false;
2067 
2068  // min args
2069  if(argc < 3) usage_exit();
2070 
2071  // primitive commad line parsing
2072  int i;
2073  for(i=1; i<argc; i++) {
2074  std::string option(argv[i]);
2075  // option: rti file
2076  if(option=="-rti") {
2077  i++; if(i>=argc) usage_exit();
2078  mRtiFile=argv[i];
2079  continue;
2080  }
2081  // option: flx file
2082  if(option=="-flx") {
2083  i++; if(i>=argc) usage_exit();
2084  mFlxFile=argv[i];
2085  continue;
2086  }
2087  // option: css file
2088  if(option=="-css") {
2089  i++; if(i>=argc) usage_exit();
2090  mCssFile=argv[i];
2091  continue;
2092  }
2093  // option: navigation include
2094  if(option=="-cnav") {
2095  i++; if(i>=argc) usage_exit();
2096  mChapterFile=argv[i];
2097  continue;
2098  }
2099  // option: toc include
2100  if(option=="-inc") {
2101  i++; if(i>=argc) usage_exit();
2102  mIncludeFile=argv[i];
2103  continue;
2104  }
2105  // option: target prefix
2106  if(option=="-rel") {
2107  i++; if(i>=argc) usage_exit();
2108  ChaptersPrefix(argv[i]);
2109  continue;
2110  }
2111  // option: overwrite chapter
2112  if(option=="-chapter") {
2113  i++; if(i>=argc) usage_exit();
2114  mFrefChapter=argv[i];
2115  continue;
2116  }
2117  // option: overwrite section
2118  if(option=="-section") {
2119  i++; if(i>=argc) usage_exit();
2120  mFrefSection=argv[i];
2121  continue;
2122  }
2123  // option: extract multiple pages
2124  if(option=="-extract") {
2125  if(i+2!=argc-1) usage_exit();
2126  xpage=true;
2127  break;
2128  }
2129  // option: generate toc (break)
2130  if(option=="-toc") {
2131  i++; if(i+1>=argc) usage_exit();
2132  dotoc=true;
2133  mDstFile = argv[argc-1];
2134  break;
2135  }
2136  // option: generate doxygen header (break)
2137  if(option=="-doxheader") {
2138  i++; if(i>=argc) usage_exit();
2139  dodhd=true;
2140  mDstFile = argv[argc-1];
2141  break;
2142  }
2143  // option: generate doxygen footer (break)
2144  if(option=="-doxfooter") {
2145  i++; if(i>=argc) usage_exit();
2146  dodft=true;
2147  mDstFile = argv[argc-1];
2148  break;
2149  }
2150  // option: generate standalone reference
2151  if(option=="-app") {
2152  mStandaloneReference=true;
2153  continue;
2154  }
2155  // option: help
2156  if((option=="-?") || (option=="--help")) {
2157  usage_exit();
2158  continue;
2159  }
2160  // option: unknown
2161  if(option.size()>1)
2162  if(option.at(0)=='-') {
2163  usage_exit("unknown option " + option);
2164  continue;
2165  }
2166  // non-option: break
2167  break;
2168  }
2169 
2170  // figure source
2171  for(;i<argc-1; i++) {
2172  std::string option(argv[i]);
2173  if(option.size()>1)
2174  if(option.at(0)=='-') {
2175  usage_exit("missplaced/unknown option " + option);
2176  continue;
2177  }
2178  mSrcFiles.insert(option);
2179  }
2180 
2181  // figure destination
2182  for(;i<argc; i++) {
2183  std::string option(argv[i]);
2184  if(option.size()>1)
2185  if(option.at(0)=='-') {
2186  usage_exit("missplaced/unknown option " + option);
2187  continue;
2188  }
2189  mDstFile=option;
2190  }
2191 
2192  // test
2193  if(mDstFile=="") {
2194  usage_exit("no destination file specified");
2195  }
2196  bool dirdst=DirectoryExists(mDstFile);
2197 
2198  // load registry
2199  if(mRtiFile!="") {
2201  }
2202 
2203  // record plug-in and buil-in sections
2204  for(FunctionRegistry::Iterator fit=FunctionRegistry::G()->Begin();
2205  fit!=FunctionRegistry::G()->End(); fit++) {
2206  std::string section=fit->second->KeywordAt(0);
2207  std::transform(section.begin(), section.end(), section.begin(), tolower);
2208  mExclLuaSections.insert(section);
2209  }
2210 
2211  // extend registry
2212  if(mFlxFile!="") {
2214  }
2215 
2216  // record lua sections
2217  for(FunctionRegistry::Iterator fit=FunctionRegistry::G()->Begin();
2218  fit!=FunctionRegistry::G()->End(); fit++) {
2219  std::string section=fit->second->KeywordAt(0);
2220  std::transform(section.begin(), section.end(), section.begin(), tolower);
2221  mInclLuaSections.insert(section);
2222  }
2223 
2224 
2225  // include toc
2226  if(mIncludeFile!="") {
2228  RecordLiterature(tr);
2229  tr.Rewind();
2230  RecordPages(tr);
2231  }
2232 
2233 
2234  // special case: xtract fref
2235  if(xpage) {
2236  if(mSrcFiles.size()!=1) {
2237  usage_exit("extract mode requires one source file");
2238  }
2239  if(!dirdst) {
2240  usage_exit("extract mode requires destination directory");
2241  }
2242  std::cerr << "ref2html: extract pages from " << *mSrcFiles.begin() << std::endl;
2243  TokenReader tr(*mSrcFiles.begin());
2244  XtractPages(tr,mDstFile);
2245  tr.Rewind();
2246  XtractFiles(tr,mDstFile);
2247  exit(0);
2248  }
2249 
2250 
2251  // special case: generate toc
2252  if(dotoc) {
2253  if(dirdst) {
2254  usage_exit("toc mode requires destination file");
2255  }
2256  // output file
2257  std::ostream* hout= &std::cout;
2258  std::ofstream fout;
2259  if(mDstFile != "-") {
2260  fout.open(mDstFile.c_str(), std::ios::out);
2261  hout = &fout;
2262  }
2263  // process all input
2264  std::set< std::string >::iterator sit=mSrcFiles.begin();
2265  for(;sit!=mSrcFiles.end();++sit) {
2266  std::cerr << "ref2html: process toc " << *sit << std::endl;
2267  TokenReader tr(*sit);
2268  RecordLiterature(tr);
2269  tr.Rewind();
2270  RecordPages(tr);
2271  }
2272  // dump
2273  TokenWriter dst(*hout);
2274  DumpPages(dst);
2275  DumpLiterature(dst);
2276  dst.Flush();
2277  exit(0);
2278  }
2279 
2280  // special case: generate dox header/footer
2281  if(dodhd || dodft) {
2282  if(dirdst) {
2283  usage_exit("header-footer mode requires destination file");
2284  }
2285  // output file
2286  std::ostream* hout= &std::cout;
2287  std::ofstream fout;
2288  if(mDstFile != "-") {
2289  fout.open(mDstFile.c_str(), std::ios::out);
2290  hout = &fout;
2291  }
2292  // doit
2293  if(dodhd) DoxygenHeader(hout);
2294  if(dodft) DoxygenFooter(hout);
2295  exit(0);
2296  }
2297 
2298 
2299  // convert all source directories
2300  std::set< std::string > srcfiles;
2301  std::set< std::string >::iterator sit=mSrcFiles.begin();
2302  for(;sit!=mSrcFiles.end();++sit) {
2303  if(!DirectoryExists(*sit)) { srcfiles.insert(*sit); continue;}
2304  std::set< std::string > dirfiles = ReadDirectory(*sit);
2305  std::set< std::string >::iterator dit=dirfiles.begin();
2306  for(;dit!=dirfiles.end();++dit) {
2307  std::string ext = ExtractSuffix(*dit);
2308  std::string base = ExtractBasename(*dit);
2309  std::string src= PrependPath(*sit,base + ".fref");
2310  // skip if not an fref file
2311  if(ext!="fref") continue;
2312  // record
2313  srcfiles.insert(src);
2314  }
2315  }
2316  mSrcFiles=srcfiles;
2317 
2318  // insist in target dir
2319  if(mSrcFiles.size()>1 && ! dirdst) {
2320  usage_exit("multiple source files require destination directory");
2321  }
2322 
2323 
2324  // do loop
2325  /*std::set< std::string >::iterator*/ sit=mSrcFiles.begin();
2326  for(;sit!=mSrcFiles.end();++sit) {
2327  std::string base = ExtractBasename(*sit);
2328  std::string src= *sit;
2329  std::string dst= mDstFile;
2330  if(dirdst) dst=PrependPath(mDstFile,base + ".html");
2331  // process
2332  if(mSrcFiles.size()>1)
2333  std::cout << "ref2html: processing " << src << " to " << dst << std::endl;
2334  std::ofstream fout;
2335  fout.open(dst.c_str(), std::ios::out);
2336  RefpageHtml(&fout,src);
2337  }
2338  exit(0);
2339 }
std::string mJournal
Definition: ref2html.cpp:1233
std::string mTitle
Definition: ref2html.cpp:1232
std::string mYear
Definition: ref2html.cpp:1235
std::string mLabel
Definition: ref2html.cpp:1229
std::string mPublisher
Definition: ref2html.cpp:1234
std::string mAuthors
Definition: ref2html.cpp:1231
std::string mLink
Definition: ref2html.cpp:1230
std::string mSection
Definition: ref2html.cpp:610
std::string mPage
Definition: ref2html.cpp:611
std::string mLink
Definition: ref2html.cpp:612
std::string mSummary
Definition: ref2html.cpp:613
std::string mChapter
Definition: ref2html.cpp:609
std::string mTitle
Definition: ref2html.cpp:608
const std::string & HtmlDoc(void) const
Definition: cfl_types.cpp:400
const std::string & Name(void) const
Get name of the entety to document (aka faudes-type or faudes-function).
Definition: cfl_types.cpp:396
const std::string & TextDoc(void) const
Definition: cfl_types.cpp:399
A FunctionDefinition defines the interface to a faudes-function.
const Signature & Variant(const std::string &rName) const
Return reference to Signature by name.
int VariantsSize(void) const
Return number of supported Signature instances.
Iterator End(void) const
STL interator to the internal function-name map.
static FunctionRegistry * G()
Method to access the single global instance of the registry.
std::map< std::string, FunctionDefinition * >::const_iterator Iterator
Convenience typedef to access registry entries.
Definition: cfl_registry.h:505
const FunctionDefinition & Definition(const std::string &rFunctionName) const
Look up the function definition by faudes-function name.
void MergeDocumentation(TokenReader &rTr)
Scan token input for function documentation.
Structure to model a parameter type within the Signature of a Function.
Definition: cfl_functions.h:45
const std::string & Type(void) const
Get type.
const ParamAttr & Attribute(void) const
Get Attribute.
static std::string AStr(Parameter::ParamAttr attr)
Convenience method to produce a textual representation of an io attribute.
const std::string & Name(void) const
Get name.
Signature of a Function.
int Size(void) const
Return number of parameters.
const Parameter & At(int n) const
Get parameter type by position.
A TokenReader reads sequential tokens from a file or string.
std::string FileLine(void) const
Return "filename:line".
void ReadCharacterData(std::string &rData)
Read plain text.
void ReadText(const std::string &rLabel, std::string &rText)
Read plain text.
bool Eos(const std::string &rLabel)
Peek a token and check whether it ends the specified section.
void SeekBegin(const std::string &rLabel)
Find specified begin label.
int Level(void) const
Return current level of section nesting.
void ReadEnd(const std::string &rLabel)
Close the current section by matching the previous ReadBegin().
void Rewind(void)
Rewind stream.
void ReadSection(std::string &rSectionString)
Read XML section.
void ReadBegin(const std::string &rLabel)
Open a section by specified label.
bool Get(Token &token)
Get next token.
bool Peek(Token &token)
Peek next token.
bool ExistsBegin(const std::string &rLabel)
Search for specified element.
std::string FileName(void) const
Access the filename.
A TokenWriter writes sequential tokens to a file, a string or stdout.
void WriteCharacterData(const std::string &rCharData)
Write character data.
void Write(Token &rToken)
Write next token.
void Endl(void)
Write endl separator.
std::ostream * Streamp(void)
Access C++ stream.
void WriteEnd(const std::string &rLabel)
Write end label.
void Flush(void)
Flush any buffers.
void WriteBegin(const std::string &rLabel)
Write begin label.
Tokens model atomic data for stream IO.
Definition: cfl_token.h:54
bool IsBinary(void) const
Test token Type.
Definition: cfl_token.cpp:249
const std::string & PreceedingSpace(void) const
Preceeding space when writing to stream.
Definition: cfl_token.cpp:189
const std::string & StringValue(void) const
Get string value of a name token.
Definition: cfl_token.cpp:178
void ClrEnd(void)
Clear End type (resolve empty section)
Definition: cfl_token.cpp:161
bool ExistsAttributeString(const std::string &name)
Test attibute existence.
Definition: cfl_token.cpp:356
bool IsBegin(void) const
Test token Type.
Definition: cfl_token.cpp:259
void SetEmpty(const std::string &rName)
Initialize as empty-tag token.
Definition: cfl_token.cpp:106
void ClrAttribute(const std::string &name)
Clear attribute.
Definition: cfl_token.cpp:286
void SetBegin(const std::string &rName)
Initialize as Begin token.
Definition: cfl_token.cpp:92
void InsAttributeString(const std::string &name, const std::string &value)
Insert named attribute with string value.
Definition: cfl_token.cpp:310
bool IsEnd(void) const
Test token Type.
Definition: cfl_token.cpp:270
const std::string & AttributeStringValue(const std::string &name)
Access attribute value.
Definition: cfl_token.cpp:386
A TypeDefinition defines a faudes-type in that it specifies a faudes-type name to identify the type a...
Definition: cfl_types.h:1467
const TypeDefinition & Definition(const std::string &rTypeName) const
Look up the type definition by faudes-type name.
static TypeRegistry * G()
Method to access the single global instance of the registry.
Iterator End(void) const
STL interator to the internal type-name map.
std::map< std::string, TypeDefinition * >::const_iterator Iterator
Convenience typedef to access registry entries.
Definition: cfl_registry.h:54
Includes all libFAUDES headers, no plugins.
void LoadRegistry(const std::string &rPath)
Load all registered types and functions.
libFAUDES resides within the namespace faudes.
std::string VersionString()
Return FAUDES_VERSION as std::string.
Definition: cfl_utils.cpp:131
std::string PrependPath(const std::string &rLeft, const std::string &rRight)
Prepend one path before another.
Definition: cfl_utils.cpp:303
std::string ExtractBasename(const std::string &rFullPath)
Extract file basename from full path.
Definition: cfl_utils.cpp:274
std::string PluginsString()
Return FAUDES_PLUGINS as std::string.
Definition: cfl_utils.cpp:136
std::string ExtractFilename(const std::string &rFullPath)
Extract file name from full path.
Definition: cfl_utils.cpp:265
std::string ExtractSuffix(const std::string &rFullPath)
Extract extension from full path, i.e.
Definition: cfl_utils.cpp:288
std::string ContributorsString()
Return contributors as std::string.
Definition: cfl_utils.cpp:141
std::set< std::string > ReadDirectory(const std::string &rDirectory)
Read the contents of the specified directors.
Definition: cfl_utils.cpp:348
std::string StringSubstitute(const std::string &rString, const std::string &rFrom, const std::string &rTo)
Substitute globally in string.
Definition: cfl_utils.cpp:111
bool DirectoryExists(const std::string &rDirectory)
Test existence of directory.
Definition: cfl_utils.cpp:332
void SectionIndexHtml(std::ostream *pIndexFile, const std::string &key)
Definition: ref2html.cpp:1098
int main(int argc, char *argv[])
Definition: ref2html.cpp:2060
std::string mExitChapterClass
Definition: ref2html.cpp:134
std::string mFrefLink
Definition: ref2html.cpp:99
void ChaptersPrefix(const std::string &prefix)
Definition: ref2html.cpp:140
void DoxygenHeader(std::ostream *pOutFile)
Definition: ref2html.cpp:1970
std::set< std::string > mSrcFiles
Definition: ref2html.cpp:105
void RecordPages(TokenReader &rTr)
Definition: ref2html.cpp:624
std::string mChapterFile
Definition: ref2html.cpp:106
void RefpageHtml(std::ostream *pOutFile, std::string inputfile)
Definition: ref2html.cpp:1820
std::map< std::string, std::map< std::string, PageRecord > > mRefSectPages
Definition: ref2html.cpp:621
std::string TimeStamp(void)
Definition: ref2html.cpp:154
void XtractFiles(TokenReader &src, const std::string &rDstDir)
Definition: ref2html.cpp:1470
std::vector< PageRecord > mAllPages
Definition: ref2html.cpp:618
std::string mFlxFile
Definition: ref2html.cpp:103
std::string mReferencePrefix
Definition: ref2html.cpp:112
std::string mDstFile
Definition: ref2html.cpp:104
std::string mFaudesLink
Definition: ref2html.cpp:126
void ShortdocHtml(std::ostream *pOutFile, std::string fname)
Definition: ref2html.cpp:1187
std::string mThisChapterClass
Definition: ref2html.cpp:132
std::string mLuafaudesPrefix
Definition: ref2html.cpp:114
void FooterHtml(std::ostream *pStream)
Definition: ref2html.cpp:249
std::string mFrefSection
Definition: ref2html.cpp:97
std::string TexScripts(const std::string &rTexString)
Definition: ref2html.cpp:416
std::string mChaptersPrefix
Definition: ref2html.cpp:110
std::string mIncludeFile
Definition: ref2html.cpp:107
void ListItemHtml(std::ostream *pStream, const std::string &rLink, const std::string &rText)
Definition: ref2html.cpp:271
void DumpLiterature(TokenWriter &rTw)
Definition: ref2html.cpp:1334
void BottomLineHtml(std::ostream *pStream)
Definition: ref2html.cpp:196
void ListFunctionsHtml(std::ostream *pIndexFile, const std::string &key="")
Definition: ref2html.cpp:796
void RecordLiterature(TokenReader &rTr)
Definition: ref2html.cpp:1242
std::map< std::string, LiteratureRecord > mLiterature
Definition: ref2html.cpp:1239
std::string mBooksPrefix
Definition: ref2html.cpp:109
std::string mImagePrefix
Definition: ref2html.cpp:111
std::string mFrefSummary
Definition: ref2html.cpp:100
std::string mOtherChapterClass
Definition: ref2html.cpp:133
void FunctionIndexHtml(std::ostream *pIndexFile, const std::string &key="")
Definition: ref2html.cpp:949
void MathHtml(std::ostream *pStream, const std::string &rMathString)
Definition: ref2html.cpp:501
std::set< std::string > mInclLuaSections
Definition: ref2html.cpp:603
std::string mLuafaudesLink
Definition: ref2html.cpp:128
void LiteratureHtml(std::ostream *pStream, const std::string &rLabel="")
Definition: ref2html.cpp:1379
void TypeIndexHtml(std::ostream *pIndexFile, const std::string &key="")
Definition: ref2html.cpp:914
std::string mFrefPage
Definition: ref2html.cpp:98
std::string TexSpacing(const std::string &rTexString)
Definition: ref2html.cpp:372
void SignatureHtml(std::ostream *pOutFile, std::string function)
Definition: ref2html.cpp:1148
std::string mFrefTitle
Definition: ref2html.cpp:95
std::string mDownloadLink
Definition: ref2html.cpp:125
std::string mCsourceLink
Definition: ref2html.cpp:129
std::string mFrefChapter
Definition: ref2html.cpp:96
void DumpPages(TokenWriter &rTw)
Definition: ref2html.cpp:730
std::string PrettyPage(const std::string page)
Definition: ref2html.cpp:169
void TextHtml(std::ostream *pStream, const std::string &rText)
Definition: ref2html.cpp:329
std::string mCsourcePrefix
Definition: ref2html.cpp:113
void ImageHtml(std::ostream *pStream, const std::string &rFileName)
Definition: ref2html.cpp:260
void ReferenceIndexHtml(std::ostream *pIndexFile, const std::string &key="")
Definition: ref2html.cpp:995
std::string mCssFile
Definition: ref2html.cpp:130
std::string mRtiFile
Definition: ref2html.cpp:102
void usage_exit(const std::string &rMessage="")
Definition: ref2html.cpp:51
void HeaderHtml(std::ostream *pStream)
Definition: ref2html.cpp:230
void CiteHtml(std::ostream *pStream, const std::string &rLabel)
Definition: ref2html.cpp:1400
void LuafaudesIndexHtml(std::ostream *pIndexFile)
Definition: ref2html.cpp:1522
std::string mDestoolLink
Definition: ref2html.cpp:127
std::string TexMacroSubstitute1(const std::string &rTexString, const std::string &rMacro, const std::string &rSubst)
Definition: ref2html.cpp:343
bool mStandaloneReference
Definition: ref2html.cpp:93
void ListSectionsHtml(std::ostream *pIndexFile, const std::string &key="")
Definition: ref2html.cpp:831
void FunctionHtml(std::ostream *pStream, const std::string &rFunctionName)
Definition: ref2html.cpp:306
void XtractPages(TokenReader &src, const std::string &rDstDir)
Definition: ref2html.cpp:1416
void DoxygenFooter(std::ostream *pOutFile)
Definition: ref2html.cpp:2014
void ProcessSection(TokenWriter &rTw, TokenReader &rTr)
Definition: ref2html.cpp:1556
void TypeHtml(std::ostream *pStream, const std::string &rTypeName)
Definition: ref2html.cpp:282
std::set< std::string > mExclLuaSections
Definition: ref2html.cpp:602
void ListTypesHtml(std::ostream *pIndexFile, const std::string &key="")
Definition: ref2html.cpp:761

libFAUDES 2.32f --- 2024.12.22 --- c++ api documentaion by doxygen