From d0fbd68055e3f4a796330cc8acc6c0954b5327ff Mon Sep 17 00:00:00 2001 From: untodesu Date: Thu, 11 Sep 2025 15:48:53 +0500 Subject: Run clang-format across the project --- core/io/buffer.hh | 176 +++++++++++++++++++++++++++--------------------------- 1 file changed, 88 insertions(+), 88 deletions(-) (limited to 'core/io/buffer.hh') diff --git a/core/io/buffer.hh b/core/io/buffer.hh index 96a37b1..5f1ab66 100644 --- a/core/io/buffer.hh +++ b/core/io/buffer.hh @@ -1,88 +1,88 @@ -namespace io -{ -class ReadBuffer final { -public: - ReadBuffer(void) = default; - explicit ReadBuffer(const ReadBuffer& other); - explicit ReadBuffer(const void* data, std::size_t size); - explicit ReadBuffer(const ENetPacket* packet); - explicit ReadBuffer(PHYSFS_File* file); - virtual ~ReadBuffer(void) = default; - - std::size_t size(void) const; - const std::byte* data(void) const; - - void reset(const void* data, std::size_t size); - void reset(const ENetPacket* packet); - void reset(PHYSFS_File* file); - - constexpr void rewind(void); - constexpr bool is_ended(void) const; - - void read(void* buffer, std::size_t size); - - template - T read(void); - - template - ReadBuffer& operator>>(T& value); - -private: - std::vector m_vector; - std::size_t m_position; -}; -} // namespace io - -namespace io -{ -class WriteBuffer final { -public: - WriteBuffer(void) = default; - explicit WriteBuffer(const WriteBuffer& other); - virtual ~WriteBuffer(void) = default; - - std::size_t size(void) const; - const std::byte* data(void) const; - - void reset(void); - - void write(const WriteBuffer& other); - void write(const void* data, std::size_t size); - - template - void write(const T value); - - template - WriteBuffer& operator<<(const T value); - - PHYSFS_File* to_file(const std::string& path, bool append = false) const; - ENetPacket* to_packet(enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE) const; - -private: - std::vector m_vector; -}; -} // namespace io - -constexpr void io::ReadBuffer::rewind(void) -{ - m_position = 0; -} - -constexpr bool io::ReadBuffer::is_ended(void) const -{ - return m_position >= m_vector.size(); -} - -template -io::ReadBuffer& io::ReadBuffer::operator>>(T& value) -{ - value = read(); - return *this; -} - -template -io::WriteBuffer& io::WriteBuffer::operator<<(const T value) -{ - write(value); - return *this; -} +namespace io +{ +class ReadBuffer final { +public: + ReadBuffer(void) = default; + explicit ReadBuffer(const ReadBuffer& other); + explicit ReadBuffer(const void* data, std::size_t size); + explicit ReadBuffer(const ENetPacket* packet); + explicit ReadBuffer(PHYSFS_File* file); + virtual ~ReadBuffer(void) = default; + + std::size_t size(void) const; + const std::byte* data(void) const; + + void reset(const void* data, std::size_t size); + void reset(const ENetPacket* packet); + void reset(PHYSFS_File* file); + + constexpr void rewind(void); + constexpr bool is_ended(void) const; + + void read(void* buffer, std::size_t size); + + template + T read(void); + + template + ReadBuffer& operator>>(T& value); + +private: + std::vector m_vector; + std::size_t m_position; +}; +} // namespace io + +namespace io +{ +class WriteBuffer final { +public: + WriteBuffer(void) = default; + explicit WriteBuffer(const WriteBuffer& other); + virtual ~WriteBuffer(void) = default; + + std::size_t size(void) const; + const std::byte* data(void) const; + + void reset(void); + + void write(const WriteBuffer& other); + void write(const void* data, std::size_t size); + + template + void write(const T value); + + template + WriteBuffer& operator<<(const T value); + + PHYSFS_File* to_file(const std::string& path, bool append = false) const; + ENetPacket* to_packet(enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE) const; + +private: + std::vector m_vector; +}; +} // namespace io + +constexpr void io::ReadBuffer::rewind(void) +{ + m_position = 0; +} + +constexpr bool io::ReadBuffer::is_ended(void) const +{ + return m_position >= m_vector.size(); +} + +template +io::ReadBuffer& io::ReadBuffer::operator>>(T& value) +{ + value = read(); + return *this; +} + +template +io::WriteBuffer& io::WriteBuffer::operator<<(const T value) +{ + write(value); + return *this; +} -- cgit