From 4c89dbc0bcde7927188ae06722f176e54d3f6ead Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Mon, 20 Jul 2015 21:57:32 +0200 Subject: [PATCH] Replace custom string classes with std::string - friendly version --- libs/fs_filesystem.h | 2 +- libs/generic/arrayrange.h | 6 ++++++ libs/string/string.cpp | 5 +++-- libs/string/string.h | 5 ++++- libs/string/stringfwd.h | 7 +++++-- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/libs/fs_filesystem.h b/libs/fs_filesystem.h index 5cd42a63..d181f702 100644 --- a/libs/fs_filesystem.h +++ b/libs/fs_filesystem.h @@ -55,7 +55,7 @@ Path( const char* path ) : m_path( path ), m_depth( path_get_depth( c_str() ) ){ } Path( StringRange range ) - : m_path( range ), m_depth( path_get_depth( c_str() ) ){ + : m_path( range.first, range.last ), m_depth( path_get_depth( c_str() ) ){ } bool operator<( const Path& other ) const { return string_less_nocase( c_str(), other.c_str() ); diff --git a/libs/generic/arrayrange.h b/libs/generic/arrayrange.h index e036cf3d..98c72633 100644 --- a/libs/generic/arrayrange.h +++ b/libs/generic/arrayrange.h @@ -21,6 +21,7 @@ #if !defined( INCLUDED_GENERIC_ARRAYRANGE_H ) #define INCLUDED_GENERIC_ARRAYRANGE_H +#include /// \file /// \brief Macros for automatically converting a compile-time-sized array to a range. @@ -34,6 +35,11 @@ struct ArrayRange } Iterator first; Iterator last; + + operator std::basic_string::type>() const + { + return std::basic_string::type>(first, last); + } }; template diff --git a/libs/string/string.cpp b/libs/string/string.cpp index 59043014..ccca51c5 100644 --- a/libs/string/string.cpp +++ b/libs/string/string.cpp @@ -21,7 +21,8 @@ #include "string.h" +/// \note Never called... void TestString(){ CopiedString bleh( "bleh" ); - SmartString blah( "blah" ); -} \ No newline at end of file + //SmartString blah( "blah" ); +} diff --git a/libs/string/string.h b/libs/string/string.h index a6de0673..7ab7e66b 100644 --- a/libs/string/string.h +++ b/libs/string/string.h @@ -288,6 +288,7 @@ const char* getToken(){ } }; +#if 0 /// \brief A non-mutable c-style string. /// /// \param Buffer The string storage implementation. Must be DefaultConstructible, CopyConstructible and Assignable. Must implement: @@ -423,7 +424,6 @@ void swap( CopiedBuffer& other ){ /// \brief A non-mutable string which uses copy-by-value for assignment. typedef String< CopiedBuffer< DefaultAllocator > > CopiedString; - /// \brief A non-mutable string buffer which uses reference-counting to avoid unnecessary allocations. template class SmartBuffer : private Allocator @@ -491,6 +491,9 @@ void swap( SmartBuffer& other ){ /// \brief A non-mutable string which uses copy-by-reference for assignment of SmartString. typedef String< SmartBuffer< DefaultAllocator > > SmartString; +#endif + +typedef std::string CopiedString; class StringEqualNoCase { diff --git a/libs/string/stringfwd.h b/libs/string/stringfwd.h index d3d634e0..1946a090 100644 --- a/libs/string/stringfwd.h +++ b/libs/string/stringfwd.h @@ -22,14 +22,17 @@ #if !defined( INCLUDED_STRING_STRINGFWD_H ) #define INCLUDED_STRING_STRINGFWD_H +#include + // forward-declaration of CopiedString template class DefaultAllocator; -template +/*template class CopiedBuffer; template class String; -typedef String< CopiedBuffer< DefaultAllocator > > CopiedString; +typedef String< CopiedBuffer< DefaultAllocator > > CopiedString;*/ +typedef std::string CopiedString; #endif -- 2.39.2