diff options
-rw-r--r-- | include/salticidae/msg.h | 2 | ||||
-rw-r--r-- | include/salticidae/stream.h | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/include/salticidae/msg.h b/include/salticidae/msg.h index 80b468a..fa4283e 100644 --- a/include/salticidae/msg.h +++ b/include/salticidae/msg.h @@ -149,7 +149,7 @@ class MsgBase { opcode = _opcode; } - bytearray_t &&get_payload() const { + DataStream &&get_payload() const { #ifndef SALTICIDAE_NOCHECK if (no_payload) throw std::runtime_error("payload not available"); diff --git a/include/salticidae/stream.h b/include/salticidae/stream.h index 50a7f70..e7e5640 100644 --- a/include/salticidae/stream.h +++ b/include/salticidae/stream.h @@ -43,6 +43,9 @@ class DataStream { DataStream(const uint8_t *begin, const uint8_t *end): buffer(begin, end), offset(0) {} DataStream(bytearray_t &&data): buffer(std::move(data)), offset(0) {} DataStream(const bytearray_t &data): buffer(data), offset(0) {} + DataStream(const std::string &data): + DataStream((uint8_t *)data.data(), + (uint8_t *)data.data() + data.size()) {} DataStream(DataStream &&other): buffer(std::move(other.buffer)), |