VTK  9.1.0
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;
39 template <typename T>
40 class vtkSmartPointer;
42 class vtkStdString;
43 
44 class VTKCOMMONCORE_EXPORT VTK_WRAPEXCLUDE vtkOStreamWrapper
45 {
46  class std_string;
47 
48 public:
50 
54  vtkOStreamWrapper(ostream& os);
57 
58  virtual ~vtkOStreamWrapper();
59 
63  struct EndlType
64  {
65  };
66 
68 
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>
115  vtkOStreamWrapper& operator<<(const S<char, std::char_traits<char>, std::allocator<char>>& s)
116  {
117  return *this << reinterpret_cast<std_string const&>(s);
118  }
119 
120  // Accept vtkSmartPointer for output.
121  template <typename T>
123  {
124  this->ostr << (static_cast<T*>(ptr));
125  return *this;
126  }
127 
131  vtkOStreamWrapper& write(const char*, unsigned long);
132 
136  ostream& GetOStream();
137 
143  operator ostream&();
144 
148  operator int();
149 
153  void flush();
154 
156 
160  static void UseEndl(const EndlType&) {}
162 protected:
163  // Reference to the real ostream.
164  ostream& ostr;
165 
166 private:
167  vtkOStreamWrapper& operator=(const vtkOStreamWrapper& r) = delete;
168  vtkOStreamWrapper& operator<<(std_string const&);
169 };
170 
171 #endif
172 // VTK-HeaderTest-Exclude: vtkOStreamWrapper.h
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(const vtkLargeInteger &)
Forward this output operator to the real ostream.
vtkSmartPointerBase
Non-templated superclass for vtkSmartPointer.
Definition: vtkSmartPointerBase.h:33
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(double)
Forward this output operator to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(void *)
Forward this output operator to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(const char *(*)(void *))
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(void(*)(void *, int *))
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(int(*)(void *))
vtkOStreamWrapper::~vtkOStreamWrapper
virtual ~vtkOStreamWrapper()
vtkSmartPointer
Hold a reference to a vtkObjectBase instance.
Definition: vtkSmartPointer.h:145
vtkOStreamWrapper::EndlType
Type for a fake endl.
Definition: vtkOStreamWrapper.h:64
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(float)
Forward this output operator to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(const vtkStdString &)
Forward this output operator to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(char)
Forward this output operator to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(unsigned int)
Forward this output operator to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(const EndlType &)
Forward this output operator to the real ostream.
VTK_WRAPEXCLUDE
#define VTK_WRAPEXCLUDE
Definition: vtkWrappingHints.h:43
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(void(*)(void *))
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(unsigned short)
Forward this output operator to the real ostream.
vtkObjectBase
abstract base class for most VTK objects
Definition: vtkObjectBase.h:70
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(const vtkIndent &)
Forward this output operator to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(const vtkSmartPointerBase &)
Forward this output operator to the real ostream.
vtkOStreamWrapper::vtkOStreamWrapper
vtkOStreamWrapper(ostream &os)
Construct class to reference a real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(int *(*)(void *))
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(const vtkSmartPointer< T > &ptr)
Definition: vtkOStreamWrapper.h:122
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(const char *)
Forward this output operator to the real ostream.
vtkOStreamWrapper::flush
void flush()
Forward the flush method to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(vtkObjectBase &)
Forward this output operator to the real ostream.
operator<<
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(short)
Forward this output operator to the real ostream.
vtkOStreamWrapper
Wrapper for C++ ostream.
Definition: vtkOStreamWrapper.h:45
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(unsigned char)
Forward this output operator to the real ostream.
vtkOStreamWrapper::UseEndl
static void UseEndl(const EndlType &)
Implementation detail to allow macros to provide an endl that may or may not be used.
Definition: vtkOStreamWrapper.h:160
vtkOStreamWrapper::GetOStream
ostream & GetOStream()
Get a reference to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(unsigned long)
Forward this output operator to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(long)
Forward this output operator to the real ostream.
Do_not_include_vtkOStreamWrapper_directly_vtkSystemIncludes_includes_it
Do_not_include_vtkOStreamWrapper_directly_vtkSystemIncludes_includes_it
Definition: vtkOStreamWrapper.h:33
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(const S< char, std::char_traits< char >, std::allocator< char >> &s)
Definition: vtkOStreamWrapper.h:115
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:105
vtkOStreamWrapper::vtkOStreamWrapper
vtkOStreamWrapper(vtkOStreamWrapper &r)
Construct class to reference a real ostream.
vtkOStreamWrapper::ostr
ostream & ostr
Definition: vtkOStreamWrapper.h:164
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(bool)
Forward this output operator to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(int)
Forward this output operator to the real ostream.
vtkOStreamWrapper::write
vtkOStreamWrapper & write(const char *, unsigned long)
Forward the write method to the real stream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(unsigned long long)
Forward this output operator to the real ostream.
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(float *(*)(void *))
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(long long)
Forward this output operator to the real ostream.
vtkLargeInteger
class for arbitrarily large ints
Definition: vtkLargeInteger.h:27
vtkOStreamWrapper::operator<<
vtkOStreamWrapper & operator<<(void *(*)(void *))