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); }; }