File: Man.h

package info (click to toggle)
inventor 2.1.5-10-21
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 36,312 kB
  • sloc: ansic: 33,864; lisp: 7,361; cpp: 3,874; yacc: 369; sh: 359; perl: 234; awk: 141; makefile: 81; csh: 35; sed: 11
file content (437 lines) | stat: -rw-r--r-- 11,225 bytes parent folder | download | duplicates (8)
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
/*
 *
 *  Copyright (C) 2000 Silicon Graphics, Inc.  All Rights Reserved. 
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library 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
 *  Lesser General Public License for more details.
 *
 *  Further, this software is distributed without any warranty that it is
 *  free of the rightful claim of any third person regarding infringement
 *  or the like.  Any license provided herein, whether implied or
 *  otherwise, applies only to this software file.  Patent licenses, if
 *  any, provided herein do not apply to combinations of this program with
 *  other software, or any other product whatsoever.
 * 
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
 *  Mountain View, CA  94043, or:
 * 
 *  http://www.sgi.com 
 * 
 *  For further information regarding this notice, see: 
 * 
 *  http://oss.sgi.com/projects/GenInfo/NoticeExplan/
 *
 */

#include <Inventor/SbString.h>
#include <Inventor/SoType.h>

enum Language {
    ALL,
    C,
    C_PLUS_PLUS
};

class Reader {
  public:
    static SbBool	open(const char *pathName);
    static SbBool	open(const char *dirName, const char *fileName);
    static void		error(const char *what);
    static SbBool	readName(SbName &name);
    static SbBool	readString(SbString &string);
    static SbBool	readBracketed(SbString &string);
    static SbBool	readUpTo(int endChar, SbString &string);
    static void		skipWhiteSpace();
    static int		get();
    static void		putBack(int c);
    // Removes tabs, newlines, and extra spaces
    static void		cleanString(SbString &string, SbBool inCode = FALSE,
				SbBool changeSbName = TRUE);
  private:
    static FILE		*fp;
    static int		lineNum;
    static char		*fullName;
    static SbBool	readBuf(char *buf, SbBool isName);
};

class Writer {
  public:
    enum Font {
	TEXT_ROMAN,	// Fonts for text descriptions
	TEXT_ITALIC,
	TEXT_BOLD,
	CODE_ROMAN,	// Fonts for code (method, field, ...) specifications
	CODE_BOLD,
	FIXED_ROMAN,	// Fonts for fixed-width code
	FIXED_BOLD,
	PREVIOUS	// Previous font
    };
    static void		setPointer(FILE *filePointer) { fp = filePointer; }
    static void		setSourceFileName(char *f) { sourceFileName = strdup(f); }
    static SbBool	open(const char *, const char *fileName);
    static void		setInSynopsis(SbBool flag) { inSynopsis = flag; }
    static SbBool	getInSynopsis()		   { return inSynopsis; }
    static void		setLanguage(Language lang) { language = lang; }
    static Language	getLanguage()		   { return language; }
    static void		setForBook(SbBool flag)	   { forBook = flag; }
    static SbBool	isForBook()		   { return forBook; }
    static void		writePreface(const SbName &className);
    static void		startSection(const char *name);
    static void		setFont(Font newFont);
    static void		changeSize(float diff);
    static void		setBaseIndent(float indInInches);
    static void		setIndent(int numChars, int firstLineChars);
    static void		setTab(int numTabChars);
    static void		indentForTab();
    static void		tab();
    static void		setFill(SbBool flag);
    static void		breakLine();
    static void		space(float amt = 1.0);
    static void		write(const char *string);
    static void		write(const SbName &name);
    static void		write(const SbString &string);
    static void		writeBracketed(const SbString &string);
    static void		writeDescription(const SbString &string);
    static void		finish();
  private:
    static FILE		*fp;
    static char		*fullName;
    static char		*sourceFileName;
    static SbBool	inSynopsis;
    static Language	language;
    static SbBool	forBook;
    static float	baseIndent;
    static int		numTabChars;
    static SbBool	indentedForTab;

    static const char *	writeStuff(const char *string,
				   SbBool compressSpace, int blockChar);
    static const char *	startBlock(const char *string, SbBool compressSpace);
    static const char *	endBlock(const char *string, int blockChar);
    static const char *	skipBlock(const char *string);
};

class Item {
  public:
    Item 		*next;
    Language		language;
    SbBool		hasNextToWrite();
    static void		setCurLanguage(Language lang) { curLanguage = lang; }
    virtual void	write(SbBool runIn) = 0;
    virtual SbBool	read()  = 0;
    virtual int		getNumPreTabChars() const;
    virtual             ~Item() {}
  protected:
    Item();
  private:
    static Language	curLanguage;
};

class ItemList {
  public:
    Item		*first, *last;
    ItemList()		{ first = last = NULL; }
    SbBool		isEmpty() const;
    int			getNum() const;
    // if append is FALSE, add at start of list; else add to end
    void		add(Item *item, SbBool append = TRUE);
    void		write(SbBool runIn = FALSE);
};

class Inherit : public Item {
  public:
    Inherit(const SbName &name);
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
  private:
    SbName		className;
};

