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 class vtkStdString;
41 
42 class VTKCOMMONCORE_EXPORT vtkOStreamWrapper
43 {
44  class std_string;
45 public:
47 
51  vtkOStreamWrapper(ostream& os);
54 
55  virtual ~vtkOStreamWrapper();
56 
60  struct EndlType {};
61 
63 
72  vtkOStreamWrapper& operator << (const char*);
78  vtkOStreamWrapper& operator << (long long);
79  vtkOStreamWrapper& operator << (unsigned char);
80  vtkOStreamWrapper& operator << (unsigned short);
81  vtkOStreamWrapper& operator << (unsigned int);
82  vtkOStreamWrapper& operator << (unsigned long);
83  vtkOStreamWrapper& operator << (unsigned long long);
88 
89  // Work-around for IBM Visual Age bug in overload resolution.
90 #if defined(__IBMCPP__)
91  vtkOStreamWrapper& WriteInternal(const char*);
92  vtkOStreamWrapper& WriteInternal(void*);
93  template <typename T>
95  {
96  return this->WriteInternal(p);
97  }
98 #endif
99 
100  vtkOStreamWrapper& operator << (void (*)(void*));
101  vtkOStreamWrapper& operator << (void* (*)(void*));
102  vtkOStreamWrapper& operator << (int (*)(void*));
103  vtkOStreamWrapper& operator << (int* (*)(void*));
104  vtkOStreamWrapper& operator << (float* (*)(void*));
105  vtkOStreamWrapper& operator << (const char* (*)(void*));
106  vtkOStreamWrapper& operator << (void (*)(void*, int*));
107 
108  // Accept std::string without a declaration.
109  template <template <typename, typename, typename> class S>
111  S< char, std::char_traits<char>, std::allocator<char> >& s)
112  {
113  return *this << reinterpret_cast<std_string const&>(s);
114  }
115 
119  vtkOStreamWrapper& write(const char*, unsigned long);
120 
124  ostream& GetOStream();
125 
131  operator ostream&();
132 
136  operator int();
137 
141  void flush();
142 
144 
148  static void UseEndl(const EndlType&) {}
149 protected:
150  // Reference to the real ostream.
151  ostream& ostr;
152 private:
153  vtkOStreamWrapper& operator=(const vtkOStreamWrapper& r) = delete;
154  vtkOStreamWrapper& operator << (std_string const&);
155 };
157 
158 #endif
159 // VTK-HeaderTest-Exclude: vtkOStreamWrapper.h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
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:68
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