VTK
vtkOStreamWrapper.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOStreamWrapper.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
27 #ifndef vtkOStreamWrapper_h
28 #define vtkOStreamWrapper_h
29 
30 #include "vtkCommonCoreModule.h"
31 
32 #ifndef __VTK_SYSTEM_INCLUDES__INSIDE
34 #endif
35 
36 class vtkIndent;
37 class vtkObjectBase;
38 class vtkLargeInteger;
40 // workaround clang bug, needs export on forward declaration
41 #ifdef __clang__
42 class VTKCOMMONCORE_EXPORT vtkStdString;
43 #else
44 class vtkStdString;
45 #endif
46 
47 class VTKCOMMONCORE_EXPORT vtkOStreamWrapper
48 {
49  class std_string;
50 public:
52 
56  vtkOStreamWrapper(ostream& os);
59 
60  virtual ~vtkOStreamWrapper();
61 
65  struct EndlType {};
66 
68 
77  vtkOStreamWrapper& operator << (const char*);
83  vtkOStreamWrapper& operator << (long long);
84  vtkOStreamWrapper& operator << (unsigned char);
85  vtkOStreamWrapper& operator << (unsigned short);
86  vtkOStreamWrapper& operator << (unsigned int);
87  vtkOStreamWrapper& operator << (unsigned long);
88  vtkOStreamWrapper& operator << (unsigned long long);
93 
94  // Work-around for IBM Visual Age bug in overload resolution.
95 #if defined(__IBMCPP__)
96  vtkOStreamWrapper& WriteInternal(const char*);
97  vtkOStreamWrapper& WriteInternal(void*);
98  template <typename T>
100  {
101  return this->WriteInternal(p);
102  }
103 #endif
104 
105  vtkOStreamWrapper& operator << (void (*)(void*));
106  vtkOStreamWrapper& operator << (void* (*)(void*));
107  vtkOStreamWrapper& operator << (int (*)(void*));
108  vtkOStreamWrapper& operator << (int* (*)(void*));
109  vtkOStreamWrapper& operator << (float* (*)(void*));
110  vtkOStreamWrapper& operator << (const char* (*)(void*));
111  vtkOStreamWrapper& operator << (void (*)(void*, int*));
112 
113  // Accept std::string without a declaration.
114  template <template <typename, typename, typename> class S>
116  S< char, std::char_traits<char>, std::allocator<char> >& s)
117  {
118  return *this << reinterpret_cast<std_string const&>(s);
119  }
120 
124  vtkOStreamWrapper& write(const char*, unsigned long);
125 
129  ostream& GetOStream();
130 
136  operator ostream&();
137 
141  operator int();
142 
146  void flush();
147 
149 
153  static void UseEndl(const EndlType&) {}
154 protected:
155  // Reference to the real ostream.
156  ostream& ostr;
157 private:
158  vtkOStreamWrapper& operator=(const vtkOStreamWrapper& r) VTK_DELETE_FUNCTION;
159  vtkOStreamWrapper& operator << (std_string const&);
160 };
162 
163 #endif
164 // VTK-HeaderTest-Exclude: vtkOStreamWrapper.h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:47
ostream & ostr
Implementation detail to allow macros to provide an endl that may or may not be used.
Do_not_include_vtkOStreamWrapper_directly__vtkSystemIncludes_includes_it
Wrapper for C++ ostream.
a simple class to control print indentation
Definition: vtkIndent.h:39
Type for a fake endl.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:65
Non-templated superclass for vtkSmartPointer.
static void UseEndl(const EndlType &)
Implementation detail to allow macros to provide an endl that may or may not be used.
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)
class for arbitrarily large ints