VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
trpage_print.h
Go to the documentation of this file.
1 /* ************************
2  Copyright Terrain Experts Inc.
3  Terrain Experts Inc (TERREX) reserves all rights to this source code
4  unless otherwise specified in writing by the President of TERREX.
5  This copyright may be updated in the future, in which case that version
6  supercedes this one.
7  -------------------
8  Terrex Experts Inc.
9  4400 East Broadway #314
10  Tucson, AZ 85711
11  info@terrex.com
12  Tel: (520) 323-7990
13  ************************
14  */
15 
16 #ifndef trpage_print_h_
17 #define trpage_print_h_
18 
21 #include <stack>
22 
23 /* Print Buffer for TerraPage. Subclasses of this object
24  are used to print out to stdout or disk (or whatever).
25  You won't create one of these directly, instead you'll create
26  something which inherits from it.
27  */
29 {
30 public:
31  trpgPrintBuffer(void);
32  virtual ~trpgPrintBuffer(void) { };
33 
35  virtual bool isValid(void) { return true; }
36 
38  virtual bool prnLine(const char *str=NULL)=0;
39 
41  virtual void IncreaseIndent(int amount=1);
43  virtual void DecreaseIndent(int amount=1);
44 protected:
45  void updateIndent(void);
46  int curIndent;
47  char indentStr[200];
48 };
49 
50 /* File print buffer for TerraPage. The file print buffer writes
51  debugging output to a file.
52 */
54 public:
56  trpgFilePrintBuffer(FILE *);
57  trpgFilePrintBuffer(char*);
58  virtual ~trpgFilePrintBuffer(void) override;
59 
61  virtual bool isValid(void) override { return valid; };
62 
64  virtual bool prnLine(const char* str = NULL) override;
65 protected:
66  bool valid;
67  bool isMine;
68  FILE *fp;
69 };
70 
71 /* The Print Graph Parser is a scene graph parser that
72  prints out the scene graph as it goes. It's simpler
73  than the scene example in trpage_scene.cpp since it
74  isn't trying to build up a working scene graph.
75 */
77 {
78 public:
80  virtual ~trpgPrintGraphParser(void) override { };
81 
83  void Reset();
84 
86  unsigned int GetNbChildrenRef() const;
89  const trpgChildRef* GetChildRef(unsigned int idx) const;
90 
91  /* The read helper class is the callback for all the various
92  token (node) types. Normally we would use a number of
93  these, probably one per token. However, since we're just
94  printing we can use a switch statement instead.
95  */
96  class ReadHelper : public trpgr_Callback
97  {
98  public:
105  typedef std::vector<trpgChildRef> ChildRefList;
106 
108  : pBuf(inBuf)
109  , parse(inPG)
110  {
111  }
112  virtual ~ReadHelper() override { Reset(); }
113 
114  virtual void * Parse(trpgToken, trpgReadBuffer& buf) override;
115  void Reset();
117  unsigned int GetNbChildrenRef() const;
120  const trpgChildRef* GetChildRef(unsigned int idx) const;
121  protected:
124 
125  private:
126 
128  };
129 
131  trpgr_Archive *GetArchive() {return archive; };
132  trpgrImageHelper *GetImageHelp() {return imageHelp; };
133 
134 protected:
135  virtual bool StartChildren(void*) override;
136  virtual bool EndChildren(void*) override;
137 
141 
143 
144 };
145 
147 
148 #define TRPGPRN_ALL -1
149 #define TRPGPRN_HEADER (1<<0)
150 #define TRPGPRN_BODY (1<<1)
153 
154 #endif
TX_CPPDECL bool trpgPrintArchive(char *filename, trpgPrintBuffer &pBuf, int flags=TRPGPRN_ALL)
virtual bool isValid(void)
Check if print buffer is valid.
Definition: trpage_print.h:35
virtual ~trpgPrintGraphParser(void) override
Definition: trpage_print.h:80
int curIndent
Definition: trpage_print.h:46
Definition: trpage_read.h:256
bool valid
Definition: trpage_print.h:66
#define TRPGPRN_ALL
Print utitility for while archive.
Definition: trpage_print.h:148
ReadHelper(trpgPrintGraphParser *inPG, trpgPrintBuffer *inBuf)
Definition: trpage_print.h:107
#define DT_DLL_osgdb_vrftxp
Contains DLL export macros.
Definition: osgdb_vrftxpDefines.h:25
trpgPrintGraphParser * parse
Definition: trpage_print.h:123
Definition: trpage_print.h:53
trpgrImageHelper * imageHelp
Definition: trpage_print.h:140
std::vector< trpgChildRef > ChildRefList
typedef std::vector&lt;const trpgChildRef&gt; ChildRefList; The const in the template parameter was removed b...
Definition: trpage_print.h:105
virtual ~trpgPrintBuffer(void)
Definition: trpage_print.h:32
trpgr_Archive * archive
Definition: trpage_print.h:139
trpgrImageHelper * GetImageHelp()
Definition: trpage_print.h:132
voidpf void * buf
Definition: ioapi.h:39
Definition: trpage_print.h:96
virtual bool prnLine(const char *str=NULL)=0
The main print function. Subclasses must fill this in.
Definition: trpage_geom.h:2476
bool isMine
Definition: trpage_print.h:67
Definition: trpage_print.h:76
trpgPrintBuffer * pBuf
Definition: trpage_print.h:122
#define TX_CPPDECL
Exports a C++ function properly in a windows DLL.
Definition: trdll.h:71
ChildRefList childRefList
Definition: trpage_print.h:127
Definition: trpage_read.h:185
{secret}
Definition: trpage_read.h:32
ReadHelper * childRefCB
Definition: trpage_print.h:142
Definition: trpage_print.h:28
FILE * fp
Definition: trpage_print.h:68
virtual bool isValid(void) override
Check if file print buffer is valid (i.e. if file was opened)
Definition: trpage_print.h:61
trpgr_Archive * GetArchive()
Fetch the archive associated with this print.
Definition: trpage_print.h:131
virtual bool EndChildren(void *)
Definition: trpage_read.h:267
Definition: trpage_read.h:99
#define TX_EXDECL
Goes before &quot;class&quot; to handle DLL export in windows.
Definition: trdll.h:69
Definition: trpage_io.h:452
virtual bool StartChildren(void *)
Start defining children for the given object.
Definition: trpage_read.h:266
virtual ~ReadHelper() override
Definition: trpage_print.h:112
trpgPrintBuffer * printBuf
Definition: trpage_print.h:138
short trpgToken
16 bit token definition value. These are values such as TRPGTEXTABLE or TRPG_ATTACH, etc...
Definition: trpage_io.h:61

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)