cebe4f08e7ee6d7ecba6520fbc524884d952ce3a
[Faustine.git] / interpretor / faust-0.9.47mr3 / compiler / documentator / doc_notice.cpp
1 /************************************************************************
2 ************************************************************************
3 FAUST compiler
4 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
5 ---------------------------------------------------------------------
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ************************************************************************
20 ************************************************************************/
21
22
23 #include <iostream>
24 #include <fstream>
25 #include <set>
26 #include <time.h>
27 #include <cstdlib>
28 #include <errno.h>
29
30 #include "doc_notice.hh"
31 #include "doc_lang.hh"
32 #include "enrobage.hh"
33 #include "compatibility.hh"
34
35
36 map<string, bool> gDocNoticeFlagMap;
37
38 map<string, string> gDocNoticeStringMap;
39 set<string> gDocNoticeKeySet;
40
41 extern map<string, string> gDocAutodocStringMap;
42
43 extern string gMasterName;
44
45 static void initDocNoticeKeySet();
46 static void initDocNoticeFlagMap();
47
48
49
50 /*****************************************************************************
51 Public functions
52 *****************************************************************************/
53
54 /**
55 * Print the content of the notice (a string map),
56 * as LaTeX items inside an itemize environment.
57 *
58 * @remark
59 * This function is meant to make it easier to reorder
60 * the notice printing by gathering all the items.
61 *
62 * @param[in] notice The set containing the strings to print as items.
63 * @param[in] faustversion The current version of this Faust compiler.
64 * @param[out] docout The LaTeX output file to print into.
65 */
66 void printDocNotice(const string& faustversion, ostream& docout) {
67
68 if (! gDocNoticeStringMap.empty() ) {
69
70 //cerr << "Documentator : printDocNotice : printing..." << endl;
71
72 docout << endl << "\\begin{itemize}" << endl;
73
74 /* Presentations. */
75 docout << "\t\\item " << gDocAutodocStringMap["autontctext"] << endl;
76 if(gDocNoticeFlagMap["faustapply"]) docout << "\t\\item " << gDocNoticeStringMap["faustapply"] << endl;
77 if(gDocNoticeFlagMap["faustpresentation"]) docout << "\t\\item " << gDocNoticeStringMap["faustpresentation"] << endl;
78 if(gDocNoticeFlagMap["causality"]) docout << "\t\\item " << gDocNoticeStringMap["causality"] << endl;
79 if(gDocNoticeFlagMap["blockdiagrams"]) docout << "\t\\item " << gDocNoticeStringMap["blockdiagrams"] << endl;
80
81 /* Naming conventions of variables and functions. */
82 if(gDocNoticeFlagMap["foreignfun"]) docout << "\t\\item " << gDocNoticeStringMap["foreignfun"] << endl;
83 if(gDocNoticeFlagMap["intcast"]) docout << "\t\\item " << gDocNoticeStringMap["intcast"] << endl;
84
85 /* Integer arithmetic into a tabular environment. */
86 if(gDocNoticeFlagMap["intplus"] ||
87 gDocNoticeFlagMap["intminus"] ||
88 gDocNoticeFlagMap["intmult"] ||
89 gDocNoticeFlagMap["intdiv"] ||
90 gDocNoticeFlagMap["intand"] ||
91 gDocNoticeFlagMap["intor"] ||
92 gDocNoticeFlagMap["intxor"])
93 {
94 gDocNoticeFlagMap["operators"] = true;
95 gDocNoticeFlagMap["optabtitle"] = true;
96 gDocNoticeFlagMap["integerops"] = true;
97
98 docout << "\t\\item " << endl;
99 docout << "\t\t" << gDocNoticeStringMap["operators"] << endl;
100 docout << "\t\\begin{center}" << endl;
101 docout << "\t\\begin{tabular}{|c|l|l|} " << endl;
102 docout << "\t\t\\hline " << endl;
103 docout << "\t\t" << gDocNoticeStringMap["optabtitle"] << endl;
104 docout << "\t\t\\hline " << endl;
105 if(gDocNoticeFlagMap["intplus"]) docout << "\t\t" << gDocNoticeStringMap["intplus"] << endl;
106 if(gDocNoticeFlagMap["intminus"]) docout << "\t\t" << gDocNoticeStringMap["intminus"] << endl;
107 if(gDocNoticeFlagMap["intmult"]) docout << "\t\t" << gDocNoticeStringMap["intmult"] << endl;
108 if(gDocNoticeFlagMap["intdiv"]) docout << "\t\t" << gDocNoticeStringMap["intdiv"] << endl;
109 if(gDocNoticeFlagMap["intand"]) docout << "\t\t" << gDocNoticeStringMap["intand"] << endl;
110 if(gDocNoticeFlagMap["intor"]) docout << "\t\t" << gDocNoticeStringMap["intor"] << endl;
111 if(gDocNoticeFlagMap["intxor"]) docout << "\t\t" << gDocNoticeStringMap["intxor"] << endl;
112 docout << "\t\t\\hline " << endl;
113 docout << "\t\\end{tabular} " << endl;
114 docout << "\t\\end{center}" << endl;
115 docout << "\t\t" << gDocNoticeStringMap["integerops"] << endl;
116 }
117
118 if(gDocNoticeFlagMap["faustdocdir"]) docout << "\t\\item " << gDocNoticeStringMap["faustdocdir"] << endl;
119
120 docout << "\\end{itemize}" << endl << endl;
121 }
122 //cerr << " ... Documentator : printDocNotice : end of printing." << endl;
123 }
124
125
126 /**
127 * Dispatch initialization of notice containers,
128 * after default notice file loading.
129 *
130 * @remark
131 * The default (english) notice is already loaded at this stage
132 * to ensure that all keywords will receive a definition.
133 */
134 void initDocNotice()
135 {
136 initDocNoticeKeySet();
137 initDocNoticeFlagMap();
138 }
139
140
141
142
143 /*****************************************************************************
144 Static functions
145 *****************************************************************************/
146
147
148 /**
149 * Initialize gDocNoticeKeySet, a set containing all the keywords.
150 */
151 static void initDocNoticeKeySet() {
152
153 gDocNoticeKeySet.insert("faustpresentation");
154 gDocNoticeKeySet.insert("faustapply");
155 gDocNoticeKeySet.insert("faustdocdir");
156 gDocNoticeKeySet.insert("causality");
157 gDocNoticeKeySet.insert("blockdiagrams");
158
159 gDocNoticeKeySet.insert("foreignfun");
160 gDocNoticeKeySet.insert("intcast");
161
162 gDocNoticeKeySet.insert("operators");
163 gDocNoticeKeySet.insert("optabtitle");
164 gDocNoticeKeySet.insert("integerops");
165 gDocNoticeKeySet.insert("intplus");
166 gDocNoticeKeySet.insert("intminus");
167 gDocNoticeKeySet.insert("intmult");
168 gDocNoticeKeySet.insert("intdiv");
169 gDocNoticeKeySet.insert("intand");
170 gDocNoticeKeySet.insert("intor");
171 gDocNoticeKeySet.insert("intxor");
172 }
173
174
175 /**
176 * Initialize gDocNoticeFlagMap, a map containing all the flags.
177 */
178 static void initDocNoticeFlagMap() {
179
180 for (set<string>::iterator it=gDocNoticeKeySet.begin(); it != gDocNoticeKeySet.end() ; ++it ) {
181 gDocNoticeFlagMap[*it] = false;
182 }
183 gDocNoticeFlagMap["faustpresentation"] = true;
184 gDocNoticeFlagMap["faustapply"] = true;
185 gDocNoticeFlagMap["faustdocdir"] = true;
186 gDocNoticeFlagMap["causality"] = true;
187 gDocNoticeFlagMap["blockdiagrams"] = true;
188 }
189