summaryrefslogtreecommitdiff
path: root/src/strings/fstring.hpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-01-19 21:46:02 -0800
committerBen Longbons <b.r.longbons@gmail.com>2014-01-20 14:03:52 -0800
commit9c1799033d0c17fbefb52a9b2695922f5a715133 (patch)
treef2859d02f87081a9166e3253c4e7c4973b82fcea /src/strings/fstring.hpp
parentb9ac1c6033a0b32ca9984f23223d9fc167415b10 (diff)
downloadtmwa-9c1799033d0c17fbefb52a9b2695922f5a715133.tar.gz
tmwa-9c1799033d0c17fbefb52a9b2695922f5a715133.tar.bz2
tmwa-9c1799033d0c17fbefb52a9b2695922f5a715133.tar.xz
tmwa-9c1799033d0c17fbefb52a9b2695922f5a715133.zip
Implement FString from scratch instead of hackishly
Diffstat (limited to 'src/strings/fstring.hpp')
-rw-r--r--src/strings/fstring.hpp22
1 files changed, 16 insertions, 6 deletions
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 <b.r.longbons@gmail.com>
+// Copyright © 2013-2014 Ben Longbons <b.r.longbons@gmail.com>
//
// This file is part of The Mana World (Athena server)
//
@@ -22,24 +22,34 @@
# include <cstdarg>
# include <cstring>
-# include <memory>
-# include <vector>
-
# 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<FString, FString, ZPair>
{
- std::shared_ptr<std::vector<char>> _hack2;
+ struct Rep
+ {
+ size_t count;
+ size_t size;
+ char body[];
+ };
+ static
+ uint8_t empty_string_rep[sizeof(Rep) + 1];
+
+ Rep *owned;
template<class It>
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);