Core/StringStream: Add Clear and GetBufferSize methods

Former-commit-id: 4d8b940c300ff415fb8060b0e20b3087dc6bb076 [formerly af2dfd84721ba70df0735c04021f9ff39e90d05d]
Former-commit-id: 3eecd417e811c29345f502f82219754ffa54c141
This commit is contained in:
Lynix 2016-07-07 08:56:45 +02:00
parent c83b9d0491
commit 832cde4bea
2 changed files with 23 additions and 22 deletions

View File

@ -22,6 +22,10 @@ namespace Nz
StringStream(const StringStream&) = default;
StringStream(StringStream&&) noexcept = default;
void Clear();
std::size_t GetBufferSize() const;
String ToString() const;
StringStream& operator=(const StringStream&) = default;

View File

@ -1,3 +1,4 @@
#include "..\..\..\include\Nazara\Core\StringStream.hpp"
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@ -16,7 +17,6 @@ namespace Nz
/*!
* \brief Constructs a StringStream object by default
*/
StringStream::StringStream() :
m_bufferSize(0)
{
@ -27,18 +27,34 @@ namespace Nz
*
* \param str First value of the stream
*/
StringStream::StringStream(const String& str) :
m_bufferSize(str.GetSize())
{
m_strings.push_back(str);
}
/*!
* \brief Resets the state of the stream, erasing every contained text
*/
void StringStream::Clear()
{
m_bufferSize = 0;
m_strings.clear();
}
/*!
* \brief Get the current buffer size
* \return The internal accumulation buffer size, this is equivalent to the size of the final string
*/
std::size_t StringStream::GetBufferSize() const
{
return m_bufferSize;
}
/*!
* \brief Gives a string representation
* \return A string representation of the object where every objects of the stream has been converted with Nz::String
*/
String StringStream::ToString() const
{
String string;
@ -56,7 +72,6 @@ namespace Nz
*
* \param boolean Boolean value
*/
StringStream& StringStream::operator<<(bool boolean)
{
m_strings.push_back(String::Boolean(boolean));
@ -71,7 +86,6 @@ namespace Nz
*
* \param number Short value
*/
StringStream& StringStream::operator<<(short number)
{
m_strings.push_back(String::Number(number));
@ -86,7 +100,6 @@ namespace Nz
*
* \param number Short value
*/
StringStream& StringStream::operator<<(unsigned short number)
{
m_strings.push_back(String::Number(number));
@ -101,7 +114,6 @@ namespace Nz
*
* \param number Int value
*/
StringStream& StringStream::operator<<(int number)
{
m_strings.push_back(String::Number(number));
@ -116,7 +128,6 @@ namespace Nz
*
* \param number Int value
*/
StringStream& StringStream::operator<<(unsigned int number)
{
m_strings.push_back(String::Number(number));
@ -131,7 +142,6 @@ namespace Nz
*
* \param number Long value
*/
StringStream& StringStream::operator<<(long number)
{
m_strings.push_back(String::Number(number));
@ -146,7 +156,6 @@ namespace Nz
*
* \param number Long value
*/
StringStream& StringStream::operator<<(unsigned long number)
{
m_strings.push_back(String::Number(number));
@ -161,7 +170,6 @@ namespace Nz
*
* \param number Long long value
*/
StringStream& StringStream::operator<<(long long number)
{
m_strings.push_back(String::Number(number));
@ -176,7 +184,6 @@ namespace Nz
*
* \param number Long long value
*/
StringStream& StringStream::operator<<(unsigned long long number)
{
m_strings.push_back(String::Number(number));
@ -191,7 +198,6 @@ namespace Nz
*
* \param number Float value
*/
StringStream& StringStream::operator<<(float number)
{
m_strings.push_back(String::Number(number));
@ -206,7 +212,6 @@ namespace Nz
*
* \param number Double value
*/
StringStream& StringStream::operator<<(double number)
{
m_strings.push_back(String::Number(number));
@ -221,7 +226,6 @@ namespace Nz
*
* \param number Long double value
*/
StringStream& StringStream::operator<<(long double number)
{
m_strings.push_back(String::Number(number));
@ -236,7 +240,6 @@ namespace Nz
*
* \param character Char value
*/
StringStream& StringStream::operator<<(char character)
{
m_strings.push_back(String(character));
@ -251,7 +254,6 @@ namespace Nz
*
* \param character Char value
*/
StringStream& StringStream::operator<<(unsigned char character)
{
m_strings.push_back(String(static_cast<char>(character)));
@ -266,7 +268,6 @@ namespace Nz
*
* \param string String value
*/
StringStream& StringStream::operator<<(const char* string)
{
m_strings.push_back(string);
@ -281,7 +282,6 @@ namespace Nz
*
* \param string String value
*/
StringStream& StringStream::operator<<(const std::string& string)
{
m_strings.push_back(string);
@ -296,7 +296,6 @@ namespace Nz
*
* \param string String value
*/
StringStream& StringStream::operator<<(const String& string)
{
m_strings.push_back(string);
@ -311,7 +310,6 @@ namespace Nz
*
* \param ptr Pointer value
*/
StringStream& StringStream::operator<<(const void* ptr)
{
m_strings.push_back(String::Pointer(ptr));
@ -324,7 +322,6 @@ namespace Nz
* \brief Converts this to Nz::String
* \return The string representation of the stream
*/
StringStream::operator String() const
{
return ToString();