StreamPeer get[_utf8]_string with negative length.

If the "bytes" parameter of get_string and get_utf8_string is negative,
the length will be read from the stream instead.
The bytes parameter has now a default (-1), allowing to use them
directly as reverses of put_string and put_utf8_string .
put_string was not implemented, so I implemented it to allow sending
ASCII strings (which are much smaller than UTF8 ones).
This commit is contained in:
Fabio Alessandrelli 2018-09-22 05:08:07 +02:00
parent 5a03d50921
commit b9707ce08f
3 changed files with 30 additions and 9 deletions

View file

@ -71,6 +71,7 @@ public:
void put_u64(uint64_t p_val);
void put_float(float p_val);
void put_double(double p_val);
void put_string(const String &p_string);
void put_utf8_string(const String &p_string);
void put_var(const Variant &p_variant);
@ -84,8 +85,8 @@ public:
int64_t get_64();
float get_float();
double get_double();
String get_string(int p_bytes);
String get_utf8_string(int p_bytes);
String get_string(int p_bytes = -1);
String get_utf8_string(int p_bytes = -1);
Variant get_var();
StreamPeer() { big_endian = false; }