VTK  9.2.20230205
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 VTK_ABI_NAMESPACE_BEGIN
37 class vtkIndent;
38 class vtkObjectBase;
39 class vtkLargeInteger;
40 template <typename T>
41 class vtkSmartPointer;
43 class vtkStdString;
44 
45 class VTKCOMMONCORE_EXPORT VTK_WRAPEXCLUDE vtkOStreamWrapper
46 {
47  class std_string;
48 
49 public:
51 
55  vtkOStreamWrapper(ostream& os);
58 
59  virtual ~vtkOStreamWrapper();
60 
64  struct EndlType
65  {
66  };
67 
69 
85  vtkOStreamWrapper& operator<<(unsigned char);
86  vtkOStreamWrapper& operator<<(unsigned short);
87  vtkOStreamWrapper& operator<<(unsigned int);
88  vtkOStreamWrapper& operator<<(unsigned long);
89  vtkOStreamWrapper& operator<<(unsigned long long);
94 
95  // Work-around for IBM Visual Age bug in overload resolution.
96 #if defined(__IBMCPP__)
97  vtkOStreamWrapper& WriteInternal(const char*);
98  vtkOStreamWrapper& WriteInternal(void*);
99  template <typename T>
101  {
102  return this->WriteInternal(p);
103  }
104 #endif
105 
106  vtkOStreamWrapper& operator<<(void (*)(void*));
107  vtkOStreamWrapper& operator<<(void* (*)(void*));
108  vtkOStreamWrapper& operator<<(int (*)(void*));
109  vtkOStreamWrapper& operator<<(int* (*)(void*));
110  vtkOStreamWrapper& operator<<(float* (*)(void*));
111  vtkOStreamWrapper& operator<<(const char* (*)(void*));
112  vtkOStreamWrapper& operator<<(void (*)(void*, int*));
113 
114  // Accept std::string without a declaration.
115  template <template <typename, typename, typename> class S>
116  vtkOStreamWrapper& operator<<(const S<char, std::char_traits<char>, std::allocator<char>>& s)
117  {
118  return *this << reinterpret_cast<std_string const&>(s);
119  }
120 
121  // Accept vtkSmartPointer for output.
122  template <typename T>
124  {
125  this->ostr << (static_cast<T*>(ptr));
126  return *this;
127  }
128 
132  vtkOStreamWrapper& write(const char*, unsigned long);
133 
137  ostream& GetOStream();
138 
144  operator ostream&();
145 
149  operator int();
150 
154  void flush();
155 
157 
161  static void UseEndl(const EndlType&) {}
163 protected:
164  // Reference to the real ostream.
165  ostream& ostr;
166 
167 private:
168  vtkOStreamWrapper& operator=(const vtkOStreamWrapper& r) = delete;
169  vtkOStreamWrapper& operator<<(std_string const&);
170 };
171 
172 VTK_ABI_NAMESPACE_END
173 #endif
174 // VTK-HeaderTest-Exclude: vtkOStreamWrapper.h
a simple class to control print indentation
Definition: vtkIndent.h:120
class for arbitrarily large ints
Wrapper for C++ ostream.
vtkOStreamWrapper & operator<<(double)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(void(*)(void *))
vtkOStreamWrapper & operator<<(long long)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(unsigned long)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(const EndlType &)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(const char *)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(unsigned char)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(float *(*)(void *))
ostream & GetOStream()
Get a reference to the real ostream.
vtkOStreamWrapper & operator<<(unsigned short)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(int)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(const char *(*)(void *))
vtkOStreamWrapper & operator<<(int *(*)(void *))
virtual ~vtkOStreamWrapper()
vtkOStreamWrapper & operator<<(const S< char, std::char_traits< char >, std::allocator< char >> &s)
static void UseEndl(const EndlType &)
Implementation detail to allow macros to provide an endl that may or may not be used.
vtkOStreamWrapper & operator<<(float)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(const vtkStdString &)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(void *)
Forward this output operator to the real ostream.
vtkOStreamWrapper(ostream &os)
Construct class to reference a real ostream.
vtkOStreamWrapper & operator<<(long)
Forward this output operator to the real ostream.
void flush()
Forward the flush method to the real ostream.
vtkOStreamWrapper & operator<<(const vtkSmartPointerBase &)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(bool)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(void *(*)(void *))
vtkOStreamWrapper & operator<<(const vtkIndent &)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(unsigned int)
Forward this output operator to the real ostream.
vtkOStreamWrapper & write(const char *, unsigned long)
Forward the write method to the real stream.
vtkOStreamWrapper & operator<<(void(*)(void *, int *))
vtkOStreamWrapper & operator<<(char)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(short)
Forward this output operator to the real ostream.
vtkOStreamWrapper(vtkOStreamWrapper &r)
Construct class to reference a real ostream.
vtkOStreamWrapper & operator<<(unsigned long long)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(const vtkSmartPointer< T > &ptr)
vtkOStreamWrapper & operator<<(int(*)(void *))
vtkOStreamWrapper & operator<<(vtkObjectBase &)
Forward this output operator to the real ostream.
vtkOStreamWrapper & operator<<(const vtkLargeInteger &)
Forward this output operator to the real ostream.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:75
Non-templated superclass for vtkSmartPointer.
Hold a reference to a vtkObjectBase instance.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:110
Type for a fake endl.
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)
Do_not_include_vtkOStreamWrapper_directly_vtkSystemIncludes_includes_it
#define VTK_WRAPEXCLUDE