From 0f9c710b717ef35d3c2a8e1f749447babde3e725 Mon Sep 17 00:00:00 2001 From: Danilo Date: Tue, 28 May 2024 21:24:27 -0300 Subject: [PATCH] =?UTF-8?q?Coment=C3=A1rios=20em=20BinaryWriter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/csharp/binary.hpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/inc/csharp/binary.hpp b/inc/csharp/binary.hpp index be72164..b5509d2 100644 --- a/inc/csharp/binary.hpp +++ b/inc/csharp/binary.hpp @@ -84,11 +84,21 @@ namespace xna { //A simplified port of the BinaryWriter class. class BinaryWriter { public: - BinaryWriter(sptr const& stream) : _stream(stream), _buffer(16) { + BinaryWriter(sptr const& stream) { + if (!stream) + throw std::invalid_argument("stream is null."); + + _stream = stream; + _buffer = std::vector(16); } + //Sets the position within the current stream. Long Seek(Int offset, SeekOrigin origin); + // + // Writes a value to the current stream. + // + void Write(bool value); void Write(Byte value); void Write(Sbyte value); @@ -108,12 +118,14 @@ namespace xna { void Write(std::string const& value); void Write(const char* _string, size_t stringLength); - public: - sptr _stream = nullptr; + //Writes a 32-bit integer in a compressed format. + void Write7BitEncodedInt(Int value); + + //void Write7BitEncodedInt64(Long value); private: + sptr _stream = nullptr; std::vector _buffer; - void Write7BitEncodedInt(Int value); }; }