Skip to content

Commit

Permalink
STYLE: Deprecate (ITK_FUTURE_LEGACY_REMOVE) ByteSwapper::OStreamType
Browse files Browse the repository at this point in the history
The type alias `OStreamType` just served as a workaround to an old MSVC bug.

For the record, this old workaround was introduced by commit 3066546
"ENH:Read at least one raw image :-)", Will Schroeder, 9 July 2001.
  • Loading branch information
N-Dekker committed Sep 26, 2024
1 parent 3b04ad1 commit 722ac86
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
18 changes: 11 additions & 7 deletions Modules/Core/Common/include/itkByteSwapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;

/** Work around MSVC bug (including ByteSwapper.h in a templated class). */
using OStreamType = std::ostream;
#ifndef ITK_FUTURE_LEGACY_REMOVE
/** Work around old MSVC bug (including ByteSwapper.h in a templated class). */
using OStreamType
[[deprecated("ByteSwapper::OStreamType is deprecated from ITK 6. Just use `std::ostream` instead!")]] =
std::ostream;
#endif

/** \see LightObject::GetNameOfClass() */
itkOverrideGetNameOfClassMacro(ByteSwapper);
Expand Down Expand Up @@ -117,7 +121,7 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object
* others raise an exception. The method is used to
* swap to and from Big Endian. */
static void
SwapWriteRangeFromSystemToBigEndian(const T * p, int num, OStreamType * fp);
SwapWriteRangeFromSystemToBigEndian(const T * p, int num, std::ostream * fp);

/** Generic swap method handles type T. The swapping is
* done in-place. 2, 4 and 8 byte swapping
Expand All @@ -143,7 +147,7 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object
* others raise an exception. The method is used to
* swap to and from Little Endian. */
static void
SwapWriteRangeFromSystemToLittleEndian(const T * p, int num, OStreamType * fp);
SwapWriteRangeFromSystemToLittleEndian(const T * p, int num, std::ostream * fp);

protected:
ByteSwapper() = default;
Expand All @@ -161,7 +165,7 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object
/** Swap and write a range of two-byte words. Num is the number of two-byte
* words to swap and write. */
static void
SwapWrite2Range(const void * ptr, BufferSizeType num, OStreamType * fp);
SwapWrite2Range(const void * ptr, BufferSizeType num, std::ostream * fp);

/** Swap four bytes. */
static void
Expand All @@ -175,7 +179,7 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object
/** Swap and write a range of four-byte words. Num is the number of four-byte
* words to swap and write. */
static void
SwapWrite4Range(const void * ptr, BufferSizeType num, OStreamType * fp);
SwapWrite4Range(const void * ptr, BufferSizeType num, std::ostream * fp);

/** Swap 8 bytes. */
static void
Expand All @@ -189,7 +193,7 @@ class ITK_TEMPLATE_EXPORT ByteSwapper : public Object
/** Swap and write a range of 8-byte words. Num is the number of four-byte
* words to swap and write. */
static void
SwapWrite8Range(const void * ptr, BufferSizeType num, OStreamType * fp);
SwapWrite8Range(const void * ptr, BufferSizeType num, std::ostream * fp);

private:
/** Swaps the bytes of the specified argument in-place. Assumes that its number of bytes is either 2, 4, or 8.
Expand Down
10 changes: 5 additions & 5 deletions Modules/Core/Common/include/itkByteSwapper.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ByteSwapper<T>::SwapRangeFromSystemToBigEndian([[maybe_unused]] T * p, [[maybe_u

template <typename T>
void
ByteSwapper<T>::SwapWriteRangeFromSystemToBigEndian(const T * p, int num, OStreamType * fp)
ByteSwapper<T>::SwapWriteRangeFromSystemToBigEndian(const T * p, int num, std::ostream * fp)
{
if constexpr (m_SystemIsBigEndian)
{
Expand Down Expand Up @@ -116,7 +116,7 @@ ByteSwapper<T>::SwapRangeFromSystemToLittleEndian([[maybe_unused]] T * p, [[mayb

template <typename T>
void
ByteSwapper<T>::SwapWriteRangeFromSystemToLittleEndian(const T * p, int num, OStreamType * fp)
ByteSwapper<T>::SwapWriteRangeFromSystemToLittleEndian(const T * p, int num, std::ostream * fp)
{
if constexpr (m_SystemIsBigEndian)
{
Expand Down Expand Up @@ -175,7 +175,7 @@ ByteSwapper<T>::Swap2Range(void * ptr, BufferSizeType num)
// Swap bunch of bytes. Num is the number of four byte words to swap.
template <typename T>
void
ByteSwapper<T>::SwapWrite2Range(const void * ptr, BufferSizeType num, OStreamType * fp)
ByteSwapper<T>::SwapWrite2Range(const void * ptr, BufferSizeType num, std::ostream * fp)
{
BufferSizeType chunkSize = 1000000;
if (num < chunkSize)
Expand Down Expand Up @@ -228,7 +228,7 @@ ByteSwapper<T>::Swap4Range(void * ptr, BufferSizeType num)
// Swap bunch of bytes. Num is the number of four byte words to swap.
template <typename T>
void
ByteSwapper<T>::SwapWrite4Range(const void * ptr, BufferSizeType num, OStreamType * fp)
ByteSwapper<T>::SwapWrite4Range(const void * ptr, BufferSizeType num, std::ostream * fp)
{
BufferSizeType chunkSize = 1000000;

Expand Down Expand Up @@ -286,7 +286,7 @@ ByteSwapper<T>::Swap8Range(void * ptr, BufferSizeType num)
// Swap bunch of bytes. Num is the number of four byte words to swap.
template <typename T>
void
ByteSwapper<T>::SwapWrite8Range(const void * ptr, BufferSizeType num, OStreamType * fp)
ByteSwapper<T>::SwapWrite8Range(const void * ptr, BufferSizeType num, std::ostream * fp)
{
BufferSizeType chunkSize = 1000000;
if (num < chunkSize)
Expand Down

0 comments on commit 722ac86

Please sign in to comment.