summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/buffer.cpp18
-rw-r--r--src/core/buffer.h14
2 files changed, 19 insertions, 13 deletions
diff --git a/src/core/buffer.cpp b/src/core/buffer.cpp
index 81fc0df..15f4cae 100644
--- a/src/core/buffer.cpp
+++ b/src/core/buffer.cpp
@@ -60,14 +60,7 @@ error buffer::pop(uint8_t &buffer, size_t size) {
return no_error();
}
-std::string buffer::to_string() const {
- std::ostringstream oss;
- for (size_t i = 0; i < read_composite_length(); ++i) {
- oss << read(i);
- }
- return oss.str();
-}
-
+/*
std::string buffer::to_hex() const {
std::ostringstream oss;
oss << std::hex << std::setfill('0');
@@ -79,6 +72,15 @@ std::string buffer::to_hex() const {
}
return oss.str();
}
+*/
+
+std::string convert_to_string(const buffer& buff){
+ std::ostringstream oss;
+ for (size_t i = 0; i < buff.read_composite_length(); ++i) {
+ oss << buff.read(i);
+ }
+ return oss.str();
+}
buffer_view::buffer_view(buffer &buffer)
: buffer_{&buffer}, read_offset_{0}, write_offset_{0} {}
diff --git a/src/core/buffer.h b/src/core/buffer.h
index ff39aff..f0cf76e 100644
--- a/src/core/buffer.h
+++ b/src/core/buffer.h
@@ -47,13 +47,17 @@ public:
error pop(uint8_t &value);
error pop(uint8_t &buffer, size_t size);
- /*
- * Subject to change
- */
- std::string to_string() const;
- std::string to_hex() const;
};
+/**
+ * Converts a buffer to a string for convenience cases
+ */
+std::string convert_to_string(const buffer& buf);
+
+/**
+ *
+ */
+
/*
* A viewer class for buffers.
* Working on the reference buffer invalidates the buffer view