From 749fec734c4583153fb2dbc80f1d21db2c2ab457 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 12 Aug 2014 10:45:18 -0700 Subject: Kill those dumb strings --- src/generic/dumb_ptr.hpp | 82 ------------------------------------------------ src/generic/fwd.hpp | 1 - 2 files changed, 83 deletions(-) (limited to 'src/generic') diff --git a/src/generic/dumb_ptr.hpp b/src/generic/dumb_ptr.hpp index 39c8c8b..72247d5 100644 --- a/src/generic/dumb_ptr.hpp +++ b/src/generic/dumb_ptr.hpp @@ -20,15 +20,9 @@ #include "fwd.hpp" -#include - #include #include -#include "../strings/astring.hpp" -#include "../strings/zstring.hpp" -#include "../strings/xstring.hpp" - namespace tmwa { @@ -184,80 +178,4 @@ public: return !(l == r); } }; - -struct dumb_string -{ - dumb_ptr impl; - - dumb_string() - : impl() - {} - dumb_string(char *) = delete; - // copy ctor, copy assign, and dtor are all default - - static dumb_string copy(const char *b, const char *e) - { - dumb_string rv; - rv.impl.new_((e - b) + 1); - std::copy(b, e, &rv.impl[0]); - return rv; - } - static dumb_string copys(XString s) - { - return dumb_string::copy(&*s.begin(), &*s.end()); - } - static -#ifndef __clang__ - __attribute__((warning("shouldn't use this - slice instead"))) -#endif - dumb_string copyn(const char *sn, size_t n) - { - return dumb_string::copy(sn, sn + strnlen(sn, n)); - } - - dumb_string dup() const - { - return dumb_string::copy(&impl[0], &impl[0] + impl.size()); - } - void delete_() - { - impl.delete_(); - } - - const char *c_str() const - { - return &impl[0]; - } - - operator ZString() const - { - return ZString(strings::really_construct_from_a_pointer, c_str(), nullptr); - } - - AString str() const - { - return ZString(*this); - } - - char& operator[](size_t i) const - { - return impl[i]; - } - - explicit - operator bool() const - { - return bool(impl); - } - bool operator !() const - { - return !impl; - } -}; - -inline -const char *convert_for_printf(dumb_string ds) -{ - return ds.c_str(); -} } // namespace tmwa diff --git a/src/generic/fwd.hpp b/src/generic/fwd.hpp index 81c4e26..3215903 100644 --- a/src/generic/fwd.hpp +++ b/src/generic/fwd.hpp @@ -26,5 +26,4 @@ namespace tmwa // meh, add more when I feel like it template class dumb_ptr; -class dumb_string; } // namespace tmwa -- cgit v1.2.3-70-g09d2