class Include : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
  private:
    SbString		file;
};

class Typedef : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
    virtual int		getNumPreTabChars() const;
  private:
    SbString		type, extra;
    SbName		name;
friend class ClassDef;
};

class Define : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
  private:
    SbString		definition;
};

class EnumDef : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
    virtual int		getNumPreTabChars() const;
  private:
    SbName		name;
    SbString		description;
};

class Enum : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
  private:
    SbName		name;
    ItemList		defs;
};

class Field : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
    virtual int		getNumPreTabChars() const;
  protected:
    SbName		name, type;
    SbString		description;
    SbBool		readStuff();
friend class ClassDef;
};

class Input : public Field {
  public:
    Input();
    virtual SbBool	read();
};

class Output : public Field {
  public:
    Output();
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
    virtual int		getNumPreTabChars() const;
};

class Part : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
    virtual int		getNumPreTabChars() const;
  private:
    SbName		name, type;
    SbString		description;
friend class ClassDef;
};

class Method : public Item {
  public:
    Method();
    ~Method();
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
    virtual int		getNumPreTabChars() const;
  private:
    enum Type {
	CONSTRUCTOR,
	DESTRUCTOR,
	OPERATOR,
	REGULAR
    };

    SbString		full, description;
    SbName		name, cName;
    SbString		pre, post;
    Type		type;
    SbBool		skipThis;
    SbBool		isHidden;
    SbBool		isStatic;
    SbBool		isVirtual;
    SbBool		isFriend;
    SbBool		isConst;
    SbBool		parse();
    void		writeName();
friend class ClassDef;
};

class Macro : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
  private:
    SbName		name;
    SbString		arguments, description;
};

class ActionName : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
  private:
    SbName		name;
};

class Action : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
  private:
    ItemList		names;
    SbString		description;
};

class Misc : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
  private:
    SbName		name;
    SbString		description;
};

class Also : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
  private:
    SbString		list;
};

class DraggerResourcePartDef : public Item {
  public:
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
  private:
    SbName		name;
friend class DraggerResource;
};

class DraggerResource : public Item {
  public:
    DraggerResource();
    virtual SbBool	read();
    virtual void	write(SbBool runIn);
    virtual int		getNumPreTabChars() const;
    int                 getNumPartDefs() const { return parts.getNum(); }
    const SbName        &getPartDefName( int which ) const;
    const SbName        &getResourceName() const { return name; }
  private:
    SbName		name;
    ItemList		parts;
    SbString		description;
    SbString		defaultGeom;
};

class ClassDef {

  public:
    ClassDef();
    ~ClassDef();

    const SbName &	getName() const		{ return name; }
    const SbName &	getCPrefix() const	{ return cPrefix; }
    const SbName &	getCEnumPrefix() const	{ return cEnumPrefix; }

    void		addInherit(ClassDef *def);
    void		setParent(ClassDef *parent) { parentClass = parent; }
    SbBool		read();
    SbBool		setUp(const ClassDef *mainDef);
    void		cullMethods();
    void		write(SbBool runIn);

    static const ClassDef *	getCurClass()	{ return curClass; }

  private:
    enum StatementType {
	NAME,
	DESCRIPTION,
	INCLUDE,
	TYPEDEF,
	DEFINE,
	ENUM,
	FIELD,
	INPUT,
	OUTPUT,
	PART,
	METHOD,
	MACRO,
	ACTION,
	MISC,
	ALSO,
	BEGIN,
	END,
	DRAGGER_RESOURCE,
	UNKNOWN
    };

    static const ClassDef *curClass;

    ClassDef		*parentClass;
    SoType		type;
    SbBool		isAbstract;
    void		*instance;

    SbName		name, cPrefix, cEnumPrefix;
    SbString		shortDescription, longDescription;
    SbString		catalog;
    SbBool		hasFileFormat;
    SbString		fileFormat;
    int			fileFormatTabLength;

    ItemList		inherits;
    ItemList		includes;
    ItemList		typedefs;
    ItemList		defines;
    ItemList		enums;
    ItemList		fields;
    ItemList		inputs;
    ItemList		outputs;
    ItemList		parts;
    ItemList		methods;
    ItemList		macros;
    ItemList		actions;
    ItemList		miscs;
    ItemList		alsos;
    ItemList		draggerResources;

    SbBool		readItem(Item *item, ItemList *list);
    static StatementType getStatementType(const SbName &keyword);
    SbBool		setUpTypedefs();
    SbBool		setUpFields();
    SbBool		setUpInputs();
    SbBool		setUpOutputs();
    SbBool		setUpParts();
    SbBool		setUpCatalog();
    SbBool		setUpFileFormat();
    void *		getInstance();
    void		writeForBook();
    void		writeForNonBook();
    void		writeName();
    void		writeSynopsis();
    void		writeFileFormat();
    void		writeFromClass(ItemList *list, const char *whats,
				       SbBool runIn = FALSE);
};

#define QUOTE_CHAR	'"'
#define OPEN_CHAR	'{'
#define CLOSE_CHAR	'}'
#define COMMENT_CHAR	'#'
#define SEP_CHAR	','