From a739c5d808c173278a60471341e51a710f7b1589 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 27 Dec 2017 14:38:46 +0100 Subject: [PATCH] [DEV] add back in the string API --- etk/String.cpp | 14 +++++++++++++- etk/String.hpp | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/etk/String.cpp b/etk/String.cpp index acf2cbc..3837d38 100644 --- a/etk/String.cpp +++ b/etk/String.cpp @@ -1,4 +1,8 @@ - +/** + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license MPL-2 (see license file) + */ #include #include @@ -256,6 +260,14 @@ void etk::String::popBack() { } } +char& etk::String::back() { + return m_data[m_data.size()-2]; +} + +const char& etk::String::back() const { + return m_data[m_data.size()-2]; +} + void etk::String::reserve(size_t _size) { m_data.reserve(_size+1); } diff --git a/etk/String.hpp b/etk/String.hpp index 7ea468b..4989501 100644 --- a/etk/String.hpp +++ b/etk/String.hpp @@ -362,6 +362,12 @@ namespace etk { * @brief Remove the last element of the string */ void popBack(); + /** + * @brief Get the last element of the String + * @return An reference on the last char + */ + char& back(); + const char& back() const; /** * @brief Force the container to have a minimum size in memory allocation * @param[in] _size Size in byte that is requested.