From 18876f01627db99142366176c67efe11b7936b13 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 26 Jul 2019 22:26:47 +0200 Subject: [PATCH] [DEV] buffer get data string --- etk/Buffer.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/etk/Buffer.hpp b/etk/Buffer.hpp index 53777d1..4e14337 100644 --- a/etk/Buffer.hpp +++ b/etk/Buffer.hpp @@ -10,6 +10,7 @@ #include #include #include +#include // minimum gapSize when allocated #define GAP_SIZE_MIN (80) @@ -104,6 +105,18 @@ namespace etk { fileIO.close(); return true; } + /** + * @brief Get all data in a single string element + * @return the buffer in string + */ + etk::String getString() { + etk::String data; + data.resize(m_allocated - m_gapEnd + m_gapStart, ' '); + memcpy(&data[0], m_data, m_gapStart); + memcpy(&data[m_gapStart], &m_data[m_gapEnd], m_allocated - m_gapEnd); + return data; + } + /** * @brief Load data from a selected file name. * @param[in] _file Name of the file to store buffer data.