VTK  9.3.20240328
vtkOStreamWrapper.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
15 #ifndef vtkOStreamWrapper_h
16 #define vtkOStreamWrapper_h
17 
18 #include "vtkCommonCoreModule.h"
19 
20 #ifndef VTK_SYSTEM_INCLUDES_INSIDE
22 #endif
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class vtkIndent;
26 class vtkObjectBase;
27 class vtkLargeInteger;
28 template <typename T>
29 class vtkSmartPointer;
31 class vtkStdString;
32 
33 class VTKCOMMONCORE_EXPORT VTK_WRAPEXCLUDE vtkOStreamWrapper
34 {
35  class std_string;
36 
37 public:
39 
43  vtkOStreamWrapper(ostream& os);
46 
47  virtual ~vtkOStreamWrapper();
48 
52  struct EndlType
53  {
54  };
55 
57 
73  vtkOStreamWrapper& operator<<(unsigned char);
74  vtkOStreamWrapper& operator<<(unsigned short);
75  vtkOStreamWrapper& operator<<(unsigned int);
76  vtkOStreamWrapper& operator<<(unsigned long);
77  vtkOStreamWrapper& operator<<(unsigned long long);
82 
83  // Work-around for IBM Visual Age bug in overload resolution.
84 #if defined(__IBMCPP__)
85  vtkOStreamWrapper& WriteInternal(const char*);
86  vtkOStreamWrapper& WriteInternal(void*);
87  template <typename T>
89  {
90  return this->WriteInternal(p);
91  }
92 #endif
93 
94  vtkOStreamWrapper& operator<<(void (*)(void*));
95  vtkOStreamWrapper& operator<<(void* (*)(void*));
96  vtkOStreamWrapper& operator<<(int (*)(void*));
97  vtkOStreamWrapper& operator<<(int* (*)(void*));
98  vtkOStreamWrapper& operator<<(float* (*)(void*));
99  vtkOStreamWrapper& operator<<(const char* (*)(void*));
100  vtkOStreamWrapper& operator<<(void (*)(void*, int*));
101 
102  // Accept std::string without a declaration.
103  template <template <typename, typename, typename> class S>
104  vtkOStreamWrapper& operator<<(const S<char, std::char_traits<char>, std::allocator<char>>& s)
105  {
106  return *this << reinterpret_cast<std_string const&>(s);
107  }
108 
109  // Accept vtkSmartPointer for output.
110  template <typename T>
112  {
113  this->ostr << (static_cast<T*>(ptr));
114  return *this;
115  }
116 
120  vtkOStreamWrapper& write(const char*, unsigned long);
121 
125  ostream& GetOStream();
126 
132  operator ostream&();
133 
137  operator int();
138 
142  void flush();
143 
145 
149  static void UseEndl(const EndlType&) {}
151 protected:
152  // Reference to the real ostream.
153  ostream& ostr;
154 
155 private:
156  vtkOStreamWrapper& operator=(const vtkOStreamWrapper& r) = delete;
157  vtkOStreamWrapper& operator<<(std_string const&);
158 };
159 
160 VTK_ABI_NAMESPACE_END
161 #endif
162 // VTK-HeaderTest-Exclude: vtkOStreamWrapper.h
a simple class to control print indentation
Definition: vtkIndent.h:108
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:83
Non-templated superclass for vtkSmartPointer.
Hold a reference to a vtkObjectBase instance.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:78
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