Point Cloud Library (PCL)  1.14.1-dev
opennurbs_textlog.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(ON_TEXTLOG_INC_)
18 #define ON_TEXTLOG_INC_
19 
20 #include <pcl/pcl_exports.h>
21 
22 class PCL_EXPORTS ON_CLASS ON_TextLog
23 {
24 public:
25  /*
26  Description:
27  Create a text log that dumps to the virtual function
28  void ON_TextLog::AppendText().
29  */
31 
32  /*
33  Description:
34  Create a text log that dumps to an ASCII file.
35  Parameters:
36  fp - [in] Pointer to an open ASCII text file. The file
37  pointer must remain valid as long as the text
38  log is in use.
39  */
40  ON_TextLog( FILE* fp); // dump to open ASCII text file
41 
42  /*
43  Description:
44  Create a text log that dumps to a string.
45  Parameters:
46  s - [in] String that must exist as long as
47  the text log is in use.
48  */
50 
51  virtual ~ON_TextLog();
52 
53  void SetDoubleFormat( const char* ); // default is %g
54  void GetDoubleFormat( ON_String& ) const;
55 
56  void SetFloatFormat( const char* ); // default is %g
57  void GetFloatFormat( ON_String& ) const;
58 
59  void PushIndent();
60  void PopIndent();
61  int IndentSize() const; // 0: one tab per indent
62  // >0: number of spaces per indent
63  void SetIndentSize(int);
64 
65  void PrintWrappedText( const char*, int = 60 ); // last arg is maximum line length
66  void PrintWrappedText( const wchar_t*, int = 60 ); // last arg is maximum line length
67 
68  /*
69  Description:
70  Print a formatted ASCII string of up to 2000 characters.
71  Parameters:
72  format - [in] NULL terminated format control string
73  Remarks:
74  To print strings longer than 2000 characters, you must
75  use ON_TextLog::PrintString.
76  See Also:
77  ON_TextLog::PrintString
78  */
79  void Print( const char* format, ... );
80 
81  /*
82  Description:
83  Print a formatted INICODE string of up to 2000 characters.
84  Parameters:
85  format - [in] NULL terminated format control string
86  Remarks:
87  To print strings longer than 2000 characters, you must
88  use ON_TextLog::PrintString.
89  See Also:
90  ON_TextLog::PrintString
91  */
92  void Print( const wchar_t* format, ... );
93 
94  void Print( float );
95  void Print( double );
96  void Print( const ON_2dPoint& );
97  void Print( const ON_3dPoint& );
98  void Print( const ON_4dPoint& );
99  void Print( const ON_2dVector& );
100  void Print( const ON_3dVector& );
101  void Print( const ON_Xform& );
102  void Print( const ON_UUID& );
103  void Print( const ON_COMPONENT_INDEX& );
104 
105  /*
106  Description:
107  Print an unformatted UNICODE string of any length.
108  Parameters:
109  string - [in]
110  */
111  void Print( const ON_wString& string );
112 
113  /*
114  Description:
115  Print an unformatted ASCII string of any length.
116  Parameters:
117  string - [in]
118  */
119  void Print( const ON_String& string );
120 
121  void Print( const ON_3dPointArray&, const char* = NULL );
122  void Print(
123  const ON_Matrix&,
124  const char* = NULL, // optional preamble
125  int = 0 // optional number precision
126  );
127 
128  // printing utilities
129  /*
130  Description:
131  Same as calling Print("\n");
132  */
133  void PrintNewLine();
134 
135  /*
136  Description:
137  Print an unformatted ASCII string of any length.
138  Parameters:
139  s - [in] NULL terminated ASCII string.
140  */
141  void PrintString( const char* s );
142 
143  /*
144  Description:
145  Print an unformatted UNICODE string of any length.
146  Parameters:
147  s - [in] NULL terminated UNICODE string.
148  */
149  void PrintString( const wchar_t* s );
150 
151  void PrintRGB( const ON_Color& );
152 
153  void PrintTime( const struct tm& );
154 
156  int, // dim
157  ON_BOOL32, // true for rational points
158  int, // count
159  int, // stride
160  const double*, // point[] array
161  const char* = NULL // optional preabmle
162  );
163 
165  int, // dim
166  ON_BOOL32, // true for rational points
167  int, int, // point_count0, point_count1
168  int, int, // point_stride0, point_stride1
169  const double*, // point[] array
170  const char* = NULL // optional preabmle
171  );
172 
174  int, // order
175  int, // cv_count
176  const double* // knot[] array
177  );
178 
179  ON_TextLog& operator<<( const char* );
184  ON_TextLog& operator<<( double );
191 
192 protected:
193  FILE* m_pFile;
195 
196 
197  /*
198  Description:
199  If the ON_TextLog(ON_wString& wstr) constructor was used, the
200  default appends s to wstr. If the ON_TextLog(FILE* fp)
201  constructor was used, the default calls fputs( fp, s).
202  In all other cases, the default calls printf("%s",s).
203  Parameters:
204  s - [in];
205  */
206  virtual
208  const char* s
209  );
210 
211  /*
212  Description:
213  If the ON_TextLog(ON_wString& wstr) constructor was used, the
214  default appends s to wstr. In all other cases, the default
215  converts the string to an ON_String and calls the ASCII
216  version AppendText(const char*).
217  Parameters:
218  s - [in];
219  */
220  virtual
222  const wchar_t* s
223  );
224 
225 private:
226  ON_String m_indent;
227  ON_String m_double_format;
228  ON_String m_double2_format;
229  ON_String m_double3_format;
230  ON_String m_double4_format;
231  ON_String m_float_format;
232  ON_String m_float2_format;
233  ON_String m_float3_format;
234  ON_String m_float4_format;
235 
236  ON_String m_line;
237 
238  int m_beginning_of_line; // 0
239  int m_indent_size; // 0 use tabs, > 0 = number of spaces per indent level
240 
241 private:
242  // no implementation
243  ON_TextLog( const ON_TextLog& );
244  ON_TextLog& operator=( const ON_TextLog& );
245 
246 };
247 
248 
249 #endif
ON_TextLog & operator<<(double)
ON_TextLog & operator<<(float)
void Print(const ON_UUID &)
void PrintTime(const struct tm &)
ON_TextLog & operator<<(char)
void PrintWrappedText(const char *, int=60)
void PrintPointList(int, ON_BOOL32, int, int, const double *, const char *=NULL)
void PushIndent()
ON_wString * m_pString
void Print(const wchar_t *format,...)
ON_TextLog & operator<<(short)
void SetFloatFormat(const char *)
void PrintWrappedText(const wchar_t *, int=60)
void GetFloatFormat(ON_String &) const
void Print(const char *format,...)
void Print(const ON_Xform &)
void Print(const ON_3dVector &)
void Print(const ON_COMPONENT_INDEX &)
ON_TextLog(FILE *fp)
void PrintString(const wchar_t *s)
void Print(const ON_2dVector &)
virtual void AppendText(const char *s)
void Print(const ON_4dPoint &)
void Print(float)
void Print(const ON_String &string)
void Print(const ON_3dPoint &)
void Print(const ON_Matrix &, const char *=NULL, int=0)
void PrintNewLine()
void GetDoubleFormat(ON_String &) const
ON_TextLog & operator<<(const ON_Xform &)
virtual ~ON_TextLog()
void PopIndent()
void PrintString(const char *s)
int IndentSize() const
ON_TextLog & operator<<(const ON_2dPoint &)
ON_TextLog & operator<<(const ON_4dPoint &)
void SetDoubleFormat(const char *)
void SetIndentSize(int)
void PrintPointGrid(int, ON_BOOL32, int, int, int, int, const double *, const char *=NULL)
void PrintRGB(const ON_Color &)
void Print(const ON_3dPointArray &, const char *=NULL)
virtual void AppendText(const wchar_t *s)
ON_TextLog & operator<<(const char *)
ON_TextLog(ON_wString &s)
ON_TextLog & operator<<(const ON_3dPoint &)
void Print(const ON_2dPoint &)
ON_TextLog & operator<<(int)
ON_TextLog & operator<<(const ON_2dVector &)
ON_TextLog & operator<<(const ON_3dVector &)
void Print(double)
void PrintKnotVector(int, int, const double *)
void Print(const ON_wString &string)
#define PCL_EXPORTS
Definition: pcl_macros.h:325