OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkOStreamWrapper.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkOStreamWrapper.h,v $
5   Language:  C++
6   Date:      $Date: 2003/02/07 19:30:05 $
7   Version:   $Revision: 1.7 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
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.
16
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.
26
27 #ifndef __vtkOStreamWrapper_h
28 #define __vtkOStreamWrapper_h
29
30 #ifndef __VTK_SYSTEM_INCLUDES__INSIDE
31 Do_not_include_vtkOStreamWrapper_directly__vtkSystemIncludes_includes_it;
32 #endif
33
34 class vtkIndent;
35 class vtkObjectBase;
36 class vtkLargeInteger;
37 class vtkSmartPointerBase;
38
39 class VTK_COMMON_EXPORT vtkOStreamWrapper
40 {
41 public:
42   // Description:
43   // Construct class to reference a real ostream.  All methods and
44   // operators will be forwarded.
45   vtkOStreamWrapper(ostream& os);
46   vtkOStreamWrapper(vtkOStreamWrapper& r);
47   
48   // Description:
49   // Type for a fake endl.
50   struct EndlType {};
51   
52   // Description:
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);
72
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);
78 #endif
79   
80 #ifdef VTK_NEED_ID_TYPE_STREAM_OPERATORS
81   vtkOStreamWrapper& operator << (vtkIdType);
82 #endif
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*));
90   
91   // Description:
92   // Forward the write method to the real stream.
93   vtkOStreamWrapper& write(const char*, unsigned long);
94   
95   // Description:
96   // Get a reference to the real ostream.
97   ostream& GetOStream();
98
99   // Description:
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.
103   operator ostream&();
104
105   // Description:
106   // Forward conversion to bool to the real ostream.
107   operator int();
108   
109   // Description:
110   // Forward the flush method to the real ostream.
111   void flush();
112   
113   // Description:
114   // Implementation detail to allow macros to provide an endl that may
115   // or may not be used.
116   static void UseEndl(const EndlType&) {}
117 protected:
118   // Reference to the real ostream.
119   ostream& ostr;
120 private:
121   vtkOStreamWrapper& operator=(const vtkOStreamWrapper& r); // Not Implemented.
122 };
123
124 #endif