From 9c1799033d0c17fbefb52a9b2695922f5a715133 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sun, 19 Jan 2014 21:46:02 -0800 Subject: Implement FString from scratch instead of hackishly --- src/strings/fstring.hpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/strings/fstring.hpp') diff --git a/src/strings/fstring.hpp b/src/strings/fstring.hpp index b025d74..48da326 100644 --- a/src/strings/fstring.hpp +++ b/src/strings/fstring.hpp @@ -2,7 +2,7 @@ #define TMWA_STRINGS_FSTRING_HPP // strings/fstring.hpp - An owned, reference-counted immutable string. // -// Copyright © 2013 Ben Longbons +// Copyright © 2013-2014 Ben Longbons // // This file is part of The Mana World (Athena server) // @@ -22,24 +22,34 @@ # include # include -# include -# include - # include "base.hpp" namespace strings { /// An owning string that has reached its final contents. /// The storage is NUL-terminated - /// TODO reimplement without std::shared_ptr class FString : public _crtp_string { - std::shared_ptr> _hack2; + struct Rep + { + size_t count; + size_t size; + char body[]; + }; + static + uint8_t empty_string_rep[sizeof(Rep) + 1]; + + Rep *owned; template void _assign(It b, It e); public: FString(); + FString(const FString&); + FString(FString&&); + FString& operator = (const FString&); + FString& operator = (FString&&); + ~FString(); explicit FString(const MString& s); -- cgit v1.2.3-70-g09d2