1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkOStreamWrapper.h,v $
6 Date: $Date: 2003/02/07 19:30:05 $
7 Version: $Revision: 1.7 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkOStreamWrapper - Wrapper for C++ ostream. Internal VTK use only.
19 // .SECTION Description
20 // Provides a wrapper around the C++ ostream so that VTK source files
21 // need not include the full C++ streams library. This is intended to
22 // prevent cluttering of the translation unit and speed up
23 // compilation. Experimentation has revealed between 10% and 60% less
24 // time for compilation depending on the platform. This wrapper is
25 // used by the macros in vtkSetGet.h.
27 #ifndef __vtkOStreamWrapper_h
28 #define __vtkOStreamWrapper_h
30 #ifndef __VTK_SYSTEM_INCLUDES__INSIDE
31 Do_not_include_vtkOStreamWrapper_directly__vtkSystemIncludes_includes_it;
36 class vtkLargeInteger;
37 class vtkSmartPointerBase;
39 class VTK_COMMON_EXPORT vtkOStreamWrapper
43 // Construct class to reference a real ostream. All methods and
44 // operators will be forwarded.
45 vtkOStreamWrapper(ostream& os);
46 vtkOStreamWrapper(vtkOStreamWrapper& r);
49 // Type for a fake endl.
53 // Forward this output operator to the real ostream.
54 vtkOStreamWrapper& operator << (const EndlType&);
55 vtkOStreamWrapper& operator << (const vtkIndent&);
56 vtkOStreamWrapper& operator << (vtkObjectBase&);
57 vtkOStreamWrapper& operator << (const vtkLargeInteger&);
58 vtkOStreamWrapper& operator << (const vtkSmartPointerBase&);
59 vtkOStreamWrapper& operator << (ostream&);
60 vtkOStreamWrapper& operator << (const char*);
61 vtkOStreamWrapper& operator << (void*);
62 vtkOStreamWrapper& operator << (char);
63 vtkOStreamWrapper& operator << (short);
64 vtkOStreamWrapper& operator << (int);
65 vtkOStreamWrapper& operator << (long);
66 vtkOStreamWrapper& operator << (unsigned char);
67 vtkOStreamWrapper& operator << (unsigned short);
68 vtkOStreamWrapper& operator << (unsigned int);
69 vtkOStreamWrapper& operator << (unsigned long);
70 vtkOStreamWrapper& operator << (float);
71 vtkOStreamWrapper& operator << (double);
73 // Need to switch on bool type because this wrapper is supposed to
74 // be as transparent as possible to user code. This example should
75 // not be used to justify using bool elsewhere in VTK.
76 #ifdef VTK_COMPILER_HAS_BOOL
77 vtkOStreamWrapper& operator << (bool);
80 #ifdef VTK_NEED_ID_TYPE_STREAM_OPERATORS
81 vtkOStreamWrapper& operator << (vtkIdType);
83 vtkOStreamWrapper& operator << (void (*)(void*));
84 vtkOStreamWrapper& operator << (void* (*)(void*));
85 vtkOStreamWrapper& operator << (int (*)(void*));
86 vtkOStreamWrapper& operator << (int* (*)(void*));
87 vtkOStreamWrapper& operator << (float* (*)(void*));
88 vtkOStreamWrapper& operator << (const char* (*)(void*));
89 vtkOStreamWrapper& operator << (void (*)(void*, int*));
92 // Forward the write method to the real stream.
93 vtkOStreamWrapper& write(const char*, unsigned long);
96 // Get a reference to the real ostream.
97 ostream& GetOStream();
100 // Allow conversion to the real ostream type. This allows an
101 // instance of vtkOStreamWrapper to look like ostream when passing to a
102 // function argument.
106 // Forward conversion to bool to the real ostream.
110 // Forward the flush method to the real ostream.
114 // Implementation detail to allow macros to provide an endl that may
115 // or may not be used.
116 static void UseEndl(const EndlType&) {}
118 // Reference to the real ostream.
121 vtkOStreamWrapper& operator=(const vtkOStreamWrapper& r); // Not Implemented.