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=rDstDir + faudes_pathsep() + 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=rDstDir + faudes_pathsep() + "images" +
1498  faudes_pathsep() + name;
1499  std::transform(dstfile.begin(), dstfile.end(), dstfile.begin(), tolower);
1500  std::cerr << "ref2html: extracting image file to \"" << dstfile << "\"" << std::endl;
1501  // setup stream
1502  std::fstream fsout;
1503  fsout.exceptions(std::ios::badbit|std::ios::failbit);
1504  try{
1505  fsout.open(dstfile.c_str(), std::ios::out | std::ios::binary);
1506  fsout.write(data.StringValue().c_str(),data.StringValue().size());
1507  fsout.close();
1508  }
1509  catch (std::ios::failure&) {
1510  std::cerr << "ref2html: file io error when writing \"" << dstfile << "\"" << std::endl;
1511  }
1512  // read end tag
1513  src.ReadEnd("ImageFile");
1514  }
1515 }
1516 
1517 // ******************************************************************
1518 // luafaudes index
1519 // ******************************************************************
1520 
1521 void LuafaudesIndexHtml(std::ostream* pIndexFile) {
1522 
1523  // prepare list of all sections
1524  std::map< std::string , std::string > pages;
1525  std::vector< PageRecord >::iterator pit;
1526  for(pit=mAllPages.begin(); pit != mAllPages.end(); pit++) {
1527  // my chapter only
1528  if(pit->mChapter!="luafaudes") continue;
1529  if(pit->mSection=="none") continue;
1530  if(pit->mSection=="") continue;
1531  if(pit->mPage=="") continue;
1532  // get nice name
1533  std::string pname = pit->mPage;
1534  // have link
1535  std::string phtml = pit->mLink;
1536  // record
1537  pages[pname]=phtml;
1538  }
1539  // produce sorted index
1540  std::map< std::string , std::string >::iterator sit;
1541  for(sit=pages.begin(); sit!=pages.end(); sit++) {
1542  // have entry
1543  ListItemHtml(pIndexFile,sit->second, sit->first);
1544  }
1545  // empty
1546  if(pages.size()==0) {
1547  *pIndexFile << "<li class=\"registry_item\">" << "none" << "</li>" << std::endl;
1548  }
1549 }
1550 
1551 // ******************************************************************
1552 // process current section
1553 // ******************************************************************
1554 
1556 
1557  // record my level/mode
1558  int clevel = rTr.Level();
1559 
1560  // std::cerr << "process level " << clevel << "\n";
1561 
1562  // token copy loop
1563  while(true) {
1564  // see whether we can grab and copy some plain text
1565  std::string text;
1566  rTr.ReadCharacterData(text);
1567  if(text.size()>0) {
1568  //std::cerr << "copy text \"" << text << "\"\n";
1569  rTw.WriteCharacterData(text);
1570  continue;
1571  }
1572  // break on no token or end of my level
1573  Token token;
1574  if(!rTr.Peek(token)) break;
1575  if(token.IsEnd() && !token.IsBegin() && rTr.Level()==clevel)
1576  break;
1577  // do my special tags: ftype
1578  if(token.IsBegin("ftype")) {
1579  std::string ftype;
1580  rTr.ReadText("ftype",ftype);
1581  TypeHtml(rTw.Streamp(),ftype);
1582  continue;
1583  }
1584  // do my special tags: ffnct
1585  if(token.IsBegin("ffnct")) {
1586  std::string ffnct;
1587  rTr.ReadText("ffnct",ffnct);
1588  FunctionHtml(rTw.Streamp(),ffnct);
1589  continue;
1590  }
1591  // do my special tags: fimage
1592  if(token.IsBegin("fimage")) {
1593  rTr.ReadBegin("fimage", token);
1594  std::string fsrc=token.AttributeStringValue("fsrc");
1595  fsrc = StringSubstitute(fsrc,"FAUDES_IMAGES/",""); // be nice
1596  fsrc = ExtractBasename(fsrc); // be even niecer
1597  ImageHtml(rTw.Streamp(),fsrc);
1598  rTr.ReadEnd("fimage");
1599  continue;
1600  }
1601  // do my special tags: dmath
1602  if(token.IsBegin("fdmath")) {
1603  rTr.ReadBegin("fdmath", token);
1604  std::string mtext;
1605  rTr.ReadCharacterData(mtext);
1606  *rTw.Streamp() << "<span class=\"faudes_dmath\">";
1607  MathHtml(rTw.Streamp(),mtext);
1608  *rTw.Streamp()<< "</span>";
1609  rTr.ReadEnd("fdmath");
1610  continue;
1611  }
1612  // do my special tags: dmath
1613  if(token.IsBegin("fimath")) {
1614  rTr.ReadBegin("fimath", token);
1615  std::string mtext;
1616  rTr.ReadCharacterData(mtext);
1617  *rTw.Streamp()<< "<span class=\"faudes_imath\">";
1618  MathHtml(rTw.Streamp(),mtext);
1619  *rTw.Streamp()<< "</span>";
1620  rTr.ReadEnd("fimath");
1621  continue;
1622  }
1623  // do my special tags: ffnct_reference
1624  if(token.IsBegin("ffnct_reference")) {
1625  rTr.ReadBegin("ffnct_reference", token);
1626  std::string ffnct = token.AttributeStringValue("name");
1627  *rTw.Streamp() << "<div class=\"registry_function\"> " << std::endl;
1628  *rTw.Streamp() << "<h2>" << "<a id=\"" << ffnct << "\">" << ffnct << "</a></h2>" << std::endl;
1629  ShortdocHtml(rTw.Streamp(),ffnct);
1630  ProcessSection(rTw,rTr);
1631  *rTw.Streamp() << "</div>" << std::endl;
1632  rTr.ReadEnd("ffnct_reference");
1633  continue;
1634  }
1635  // do my special tags: ftype_reference
1636  if(token.IsBegin("ftype_reference")) {
1637  rTr.ReadBegin("ftype_reference", token);
1638  std::string ftype = token.AttributeStringValue("name");
1639  *rTw.Streamp() << "<div class=\"registry_type\"> " << std::endl;
1640  *rTw.Streamp() << "<h2>" << "<a id=\"" << ftype << "\">" << ftype << "</a></h2>" << std::endl;
1641  ShortdocHtml(rTw.Streamp(),ftype);
1642  ProcessSection(rTw,rTr);
1643  *rTw.Streamp() << "</div>" << std::endl;
1644  rTr.ReadEnd("ftype_reference");
1645  continue;
1646  }
1647  // do my special tags: fdetails
1648  if(token.IsBegin("fdetails")) {
1649  rTr.ReadBegin("fdetails", token);
1650  *rTw.Streamp() << "<h5>Detailed description:</h5>";
1651  rTr.ReadEnd("fdetails");
1652  continue;
1653  }
1654  // do my special tags: fconditions
1655  if(token.IsBegin("fconditions")) {
1656  rTr.ReadBegin("fconditions", token);
1657  *rTw.Streamp() << "<h5>Parameter Conditions:</h5>";
1658  rTr.ReadEnd("fconditions");
1659  continue;
1660  }
1661  // do my special tags: fexample
1662  if(token.IsBegin("fexample")) {
1663  rTr.ReadBegin("fexample", token);
1664  *rTw.Streamp() << "<h5>Example:</h5>";
1665  rTr.ReadEnd("fexample");
1666  continue;
1667  }
1668  // do my special tags: falltypes
1669  if(token.IsBegin("falltypes")) {
1670  rTr.ReadBegin("falltypes", token);
1671  ListTypesHtml(rTw.Streamp());
1672  rTr.ReadEnd("falltypes");
1673  continue;
1674  }
1675  // do my special tags: fallfncts
1676  if(token.IsBegin("fallfncts")) {
1677  rTr.ReadBegin("fallfncts", token);
1678  ListFunctionsHtml(rTw.Streamp());
1679  rTr.ReadEnd("fallfncts");
1680  continue;
1681  }
1682  // do my special tags: fallsects
1683  if(token.IsBegin("fallsects")) {
1684  rTr.ReadBegin("fallsects", token);
1685  ListSectionsHtml(rTw.Streamp());
1686  rTr.ReadEnd("fallsects");
1687  continue;
1688  }
1689  // do my special tags: fluasects
1690  if(token.IsBegin("fluasects")) {
1691  rTr.ReadBegin("fluasects", token);
1692  ListSectionsHtml(rTw.Streamp(),"luaext");
1693  rTr.ReadEnd("fluasects");
1694  continue;
1695  }
1696  // do my special tags: fliteratur (list all)
1697  if(token.IsBegin("falllit")) {
1698  rTr.ReadBegin("falllit");
1699  LiteratureHtml(rTw.Streamp());
1700  rTr.ReadEnd("falllit");
1701  continue;
1702  }
1703  // do my special tags: fliteratur (definition of)
1704  if(token.IsBegin("fliterature")) {
1705  rTr.ReadBegin("fliterature", token);
1706  std::string label=token.AttributeStringValue("name");
1707  LiteratureHtml(rTw.Streamp(),label);
1708  rTr.ReadEnd("fliterature");
1709  continue;
1710  }
1711  // do my special tags: fcontributors
1712  if(token.IsBegin("fcontributors")) {
1713  rTr.ReadBegin("fcontributors");
1714  *rTw.Streamp() << ContributorsString();
1715  rTr.ReadEnd("fcontributors");
1716  continue;
1717  }
1718  // do my special tags: flink
1719  if(token.IsBegin("fcite")) {
1720  rTr.ReadBegin("fcite", token);
1721  std::string label=token.AttributeStringValue("name");
1722  CiteHtml(rTw.Streamp(),label);
1723  rTr.ReadEnd("fcite");
1724  continue;
1725  }
1726  // do my special tags: fix br for HTML
1727  if(token.IsBegin("br")) {
1728  rTr.ReadBegin("br");
1729  Token etag;
1730  rTr.Peek(etag);
1731  if(etag.IsEnd("br")) rTr.ReadEnd("br"); // optionally accept balanced <br>
1732  token.ClrEnd();
1733  token.PreceedingSpace("n");
1734  rTw.Write(token); // intentionall write unbalanced <br> for HTML
1735  continue;
1736  }
1737  // do my special tags: fsummary
1738  if(token.IsBegin("fsummary")) {
1739  rTr.ReadBegin("fsummary");
1740  rTr.ReadEnd("fsummary");
1741  continue;
1742  }
1743  // get token to do my special attributes
1744  rTr.Get(token);
1745  //std::cerr << "copy token (lv " << rTr.Level() << "): " << token.Str() << "\n";
1746  // sense chapter classes
1747  if(token.ExistsAttributeString("ftcclass")) {
1748  mThisChapterClass=token.AttributeStringValue("ftcclass");
1749  token.ClrAttribute("ftcclass");
1750  }
1751  if(token.ExistsAttributeString("focclass")) {
1752  mOtherChapterClass=token.AttributeStringValue("focclass");
1753  token.ClrAttribute("focclass");
1754  }
1755  if(token.ExistsAttributeString("fxcclass")) {
1756  mExitChapterClass=token.AttributeStringValue("fxcclass");
1757  token.ClrAttribute("fxcclass");
1758  }
1759  // chapter attribute
1760  if(token.ExistsAttributeString("fchapter")) {
1761  std::string chapter = token.AttributeStringValue("fchapter");
1762  std::string cclass=mOtherChapterClass;
1763  if(chapter==mFrefChapter) cclass=mThisChapterClass;
1764  if(chapter=="exit") cclass=mExitChapterClass;
1765  token.InsAttributeString("class",cclass);
1766  token.ClrAttribute("fchapter");
1767  }
1768  // fhref attribute: ref only
1769  if(token.ExistsAttributeString("fhref") && mStandaloneReference) {
1770  std::string href = token.AttributeStringValue("fhref");
1771  href = StringSubstitute(href,"FAUDES_BOOKS/",mBooksPrefix);
1772  href = StringSubstitute(href,"FAUDES_CHAPTERS/",mChaptersPrefix);
1773  href = StringSubstitute(href,"FAUDES_IMAGES/",mImagePrefix);
1774  href = StringSubstitute(href,"FAUDES_REFERENCE/",mReferencePrefix);
1775  href = StringSubstitute(href,"FAUDES_CSOURCE/",mCsourceLink);
1776  href = StringSubstitute(href,"FAUDES_LUAFAUDES/",mLuafaudesLink);
1777  href = StringSubstitute(href,"FAUDES_ONLINE",mFaudesLink);
1778  href = StringSubstitute(href,"FAUDES_GETLINUX",mDownloadLink+"#Packages");
1779  href = StringSubstitute(href,"FAUDES_GETMSWIN",mDownloadLink+"#Packages");
1780  href = StringSubstitute(href,"DESTOOL_ONLINE",mDestoolLink);
1781  token.InsAttributeString("href",href);
1782  token.ClrAttribute("fhref");
1783  }
1784  // fhref attribute
1785  if(token.ExistsAttributeString("fhref") && !mStandaloneReference) {
1786  std::string href = token.AttributeStringValue("fhref");
1787  href = StringSubstitute(href,"FAUDES_BOOKS/",mBooksPrefix);
1788  href = StringSubstitute(href,"FAUDES_CHAPTERS/",mChaptersPrefix);
1789  href = StringSubstitute(href,"FAUDES_IMAGES/",mImagePrefix);
1790  href = StringSubstitute(href,"FAUDES_REFERENCE/",mReferencePrefix);
1791  href = StringSubstitute(href,"FAUDES_CSOURCE/",mCsourcePrefix);
1792  href = StringSubstitute(href,"FAUDES_LUAFAUDES/",mLuafaudesPrefix);
1793  href = StringSubstitute(href,"FAUDES_ONLINE",mFaudesLink);
1794  href = StringSubstitute(href,"FAUDES_GETLINUX",mDownloadLink+"#Packages");
1795  href = StringSubstitute(href,"FAUDES_GETMSWIN",mDownloadLink+"#Packages");
1796  href = StringSubstitute(href,"DESTOOL_ONLINE",mDestoolLink);
1797  token.InsAttributeString("href",href);
1798  token.ClrAttribute("fhref");
1799  }
1800  // fsrc attribute
1801  if(token.ExistsAttributeString("fsrc")) {
1802  std::string fsrc = token.AttributeStringValue("fsrc");
1803  fsrc = StringSubstitute(fsrc,"FAUDES_IMAGES/",mImagePrefix);
1804  fsrc = StringSubstitute(fsrc,"FAUDES_CSOURCE/",mCsourcePrefix);
1805  fsrc = StringSubstitute(fsrc,"FAUDES_LUAFAUDES/",mLuafaudesPrefix);
1806  token.InsAttributeString("src",fsrc);
1807  token.ClrAttribute("fsrc");
1808  }
1809  token.PreceedingSpace("n");
1810  rTw.Write(token);
1811  }
1812 }
1813 
1814 
1815 // ******************************************************************
1816 // reference page
1817 // ******************************************************************
1818 
1819 void RefpageHtml(std::ostream* pOutFile, std::string inputfile) {
1820 
1821  // setup token io
1822  TokenReader src(inputfile);
1823  TokenWriter dst(*pOutFile);
1824 
1825  // find the reference page section
1826  Token btag;
1827  src.SeekBegin("ReferencePage");
1828  src.ReadBegin("ReferencePage",btag);
1829 
1830  // extract title & friends
1831  mFrefTitle="libFAUDES Reference";
1832  if(btag.ExistsAttributeString("title"))
1833  mFrefTitle=btag.AttributeStringValue("title");
1834  mFrefChapter="";
1835  if(btag.ExistsAttributeString("chapter"))
1836  mFrefChapter=btag.AttributeStringValue("chapter");
1837  mFrefSection="";
1838  if(btag.ExistsAttributeString("section"))
1839  mFrefSection=btag.AttributeStringValue("section");
1840  std::transform(mFrefChapter.begin(), mFrefChapter.end(), mFrefChapter.begin(), tolower);
1841  std::transform(mFrefSection.begin(), mFrefSection.end(), mFrefSection.begin(), tolower);
1842 
1843  // report
1844  // std::cerr << "ref2html: found chapter \"" << mFrefChapter << "\" section \"" << mFrefSection << "\"" << std::endl;
1845 
1846  // generate generic html header
1847  dst.Flush();
1848  HeaderHtml(pOutFile);
1849 
1850  // begin body
1851  dst.Flush();
1852 
1853  // include chapter level navigation
1854  if(mChapterFile!="") {
1855  //std::cerr << "using " << mChapterFile << std::endl;
1857  ProcessSection(dst,inc);
1858  }
1859 
1860  // include section level navigation, part 1
1861  if(mFrefChapter=="reference") {
1862  *pOutFile << "<table id=\"registry_page\">" << std::endl;
1863  *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1864  *pOutFile << "<td id=\"registry_index\">" << std::endl;
1865  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1866  *pOutFile << "<li class=\"registry_heading\">libFAUDES</li>" << std::endl;
1867  ListItemHtml(pOutFile,"reference_index.html", "Reference");
1868  ListItemHtml(pOutFile,"reference_types.html", "Type Index");
1869  ListItemHtml(pOutFile,"reference_functions.html", "Function Index");
1870  ListItemHtml(pOutFile,"reference_literature.html", "Literature");
1871  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1872  ReferenceIndexHtml(pOutFile, mFrefSection);
1873  *pOutFile << "</ul></td>" << std::endl;
1874  *pOutFile << "<td id=\"registry_content\">" << std::endl;
1875  }
1876 
1877  // include section level navigation, part 1
1878  if(mFrefChapter=="luafaudes") {
1879  *pOutFile << "<table id=\"registry_page\">" << std::endl;
1880  *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1881  *pOutFile << "<td id=\"registry_index\">" << std::endl;
1882  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1883  *pOutFile << "<li class=\"registry_heading\">luafaudes</li>" << std::endl;
1884  *pOutFile
1885  << "<script language=\"JavaScript\"> var luafaudes=function() { "
1886  << " popupWin = window.open('luafaudes_repl.html','open_window',"
1887  << " 'resizable,dependent, width=720, height=480, left=0, top=0'); } "
1888  << "</script>" << std::endl;
1889  ListItemHtml(pOutFile,"index.html", "Introduction");
1890  ListItemHtml(pOutFile,"javascript:luafaudes();", "Lua-Console");
1891  ListItemHtml(pOutFile,"faudes_luaext.html", "Lua-Extensions");
1892  ListItemHtml(pOutFile,"faudes_luatech.html", "Technical Detail");
1893  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1894  *pOutFile << "<li class=\"registry_heading\">Tutorials</li>" << std::endl;
1895  LuafaudesIndexHtml(pOutFile);
1896  *pOutFile << "</ul></td>" << std::endl;
1897  *pOutFile << "<td id=\"registry_content\">" << std::endl;
1898  }
1899 
1900  // process src
1901  ProcessSection(dst,src);
1902  src.ReadEnd("ReferencePage");
1903  dst.Flush();
1904 
1905  // track bottom line
1906  bool bottom=false;
1907 
1908  // include section level navigation, part 2
1909  if(mFrefChapter=="reference") {
1910  BottomLineHtml(pOutFile);
1911  bottom=true;
1912  *pOutFile << "</td>" << std::endl;
1913  *pOutFile << "</tr>" << std::endl;
1914  *pOutFile << "</table>" << std::endl;
1915  }
1916 
1917  // include section level navigation, part 2
1918  if(mFrefChapter=="luafaudes") {
1919  BottomLineHtml(pOutFile);
1920  bottom=true;
1921  *pOutFile << "</td>" << std::endl;
1922  *pOutFile << "</tr>" << std::endl;
1923  *pOutFile << "</table>" << std::endl;
1924  }
1925 
1926  // include section level navigation, part 3
1927  if(mFrefChapter=="reference") {
1928  *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
1929  *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
1930  *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
1931  *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
1932  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1933  SectionIndexHtml(pOutFile,mFrefSection);
1934  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1935  ListItemHtml(pOutFile,"#", "Top of Page");
1936  *pOutFile << "</ul></div>" << std::endl;
1937  }
1938 
1939  // include section level navigation, part 3
1940  if(mFrefChapter=="luafaudes" && mFrefSection=="tutorials") {
1941  *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
1942  *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
1943  *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
1944  *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
1945  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1946  *pOutFile << "<li class=\"registry_heading\">luafaudes</li>" << std::endl;
1947  *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luafaudes.html\">Introduction</a></li>" << std::endl;
1948  *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luaext.html\">Lua-Extansions</a></li>" << std::endl;
1949  *pOutFile << "<li class=\"registry_item\"><a href=\"faudes_luatech.html\">Techn. Details</a></li>" << std::endl;
1950  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1951  *pOutFile << "<li class=\"registry_item\"><a href=\"#\">Top of Page</a></li>" << std::endl;
1952  *pOutFile << "</ul></div>" << std::endl;
1953  }
1954 
1955  // bottom line
1956  if(!bottom) BottomLineHtml(pOutFile);
1957 
1958  // generic footer
1959  FooterHtml(pOutFile);
1960 
1961 }
1962 
1963 
1964 
1965 // ******************************************************************
1966 // Doxygen header and footer
1967 // ******************************************************************
1968 
1969 void DoxygenHeader(std::ostream* pOutFile) {
1970 
1971  // setup token io
1972  TokenWriter dst(*pOutFile);
1973 
1974  // configure
1975  mFrefTitle="C++ API";
1976  mFrefChapter="cppapi";
1977  mFrefSection="none";
1978 
1979  // generate generic html header
1980  dst.Flush();
1981  HeaderHtml(pOutFile);
1982 
1983  // include chapter level navigation
1984  if(mChapterFile!="") {
1986  ProcessSection(dst,inc);
1987  }
1988 
1989  // include section level navigation, part 1
1990  *pOutFile << "<table id=\"registry_page\">" << std::endl;
1991  *pOutFile << "<tr id=\"registry_row\">" << std::endl;
1992  *pOutFile << "<td id=\"registry_index\">" << std::endl;
1993  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
1994  *pOutFile << "<li class=\"registry_heading\">libFAUDES</li>" << std::endl;
1995  ListItemHtml(pOutFile, "index.html", "C++ API");
1996  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
1997  *pOutFile << "<li class=\"registry_heading\">Sections</li>" << std::endl;
1998  ListItemHtml(pOutFile, "group__ContainerClasses.html", "Sets");
1999  ListItemHtml(pOutFile, "group__GeneratorClasses.html", "Generators");
2000  ListItemHtml(pOutFile, "group__GeneratorFunctions.html", "Functions");
2001  ListItemHtml(pOutFile, "group__AllPlugins.html", "PlugIns");
2002  ListItemHtml(pOutFile, "group__Tutorials.html", "Tutorials");
2003  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2004  *pOutFile << "<li class=\"registry_heading\">Index</li>" << std::endl;
2005  ListItemHtml(pOutFile, "classes.html", "Classes");
2006  ListItemHtml(pOutFile, "files.html", "Files");
2007  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2008  *pOutFile << "</ul></td>" << std::endl;
2009  *pOutFile << "<td id=\"registry_content\">" << std::endl;
2010 }
2011 
2012 
2013 void DoxygenFooter(std::ostream* pOutFile) {
2014 
2015  // setup token io
2016  TokenWriter dst(*pOutFile);
2017 
2018  // configure
2019  mFrefTitle="C++ API";
2020  mFrefChapter="cppapi";
2021  mFrefSection="none";
2022 
2023  // include section level navigation, part 2
2024  BottomLineHtml(pOutFile);
2025  *pOutFile << "</td>" << std::endl;
2026  *pOutFile << "</tr>" << std::endl;
2027  *pOutFile << "</table>" << std::endl;
2028 
2029  // include section level navigation, part 3
2030  *pOutFile << "</div>" << std::endl << "</div>" << std::endl;
2031  *pOutFile << "<div id=\"cxwrapper1000\">" << std::endl;
2032  *pOutFile << "<div id=\"dxwrapper1000\">" << std::endl;
2033  *pOutFile << "<div class=\"registry_trigger\"> <span>&gt;&gt;</span>" << std::endl;
2034  *pOutFile << "<ul class=\"registry_list\">" << std::endl;
2035  *pOutFile << "<li class=\"registry_heading\">C++ API</li>" << std::endl;
2036  *pOutFile << "<li class=\"registry_item\"><a href=\"index.html\">Introduction</a></li>" << std::endl;
2037  *pOutFile << "<li class=\"registry_item\"><a href=\"group__ContainerClasses.html\">Sets</a></li>" << std::endl;
2038  *pOutFile << "<li class=\"registry_item\"><a href=\"group__GeneratorClasses.html\">Generators</a></li>" << std::endl;
2039  *pOutFile << "<li class=\"registry_item\"><a href=\"group__GeneratorFunctions.html\">Functions</a></li>" << std::endl;
2040  *pOutFile << "<li class=\"registry_item\"><a href=\"group__AllPlugins.html\">PlugIns</a></li>" << std::endl;
2041  *pOutFile << "<li class=\"registry_item\"><a href=\"group__Tutorials.html\">Tutorials</a></li>" << std::endl;
2042  *pOutFile << "<li class=\"registry_item\"><a href=\"classes.html\">Classes</a></li>" << std::endl;
2043  *pOutFile << "<li class=\"registry_item\"><a href=\"files.html\">Files</a></li>" << std::endl;
2044  *pOutFile << "<li class=\"registry_blanc\">&nbsp;</li>" << std::endl;
2045  *pOutFile << "<li class=\"registry_item\"><a href=\"#\">Top of Page</a></li>" << std::endl;
2046  *pOutFile << "</ul></div>" << std::endl;
2047 
2048  // end page
2049  dst.Flush();
2050  FooterHtml(pOutFile);
2051 
2052 }
2053 
2054 // ******************************************************************
2055 // command line ui
2056 // ******************************************************************
2057 
2058 
2059 int main(int argc, char *argv[]) {
2060 
2061  // local config
2062  bool dotoc=false;
2063  bool dodhd=false;
2064  bool dodft=false;
2065  bool xpage=false;
2066 
2067  // min args
2068  if(argc < 3) usage_exit();
2069 
2070  // primitive commad line parsing
2071  int i;
2072  for(i=1; i<argc; i++) {
2073  std::string option(argv[i]);
2074  // option: rti file
2075  if(option=="-rti") {
2076  i++; if(i>=argc) usage_exit();
2077  mRtiFile=argv[i];
2078  continue;
2079  }
2080  // option: flx file
2081  if(option=="-flx") {
2082  i++; if(i>=argc) usage_exit();
2083  mFlxFile=argv[i];
2084  continue;
2085  }
2086  // option: css file
2087  if(option=="-css") {
2088  i++; if(i>=argc) usage_exit();
2089  mCssFile=argv[i];
2090  continue;
2091  }
2092  // option: navigation include
2093  if(option=="-cnav") {
2094  i++; if(i>=argc) usage_exit();
2095  mChapterFile=argv[i];
2096  continue;
2097  }
2098  // option: toc include
2099  if(option=="-inc") {
2100  i++; if(i>=argc) usage_exit();
2101  mIncludeFile=argv[i];
2102  continue;
2103  }
2104  // option: target prefix
2105  if(option=="-rel") {
2106  i++; if(i>=argc) usage_exit();
2107  ChaptersPrefix(argv[i]);
2108  continue;
2109  }
2110  // option: overwrite chapter
2111  if(option=="-chapter") {
2112  i++; if(i>=argc) usage_exit();
2113  mFrefChapter=argv[i];
2114  continue;
2115  }
2116  // option: overwrite section
2117  if(option=="-section") {
2118  i++; if(i>=argc) usage_exit();
2119  mFrefSection=argv[i];
2120  continue;
2121  }
2122  // option: extract multiple pages
2123  if(option=="-extract") {
2124  if(i+2!=argc-1) usage_exit();
2125  xpage=true;
2126  break;
2127  }
2128  // option: generate toc (break)
2129  if(option=="-toc") {
2130  i++; if(i+1>=argc) usage_exit();
2131  dotoc=true;
2132  mDstFile = argv[argc-1];
2133  break;
2134  }
2135  // option: generate doxygen header (break)
2136  if(option=="-doxheader") {
2137  i++; if(i>=argc) usage_exit();
2138  dodhd=true;
2139  mDstFile = argv[argc-1];
2140  break;
2141  }
2142  // option: generate doxygen footer (break)
2143  if(option=="-doxfooter") {
2144  i++; if(i>=argc) usage_exit();
2145  dodft=true;
2146  mDstFile = argv[argc-1];
2147  break;
2148  }
2149  // option: generate standalone reference
2150  if(option=="-app") {
2151  mStandaloneReference=true;
2152  continue;
2153  }
2154  // option: help
2155  if((option=="-?") || (option=="--help")) {
2156  usage_exit();
2157  continue;
2158  }
2159  // option: unknown
2160  if(option.size()>1)
2161  if(option.at(0)=='-') {
2162  usage_exit("unknown option " + option);
2163  continue;
2164  }
2165  // non-option: break
2166  break;
2167  }
2168 
2169  // figure source
2170  for(;i<argc-1; i++) {
2171  std::string option(argv[i]);
2172  if(option.size()>1)
2173  if(option.at(0)=='-') {
2174  usage_exit("missplaced/unknown option " + option);
2175  continue;
2176  }
2177  mSrcFiles.insert(option);
2178  }
2179 
2180  // figure destination
2181  for(;i<argc; i++) {
2182  std::string option(argv[i]);
2183  if(option.size()>1)
2184  if(option.at(0)=='-') {
2185  usage_exit("missplaced/unknown option " + option);
2186  continue;
2187  }
2188  mDstFile=option;
2189  }
2190 
2191  // test
2192  if(mDstFile=="") {
2193  usage_exit("no destination file specified");
2194  }
2195  bool dirdst=DirectoryExists(mDstFile);
2196 
2197  // load registry
2198  if(mRtiFile!="") {
2200  }
2201 
2202  // record plug-in and buil-in sections
2203  for(FunctionRegistry::Iterator fit=FunctionRegistry::G()->Begin();
2204  fit!=FunctionRegistry::G()->End(); fit++) {
2205  std::string section=fit->second->KeywordAt(0);
2206  std::transform(section.begin(), section.end(), section.begin(), tolower);
2207  mExclLuaSections.insert(section);
2208  }
2209 
2210  // extend registry
2211  if(mFlxFile!="") {
2213  }
2214 
2215  // record lua sections
2216  for(FunctionRegistry::Iterator fit=FunctionRegistry::G()->Begin();
2217  fit!=FunctionRegistry::G()->End(); fit++) {
2218  std::string section=fit->second->KeywordAt(0);
2219  std::transform(section.begin(), section.end(), section.begin(), tolower);
2220  mInclLuaSections.insert(section);
2221  }
2222 
2223 
2224  // include toc
2225  if(mIncludeFile!="") {
2227  RecordLiterature(tr);
2228  tr.Rewind();
2229  RecordPages(tr);
2230  }
2231 
2232 
2233  // special case: xtract fref
2234  if(xpage) {
2235  if(mSrcFiles.size()!=1) {
2236  usage_exit("extract mode requires one source file");
2237  }
2238  if(!dirdst) {
2239  usage_exit("extract mode requires destination directory");
2240  }
2241  std::cerr << "ref2html: extract pages from " << *mSrcFiles.begin() << std::endl;
2242  TokenReader tr(*mSrcFiles.begin());
2243  XtractPages(tr,mDstFile);
2244  tr.Rewind();
2245  XtractFiles(tr,mDstFile);
2246  exit(0);
2247  }
2248 
2249 
2250  // special case: generate toc
2251  if(dotoc) {
2252  if(dirdst) {
2253  usage_exit("toc mode requires destination file");
2254  }
2255  // output file
2256  std::ostream* hout= &std::cout;
2257  std::ofstream fout;
2258  if(mDstFile != "-") {
2259  fout.open(mDstFile.c_str(), std::ios::out);
2260  hout = &fout;
2261  }
2262  // process all input
2263  std::set< std::string >::iterator sit=mSrcFiles.begin();
2264  for(;sit!=mSrcFiles.end();++sit) {
2265  std::cerr << "ref2html: process toc " << *sit << std::endl;
2266  TokenReader tr(*sit);
2267  RecordLiterature(tr);
2268  tr.Rewind();
2269  RecordPages(tr);
2270  }
2271  // dump
2272  TokenWriter dst(*hout);
2273  DumpPages(dst);
2274  DumpLiterature(dst);
2275  dst.Flush();
2276  exit(0);
2277  }
2278 
2279  // special case: generate dox header/footer
2280  if(dodhd || dodft) {
2281  if(dirdst) {
2282  usage_exit("header-footer mode requires destination file");
2283  }
2284  // output file
2285  std::ostream* hout= &std::cout;
2286  std::ofstream fout;
2287  if(mDstFile != "-") {
2288  fout.open(mDstFile.c_str(), std::ios::out);
2289  hout = &fout;
2290  }
2291  // doit
2292  if(dodhd) DoxygenHeader(hout);
2293  if(dodft) DoxygenFooter(hout);
2294  exit(0);
2295  }
2296 
2297 
2298  // convert all source directories
2299  std::set< std::string > srcfiles;
2300  std::set< std::string >::iterator sit=mSrcFiles.begin();
2301  for(;sit!=mSrcFiles.end();++sit) {
2302  if(!DirectoryExists(*sit)) { srcfiles.insert(*sit); continue;}
2303  std::set< std::string > dirfiles = ReadDirectory(*sit);
2304  std::set< std::string >::iterator dit=dirfiles.begin();
2305  for(;dit!=dirfiles.end();++dit) {
2306  std::string ext = ExtractExtension(*dit);
2307  std::string base = ExtractBasename(*dit);
2308  std::string src= PrependDirectory(*sit,base + ".fref");
2309  // skip if not an fref file
2310  if(ext!="fref") continue;
2311  // record
2312  srcfiles.insert(src);
2313  }
2314  }
2315  mSrcFiles=srcfiles;
2316 
2317  // insist in target dir
2318  if(mSrcFiles.size()>1 && ! dirdst) {
2319  usage_exit("multiple source files require destination directory");
2320  }
2321 
2322 
2323  // do loop
2324  /*std::set< std::string >::iterator*/ sit=mSrcFiles.begin();
2325  for(;sit!=mSrcFiles.end();++sit) {
2326  std::string base = ExtractBasename(*sit);
2327  std::string src= *sit;
2328  std::string dst= mDstFile;
2329  if(dirdst) dst=PrependDirectory(mDstFile,base + ".html");
2330  // process
2331  if(mSrcFiles.size()>1)
2332  std::cout << "ref2html: processing " << src << " to " << dst << std::endl;
2333  std::ofstream fout;
2334  fout.open(dst.c_str(), std::ios::out);
2335  RefpageHtml(&fout,src);
2336  }
2337  exit(0);
2338 }
FAUDES_API const std::string & faudes_pathsep(void)
Definition: cfl_platform.h:185
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:501
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:53
bool IsBinary(void) const
Test token Type.
Definition: cfl_token.cpp:248
const std::string & PreceedingSpace(void) const
Preceeding space when writing to stream.
Definition: cfl_token.cpp:188
const std::string & StringValue(void) const
Get string value of a name token.
Definition: cfl_token.cpp:177
void ClrEnd(void)
Clear End type (resolve empty section)
Definition: cfl_token.cpp:160
bool ExistsAttributeString(const std::string &name)
Test attibute existence.
Definition: cfl_token.cpp:355
bool IsBegin(void) const
Test token Type.
Definition: cfl_token.cpp:258
void SetEmpty(const std::string &rName)
Initialize as empty-tag token.
Definition: cfl_token.cpp:105
void ClrAttribute(const std::string &name)
Clear attribute.
Definition: cfl_token.cpp:285
void SetBegin(const std::string &rName)
Initialize as Begin token.
Definition: cfl_token.cpp:91
void InsAttributeString(const std::string &name, const std::string &value)
Insert named attribute with string value.
Definition: cfl_token.cpp:309
bool IsEnd(void) const
Test token Type.
Definition: cfl_token.cpp:269
const std::string & AttributeStringValue(const std::string &name)
Access attribute value.
Definition: cfl_token.cpp:385
A TypeDefinition defines a faudes-type in that it specifies a faudes-type name to identify the type a...
Definition: cfl_types.h:1462
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:52
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_helper.cpp:131
std::string ExtractExtension(const std::string &rFullPath)
Extract file name from full path.
Definition: cfl_helper.cpp:294
std::string ExtractBasename(const std::string &rFullPath)
Extract file name from full path.
Definition: cfl_helper.cpp:280
std::string PluginsString()
Return FAUDES_PLUGINS as std::string.
Definition: cfl_helper.cpp:136
std::string PrependDirectory(const std::string &rDirectory, const std::string &rFileName)
Construct full path from directory and filename.
Definition: cfl_helper.cpp:309
std::string ExtractFilename(const std::string &rFullPath)
Extract file name from full path.
Definition: cfl_helper.cpp:271
std::string ContributorsString()
Return contributors as std::string.
Definition: cfl_helper.cpp:141
std::set< std::string > ReadDirectory(const std::string &rDirectory)
Read the contents of the specified directors.
Definition: cfl_helper.cpp:336
std::string StringSubstitute(const std::string &rString, const std::string &rFrom, const std::string &rTo)
Substitute in string.
Definition: cfl_helper.cpp:111
bool DirectoryExists(const std::string &rDirectory)
Test existence of directory.
Definition: cfl_helper.cpp:320
void SectionIndexHtml(std::ostream *pIndexFile, const std::string &key)
Definition: ref2html.cpp:1098
int main(int argc, char *argv[])
Definition: ref2html.cpp:2059
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:1969
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:1819
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:1521
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:2013
void ProcessSection(TokenWriter &rTw, TokenReader &rTr)
Definition: ref2html.cpp:1555
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.32b --- 2024.03.01 --- c++ api documentaion by doxygen