Skip to content

Commit 965f201

Browse files
committed
style: Move implementation InputStreamBase from h to cxx file
Moved the implementation of non-trivial member functions of InputStreamBase (including its defaulted destructor, which deallocates dynamic memory) from its h file to its cxx file. Might improve the compilation speed.
1 parent 5570591 commit 965f201

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

include/itkInputStreamBase.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
#ifndef itkInputStreamBase_h
1919
#define itkInputStreamBase_h
2020

21-
#include "itkPipeline.h"
22-
#include "itkWasmStringStream.h"
23-
21+
#include <ios>
22+
#include <iosfwd> // For istream.
23+
#include <memory> // For unique_ptr.
2424
#include <string>
25-
#include <sstream>
26-
#include <fstream>
2725

2826
#include "WebAssemblyInterfaceExport.h"
2927

@@ -58,22 +56,14 @@ class WebAssemblyInterface_EXPORT InputStreamBase
5856
}
5957

6058
void
61-
SetJSON(const std::string & json)
62-
{
63-
const auto wasmStringStream = WasmStringStream::New();
64-
wasmStringStream->SetJSON(json.c_str());
65-
m_IStream = std::make_unique<std::stringstream>(std::move(wasmStringStream->GetStringStream()));
66-
}
59+
SetJSON(const std::string & json);
6760

6861
virtual void
6962
SetFileName(const std::string & fileName) = 0;
7063

7164
protected:
7265
void
73-
SetFile(const std::string & fileName, const std::ios_base::openmode openMode)
74-
{
75-
m_IStream = std::make_unique<std::ifstream>(fileName, openMode);
76-
}
66+
SetFile(const std::string & fileName, const std::ios_base::openmode openMode);
7767

7868
InputStreamBase() = default;
7969

@@ -82,7 +72,7 @@ class WebAssemblyInterface_EXPORT InputStreamBase
8272
InputStreamBase &
8373
operator=(InputStreamBase &&) = default;
8474

85-
virtual ~InputStreamBase() = default;
75+
virtual ~InputStreamBase();
8676

8777
private:
8878
std::unique_ptr<std::istream> m_IStream;

src/itkInputStreamBase.cxx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,38 @@
1616
*
1717
*=========================================================================*/
1818
#include "itkInputStreamBase.h"
19+
#include "itkPipeline.h"
20+
#include "itkWasmStringStream.h"
1921

20-
#include <string>
2122
#ifndef ITK_WASM_NO_MEMORY_IO
2223
# include "itkWasmExports.h"
2324
#endif
2425

26+
#include <fstream>
27+
#include <sstream>
28+
2529
namespace itk
2630
{
2731
namespace wasm
2832
{
33+
void
34+
InputStreamBase::SetJSON(const std::string & json)
35+
{
36+
const auto wasmStringStream = WasmStringStream::New();
37+
wasmStringStream->SetJSON(json.c_str());
38+
m_IStream = std::make_unique<std::stringstream>(std::move(wasmStringStream->GetStringStream()));
39+
}
40+
41+
42+
void
43+
InputStreamBase::SetFile(const std::string & fileName, const std::ios_base::openmode openMode)
44+
{
45+
m_IStream = std::make_unique<std::ifstream>(fileName, openMode);
46+
}
47+
48+
49+
InputStreamBase::~InputStreamBase() = default;
50+
2951

3052
bool
3153
lexical_cast(const std::string & input, InputStreamBase & inputStream)

0 commit comments

Comments
 (0)