diff options
Diffstat (limited to 'lib/binarytools')
| -rw-r--r-- | lib/binarytools/BinaryWriter.cpp | 13 | ||||
| -rw-r--r-- | lib/binarytools/BinaryWriter.h | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/binarytools/BinaryWriter.cpp b/lib/binarytools/BinaryWriter.cpp index 362824f..6e0140f 100644 --- a/lib/binarytools/BinaryWriter.cpp +++ b/lib/binarytools/BinaryWriter.cpp @@ -132,10 +132,11 @@ void LUS::BinaryWriter::Write(double value) { mStream->Write((char*)&value, sizeof(double)); } -void LUS::BinaryWriter::Write(const std::string& str) { - int strLen = str.size(); - Write(strLen); - +void LUS::BinaryWriter::Write(const std::string& str, bool writeLength) { + if(writeLength){ + int strLen = str.size(); + Write(strLen); + } for (char c : str) { mStream->WriteByte(c); } @@ -145,6 +146,10 @@ void LUS::BinaryWriter::Write(char* srcBuffer, size_t length) { mStream->Write(srcBuffer, length); } +void LUS::BinaryWriter::WriteByte(char value) { + mStream->WriteByte(value); +} + std::vector<char> LUS::BinaryWriter::ToVector() { return mStream->ToVector(); } diff --git a/lib/binarytools/BinaryWriter.h b/lib/binarytools/BinaryWriter.h index fbd4f65..dca683f 100644 --- a/lib/binarytools/BinaryWriter.h +++ b/lib/binarytools/BinaryWriter.h @@ -33,8 +33,9 @@ class BinaryWriter { void Write(uint64_t value); void Write(float value); void Write(double value); - void Write(const std::string& str); + void Write(const std::string& str, bool writeLength = true); void Write(char* srcBuffer, size_t length); + void WriteByte(char value); std::vector<char> ToVector(); |
