VTK
vtkIOStream.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkIOStream.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 =========================================================================*/
22 #ifndef __vtkIOStream_h
23 #define __vtkIOStream_h
24 
25 #include "vtkConfigure.h"
26 
27 #define __VTK_SYSTEM_INCLUDES__INSIDE
28 #include "vtkWin32Header.h" // For export macros.
29 #undef __VTK_SYSTEM_INCLUDES__INSIDE
30 
31 #ifdef VTK_USE_ANSI_STDLIB
32 
33 #ifdef _MSC_VER
34 #pragma warning (push, 3)
35 #endif
36 
37 # include <iostream> // Include real ansi istream and ostream.
38 # include <fstream> // Include real ansi ifstream and ofstream.
39 # include <iomanip> // Include real ansi io manipulators.
40 
41 // Need these in global namespace so the same code will work with ansi
42 // and old-style streams.
43 using std::dec;
44 using std::hex;
45 using std::setw;
46 using std::setfill;
47 using std::setprecision;
48 using std::cerr;
49 using std::cout;
50 using std::cin;
51 using std::ios;
52 using std::endl;
53 using std::ends;
54 using std::ostream;
55 using std::istream;
56 using std::ofstream;
57 using std::ifstream;
58 using std::fstream;
59 
60 #ifdef _MSC_VER
61 #pragma warning(pop)
62 #endif
63 
64 #else
65 
66 // Include old-style streams.
67 # include <iostream.h> // Include old-style istream and ostream.
68 # include <iomanip.h>
69 # include <fstream.h> // Include old-style ifstream and ofstream.
70 #endif
71 
72 //----------------------------------------------------------------------------
73 // Include deprecated strstream headers? If including file has explicitly
74 // defined VTK_INCLUDE_STRSTREAM_HEADERS or VTK_EXCLUDE_STRSTREAM_HEADERS,
75 // then honor the setting. Otherwise, use the legacy defines to figure out
76 // if the deprecated strstream headers should be included...
77 //
78 // To prevent VTK from including the strstream headers, define
79 // VTK_EXCLUDE_STRSTREAM_HEADERS before including any VTK header files
80 // or set the VTK_LEGACY_REMOVE CMake option to ON.
81 //
82 // Clients may include <vtksys/ios/sstream> directly in their code and should
83 // prefer ostringstream and istringstream over ostrstream and istrstream.
84 //
85 #if !defined(VTK_INCLUDE_STRSTREAM_HEADERS)
86 # if defined(VTK_LEGACY_REMOVE)
87 // Remove legacy code - do NOT include the strstream headers
88 # elif defined(VTK_LEGACY_SILENT)
89 // Silently still include legacy code - DO include the strstream headers
90 # define VTK_INCLUDE_STRSTREAM_HEADERS
91 # else
92 // Default case - DO include the strstream headers for strict
93 // backwards compatibility unless client has explicitly defined
94 // VTK_EXCLUDE_STRSTREAM_HEADERS.
95 # if !defined(VTK_EXCLUDE_STRSTREAM_HEADERS)
96 # define VTK_INCLUDE_STRSTREAM_HEADERS
97 # endif
98 # endif
99 #endif
100 
101 #if defined(VTK_INCLUDE_STRSTREAM_HEADERS)
102 
103 # ifdef VTK_USE_ANSI_STDLIB
104 // Include real ansi strstreams.
105 
106 # ifdef _MSC_VER
107 # pragma warning(push, 3)
108 # endif
109 
110 # include <strstream>
111 
112 using std::ostrstream;
113 using std::istrstream;
114 using std::strstream;
115 
116 # ifdef _MSC_VER
117 # pragma warning(pop)
118 # endif
119 
120 # else
121 // Include old-style streams.
122 
123 # ifndef _WIN32_WCE
124 # if defined(_MSC_VER)
125 # include <strstrea.h> // Include old-style strstream from MSVC.
126 # else
127 # include <strstream.h> // Include old-style strstream.
128 # endif
129 # endif
130 
131 # endif
132 
133 #endif
134 
135 //----------------------------------------------------------------------------
136 #if defined(VTK_IOSTREAM_NEED_OPERATORS_LL)
137 
138 # if !defined(VTK_ISTREAM_SUPPORTS_LONG_LONG)
139 VTK_COMMON_EXPORT istream& vtkIOStreamScan(istream&, vtkIOStreamSLL&);
140 # if !defined(VTK_DO_NOT_DEFINE_ISTREAM_SLL)
141 inline istream& operator >> (istream& is, vtkIOStreamSLL& value)
142 {
143  return vtkIOStreamScan(is, value);
144 }
145 # endif
146 
147 VTK_COMMON_EXPORT istream& vtkIOStreamScan(istream&, vtkIOStreamULL&);
148 # if !defined(VTK_DO_NOT_DEFINE_ISTREAM_ULL)
149 inline istream& operator >> (istream& is, vtkIOStreamULL& value)
150 {
151  return vtkIOStreamScan(is, value);
152 }
153 # endif
154 # endif
155 
156 # if !defined(VTK_OSTREAM_SUPPORTS_LONG_LONG)
157 VTK_COMMON_EXPORT ostream& vtkIOStreamPrint(ostream&, vtkIOStreamSLL);
158 # if !defined(VTK_DO_NOT_DEFINE_OSTREAM_SLL)
159 inline ostream& operator << (ostream& os, vtkIOStreamSLL value)
160 {
161  return vtkIOStreamPrint(os, value);
162 }
163 # endif
164 
165 VTK_COMMON_EXPORT ostream& vtkIOStreamPrint(ostream&, vtkIOStreamULL);
166 # if !defined(VTK_DO_NOT_DEFINE_OSTREAM_ULL)
167 inline ostream& operator << (ostream& os, vtkIOStreamULL value)
168 {
169  return vtkIOStreamPrint(os, value);
170 }
171 # endif
172 # endif
173 
174 #endif
175 
176 #endif // __vtkIOStream_h