Thu, 23 Jul 2015 18:26:30 +0300
Use stdint.h types for the bytestream
--- a/sources/main.h Thu Jul 23 18:07:39 2015 +0300 +++ b/sources/main.h Thu Jul 23 18:26:30 2015 +0300 @@ -33,6 +33,7 @@ #include <functional> #include <cstdio> #include <cstdlib> +#include <cstdint> #include <cstring> #include <cctype> #include <ctime>
--- a/sources/network/bytestream.cpp Thu Jul 23 18:07:39 2015 +0300 +++ b/sources/network/bytestream.cpp Thu Jul 23 18:26:30 2015 +0300 @@ -136,7 +136,7 @@ // ------------------------------------------------------------------------------------------------- // -char Bytestream::read_byte() +int8_t Bytestream::read_byte() { ensure_read_space (1); return *m_cursor++; @@ -144,7 +144,7 @@ // ------------------------------------------------------------------------------------------------- // -short int Bytestream::read_short() +int16_t Bytestream::read_short() { ensure_read_space (2); short int result = 0; @@ -158,7 +158,7 @@ // ------------------------------------------------------------------------------------------------- // -long int Bytestream::read_long() +int32_t Bytestream::read_long() { ensure_read_space (4); long int result = 0; @@ -250,7 +250,7 @@ // ------------------------------------------------------------------------------------------------- // -void Bytestream::write_byte (char val) +void Bytestream::write_byte (int8_t val) { grow_to_fit (1); write (val); @@ -258,7 +258,7 @@ // ------------------------------------------------------------------------------------------------- // -void Bytestream::write_short (short int val) +void Bytestream::write_short (int16_t val) { grow_to_fit (2); @@ -268,7 +268,7 @@ // ------------------------------------------------------------------------------------------------- // -void Bytestream::write_long (long int val) +void Bytestream::write_long (int32_t val) { grow_to_fit (4);
--- a/sources/network/bytestream.h Thu Jul 23 18:07:39 2015 +0300 +++ b/sources/network/bytestream.h Thu Jul 23 18:26:30 2015 +0300 @@ -67,20 +67,20 @@ void clear(); void grow_to_fit (unsigned long bytes); void read (unsigned char* buffer, unsigned long length); - char read_byte(); - short int read_short(); - long int read_long(); + int8_t read_byte(); + int32_t read_long(); + int16_t read_short(); String read_string(); float read_float(); void resize (unsigned long length); void write (const unsigned char* val, unsigned int length); void write_buffer (const Bytestream& other); void write_buffer (const Vector<unsigned char>& other); - void write_byte (char val); + void write_byte (int8_t val); void write_double (double val); void write_float (float val); - void write_long (long int val); - void write_short (short int val); + void write_long (int32_t val); + void write_short (int16_t val); void write_string (const String& val); Bytestream& operator= (const Bytestream& other);