18
18
#ifndef itkOutputBinaryStream_h
19
19
#define itkOutputBinaryStream_h
20
20
21
- #include " itkPipeline.h"
22
- #include " itkWasmStringStream.h"
21
+ #include " itkOutputStreamBase.h"
23
22
23
+ #include < ios>
24
24
#include < string>
25
- #ifndef ITK_WASM_NO_MEMORY_IO
26
- # include < sstream>
27
- #endif
28
- #ifndef ITK_WASM_NO_FILESYSTEM_IO
29
- # include < fstream>
30
- #endif
31
-
32
- #include " WebAssemblyInterfaceExport.h"
33
25
34
26
namespace itk
35
27
{
@@ -38,70 +30,20 @@ namespace wasm
38
30
39
31
/* *
40
32
*\class OutputBinaryStream
41
- * \brief Output text std::ostream for an itk::wasm::Pipeline
42
- *
43
- * This stream is written to the filesystem or memory when the object goes out of scope.
44
- *
45
- * Call `Get()` to get the std::ostream & to use an output for a pipeline.
33
+ * \brief Output binary std::ostream for an itk::wasm::Pipeline
46
34
*
47
35
* \ingroup WebAssemblyInterface
48
36
*/
49
- class WebAssemblyInterface_EXPORT OutputBinaryStream
37
+ class OutputBinaryStream : public OutputStreamBase
50
38
{
51
39
public:
52
- std::ostream &
53
- Get ()
54
- {
55
- return *m_OStream;
56
- }
57
-
58
40
void
59
- SetFileName (const std::string & fileName)
41
+ SetFileName (const std::string & fileName) override
60
42
{
61
- if (m_DeleteOStream && m_OStream != nullptr )
62
- {
63
- delete m_OStream;
64
- }
65
- m_OStream = new std::ofstream (fileName, std::ofstream::out | std::ofstream::binary);
66
- m_DeleteOStream = true ;
43
+ OutputStreamBase::SetFile (fileName, std::ios_base::binary);
67
44
}
68
-
69
- OutputBinaryStream () = default ;
70
- ~OutputBinaryStream ();
71
-
72
- /* * Output index. */
73
- void
74
- SetIdentifier (const std::string & identifier)
75
- {
76
- if (m_DeleteOStream && m_OStream != nullptr )
77
- {
78
- delete m_OStream;
79
- }
80
- m_DeleteOStream = false ;
81
- m_WasmStringStream = WasmStringStream::New ();
82
-
83
- m_OStream = &(m_WasmStringStream->GetStringStream ());
84
- this ->m_Identifier = identifier;
85
- }
86
- const std::string &
87
- GetIdentifier () const
88
- {
89
- return this ->m_Identifier ;
90
- }
91
-
92
- private:
93
- std::ostream * m_OStream{ nullptr };
94
- bool m_DeleteOStream{ false };
95
-
96
- std::string m_Identifier;
97
-
98
- WasmStringStream::Pointer m_WasmStringStream;
99
45
};
100
46
101
-
102
- WebAssemblyInterface_EXPORT bool
103
- lexical_cast (const std::string & output, OutputBinaryStream & outputStream);
104
-
105
47
} // end namespace wasm
106
48
} // end namespace itk
107
49
0 commit comments