VTK  9.3.1
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 
66  vtkOStreamWrapper& operator<<(const char*);
72  vtkOStreamWrapper& operator<<(long long);
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>
111  vtkOStreamWrapper& operator<<(const vtkSmartPointer<T>& ptr)
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
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:28
Do_not_include_vtkOStreamWrapper_directly_vtkSystemIncludes_includes_it
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
Wrapper for C++ ostream.
a simple class to control print indentation
Definition: vtkIndent.h:28
Type for a fake endl.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:62
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
#define VTK_WRAPEXCLUDE