Skip to content

Commit

Permalink
Improve handling of deprecated ctors that are still used in Packet.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Nov 25, 2024
1 parent 9c09860 commit fc33649
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 10 deletions.
2 changes: 1 addition & 1 deletion soup/BufferWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ NAMESPACE_SOUP
{
}

[[deprecated]] BufferWriter(Endian endian)
/* deprecated */ BufferWriter(Endian endian)
: Writer(endian)
{
}
Expand Down
7 changes: 6 additions & 1 deletion soup/IstreamReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ NAMESPACE_SOUP
public:
std::istream& is;

IstreamReader(std::istream& is, Endian endian = ENDIAN_LITTLE)
IstreamReader(std::istream& is)
: Reader(ENDIAN_LITTLE), is(is)
{
}

/* deprecated */ IstreamReader(std::istream& is, Endian endian)
: Reader(endian), is(is)
{
}
Expand Down
15 changes: 13 additions & 2 deletions soup/MemoryRefReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,24 @@ NAMESPACE_SOUP
size_t size;
size_t offset = 0;

MemoryRefReader(const void* _data, size_t size, bool little_endian = true)
MemoryRefReader(const void* _data, size_t size)
: Reader(true), data(reinterpret_cast<const uint8_t*>(_data)), size(size)
{
}

/* deprecated */ MemoryRefReader(const void* _data, size_t size, bool little_endian)
: Reader(little_endian), data(reinterpret_cast<const uint8_t*>(_data)), size(size)
{
}

template <typename T, SOUP_RESTRICT(!std::is_pointer_v<T>)>
MemoryRefReader(const T& t, bool little_endian = true)
MemoryRefReader(const T& t)
: MemoryRefReader(t.data(), t.size(), true)
{
}

template <typename T, SOUP_RESTRICT(!std::is_pointer_v<T>)>
/* deprecated */ MemoryRefReader(const T& t, bool little_endian)
: MemoryRefReader(t.data(), t.size(), little_endian)
{
}
Expand Down
7 changes: 6 additions & 1 deletion soup/OstreamWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ NAMESPACE_SOUP
public:
std::ostream& os;

OstreamWriter(std::ostream& os, Endian endian = ENDIAN_LITTLE)
OstreamWriter(std::ostream& os)
: Writer(ENDIAN_LITTLE), os(os)
{
}

/* deprecated */ OstreamWriter(std::ostream& os, Endian endian)
: Writer(endian), os(os)
{
}
Expand Down
16 changes: 13 additions & 3 deletions soup/StringReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,27 @@ NAMESPACE_SOUP
std::string data;
size_t offset = 0;

StringReader(Endian endian = ENDIAN_LITTLE) noexcept
StringReader() noexcept
: Reader(ENDIAN_LITTLE)
{
}

/* deprecated */ StringReader(Endian endian) noexcept
: Reader(endian)
{
}

StringReader(std::string&& data, Endian endian = ENDIAN_LITTLE) noexcept
StringReader(std::string&& data) noexcept
: Reader(ENDIAN_LITTLE), data(std::move(data))
{
}

/* deprecated */ StringReader(std::string&& data, Endian endian) noexcept
: Reader(endian), data(std::move(data))
{
}

StringReader(std::string&& data, bool little_endian) noexcept
/* deprecated */ StringReader(std::string&& data, bool little_endian) noexcept
: Reader(little_endian), data(std::move(data))
{
}
Expand Down
9 changes: 7 additions & 2 deletions soup/StringWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ NAMESPACE_SOUP
public:
std::string data{};

StringWriter(Endian endian = ENDIAN_LITTLE)
StringWriter()
: Writer(ENDIAN_LITTLE)
{
}

/* deprecated */ StringWriter(Endian endian)
: Writer(endian)
{
}

StringWriter(bool little_endian)
/* deprecated */ StringWriter(bool little_endian)
: Writer(little_endian)
{
}
Expand Down

0 comments on commit fc33649

Please sign in to comment.