File: doc_notice.cpp

package info (click to toggle)
faust 0.9.46-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 15,256 kB
  • ctags: 9,961
  • sloc: cpp: 47,746; sh: 2,254; ansic: 1,503; makefile: 1,211; ruby: 950; yacc: 468; objc: 459; lex: 200; xml: 177
file content (189 lines) | stat: -rw-r--r-- 6,911 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/************************************************************************
 ************************************************************************
 FAUST compiler
 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
 ---------------------------------------------------------------------
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 ************************************************************************
 ************************************************************************/


#include <iostream>
#include <fstream>
#include <set>
#include <time.h>
#include <cstdlib>
#include <errno.h>

#include "doc_notice.hh"
#include "doc_lang.hh"
#include "enrobage.hh"
#include "compatibility.hh"


map<string, bool>	gDocNoticeFlagMap;

map<string, string>	gDocNoticeStringMap;
set<string>			gDocNoticeKeySet;

extern map<string, string>		gDocAutodocStringMap;

extern string		gMasterName;

static void			initDocNoticeKeySet();
static void			initDocNoticeFlagMap();



/*****************************************************************************
							Public functions
 *****************************************************************************/

/** 
 * Print the content of the notice (a string map),
 * as LaTeX items inside an itemize environment.
 *
 * @remark 
 * This function is meant to make it easier to reorder
 * the notice printing by gathering all the items.
 *
 * @param[in]	notice			The set containing the strings to print as items.
 * @param[in]	faustversion	The current version of this Faust compiler.
 * @param[out]	docout			The LaTeX output file to print into.
 */
void printDocNotice(const string& faustversion, ostream& docout) {
	
	if (! gDocNoticeStringMap.empty() ) {
		
		//cerr << "Documentator : printDocNotice : printing..." << endl;
		
		docout << endl << "\\begin{itemize}" << endl;
		
		/* Presentations. */
		docout << "\t\\item " << gDocAutodocStringMap["autontctext"]	<< endl;
		if(gDocNoticeFlagMap["faustapply"])			docout << "\t\\item " << gDocNoticeStringMap["faustapply"]	<< endl;
		if(gDocNoticeFlagMap["faustpresentation"])	docout << "\t\\item " << gDocNoticeStringMap["faustpresentation"]	<< endl;
		if(gDocNoticeFlagMap["causality"])			docout << "\t\\item " << gDocNoticeStringMap["causality"]	<< endl;
		if(gDocNoticeFlagMap["blockdiagrams"])		docout << "\t\\item " << gDocNoticeStringMap["blockdiagrams"]	<< endl;
		
		/* Naming conventions of variables and functions. */
		if(gDocNoticeFlagMap["foreignfun"])		docout << "\t\\item " << gDocNoticeStringMap["foreignfun"]	<< endl;
		if(gDocNoticeFlagMap["intcast"])		docout << "\t\\item " << gDocNoticeStringMap["intcast"]	<< endl;
		
		/* Integer arithmetic into a tabular environment. */
		if(gDocNoticeFlagMap["intplus"] || 
		   gDocNoticeFlagMap["intminus"] || 
		   gDocNoticeFlagMap["intmult"] || 
		   gDocNoticeFlagMap["intdiv"] || 
		   gDocNoticeFlagMap["intand"] || 
		   gDocNoticeFlagMap["intor"] || 
		   gDocNoticeFlagMap["intxor"])
		{
			gDocNoticeFlagMap["operators"]		= true;
			gDocNoticeFlagMap["optabtitle"]		= true;
			gDocNoticeFlagMap["integerops"]		= true;
			
			docout << "\t\\item " << endl;
			docout << "\t\t" << gDocNoticeStringMap["operators"] << endl;
			docout << "\t\\begin{center}" << endl;
			docout << "\t\\begin{tabular}{|c|l|l|} " << endl;
			docout << "\t\t\\hline " << endl;
			docout << "\t\t" << gDocNoticeStringMap["optabtitle"]	<< endl;
			docout << "\t\t\\hline " << endl;
			if(gDocNoticeFlagMap["intplus"])	docout << "\t\t" << gDocNoticeStringMap["intplus"]	<< endl;
			if(gDocNoticeFlagMap["intminus"])	docout << "\t\t" << gDocNoticeStringMap["intminus"]	<< endl;
			if(gDocNoticeFlagMap["intmult"])	docout << "\t\t" << gDocNoticeStringMap["intmult"]	<< endl;
			if(gDocNoticeFlagMap["intdiv"])		docout << "\t\t" << gDocNoticeStringMap["intdiv"]	<< endl;
			if(gDocNoticeFlagMap["intand"])		docout << "\t\t" << gDocNoticeStringMap["intand"]	<< endl;
			if(gDocNoticeFlagMap["intor"])		docout << "\t\t" << gDocNoticeStringMap["intor"]	<< endl;
			if(gDocNoticeFlagMap["intxor"])		docout << "\t\t" << gDocNoticeStringMap["intxor"]	<< endl;
			docout << "\t\t\\hline " << endl;
			docout << "\t\\end{tabular} " << endl;
			docout << "\t\\end{center}" << endl;
			docout << "\t\t" << gDocNoticeStringMap["integerops"]	<< endl;
		}

		if(gDocNoticeFlagMap["faustdocdir"])		docout << "\t\\item " << gDocNoticeStringMap["faustdocdir"]	<< endl;

		docout << "\\end{itemize}" << endl << endl;
	}
	//cerr << "  ... Documentator : printDocNotice : end of printing." << endl;
}


/** 
 * Dispatch initialization of notice containers,
 * after default notice file loading.
 *
 * @remark
 * The default (english) notice is already loaded at this stage
 * to ensure that all keywords will receive a definition.
 */
void initDocNotice() 
{
	initDocNoticeKeySet();
	initDocNoticeFlagMap();
}




/*****************************************************************************
								Static functions
 *****************************************************************************/


/** 
 * Initialize gDocNoticeKeySet, a set containing all the keywords.
 */
static void initDocNoticeKeySet() {
	
	gDocNoticeKeySet.insert("faustpresentation");
	gDocNoticeKeySet.insert("faustapply");
	gDocNoticeKeySet.insert("faustdocdir");
	gDocNoticeKeySet.insert("causality");
	gDocNoticeKeySet.insert("blockdiagrams");
	
	gDocNoticeKeySet.insert("foreignfun");
	gDocNoticeKeySet.insert("intcast");
	
	gDocNoticeKeySet.insert("operators");
	gDocNoticeKeySet.insert("optabtitle");
	gDocNoticeKeySet.insert("integerops");
	gDocNoticeKeySet.insert("intplus");
	gDocNoticeKeySet.insert("intminus");
	gDocNoticeKeySet.insert("intmult");
	gDocNoticeKeySet.insert("intdiv");
	gDocNoticeKeySet.insert("intand");
	gDocNoticeKeySet.insert("intor");
	gDocNoticeKeySet.insert("intxor");
}


/** 
 * Initialize gDocNoticeFlagMap, a map containing all the flags.
 */
static void initDocNoticeFlagMap() {
	
	for (set<string>::iterator it=gDocNoticeKeySet.begin(); it != gDocNoticeKeySet.end() ; ++it ) {
		gDocNoticeFlagMap[*it] = false;
	}
	gDocNoticeFlagMap["faustpresentation"]	= true;
	gDocNoticeFlagMap["faustapply"]			= true;
	gDocNoticeFlagMap["faustdocdir"]		= true;
	gDocNoticeFlagMap["causality"]			= true;
	gDocNoticeFlagMap["blockdiagrams"]		= true;
}