diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-10-04 21:03:31 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-10-05 13:42:46 -0700 |
commit | 70214054e84b920ca3bea5119bd5d1456c809054 (patch) | |
tree | 0a9383d460c8988f788f4ef7adcd567526b35a75 | |
parent | caae1e38d0d239f4f7088a64526fe1d2f6587999 (diff) | |
download | tmwa-70214054e84b920ca3bea5119bd5d1456c809054.tar.gz tmwa-70214054e84b920ca3bea5119bd5d1456c809054.tar.bz2 tmwa-70214054e84b920ca3bea5119bd5d1456c809054.tar.xz tmwa-70214054e84b920ca3bea5119bd5d1456c809054.zip |
Remove owning slices
They were hardly ever used, hid errors, and were obsoleted by baseful x'es.
-rw-r--r-- | src/admin/ladmin.cpp | 6 | ||||
-rw-r--r-- | src/char/char.cpp | 10 | ||||
-rw-r--r-- | src/char/inter.cpp | 6 | ||||
-rw-r--r-- | src/common/mmo.hpp | 2 | ||||
-rw-r--r-- | src/common/utils.cpp | 18 | ||||
-rw-r--r-- | src/common/utils.hpp | 2 | ||||
-rw-r--r-- | src/login/login.cpp | 12 | ||||
-rw-r--r-- | src/map/atcommand.cpp | 10 | ||||
-rw-r--r-- | src/map/battle.cpp | 6 | ||||
-rw-r--r-- | src/map/clif.cpp | 2 | ||||
-rw-r--r-- | src/map/map.cpp | 6 | ||||
-rw-r--r-- | src/monitor/main.cpp | 6 | ||||
-rw-r--r-- | src/strings/base.hpp | 8 | ||||
-rw-r--r-- | src/strings/fstring.cpp | 19 | ||||
-rw-r--r-- | src/strings/fstring.hpp | 10 | ||||
-rw-r--r-- | src/strings/sstring.cpp | 19 | ||||
-rw-r--r-- | src/strings/sstring.hpp | 10 | ||||
-rw-r--r-- | src/strings/strings_test.cpp | 17 | ||||
-rw-r--r-- | src/strings/tstring.cpp | 19 | ||||
-rw-r--r-- | src/strings/tstring.hpp | 10 | ||||
-rw-r--r-- | src/strings/vstring.hpp | 10 | ||||
-rw-r--r-- | src/strings/xstring.hpp | 10 | ||||
-rw-r--r-- | src/strings/zstring.cpp | 19 | ||||
-rw-r--r-- | src/strings/zstring.hpp | 10 |
24 files changed, 34 insertions, 213 deletions
diff --git a/src/admin/ladmin.cpp b/src/admin/ladmin.cpp index 8a79662..fbea4dc 100644 --- a/src/admin/ladmin.cpp +++ b/src/admin/ladmin.cpp @@ -10,8 +10,6 @@ #include "../strings/mstring.hpp" #include "../strings/fstring.hpp" -#include "../strings/tstring.hpp" -#include "../strings/sstring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" #include "../strings/vstring.hpp" @@ -2784,8 +2782,8 @@ int ladmin_config_read(ZString cfgName) FString line; while (io::getline(in, line)) { - SString w1; - TString w2; + XString w1; + ZString w2; if (!split_key_value(line, &w1, &w2)) continue; diff --git a/src/char/char.cpp b/src/char/char.cpp index 35e5841..5d8650e 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -18,8 +18,6 @@ #include "../strings/mstring.hpp" #include "../strings/fstring.hpp" -#include "../strings/tstring.hpp" -#include "../strings/sstring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -2550,8 +2548,8 @@ int lan_config_read(ZString lancfgName) FString line; while (io::getline(in, line)) { - SString w1; - TString w2; + XString w1; + ZString w2; if (!split_key_value(line, &w1, &w2)) continue; @@ -2623,8 +2621,8 @@ int char_config_read(ZString cfgName) FString line; while (io::getline(in, line)) { - SString w1; - TString w2; + XString w1; + ZString w2; if (!split_key_value(line, &w1, &w2)) continue; diff --git a/src/char/inter.cpp b/src/char/inter.cpp index b6bc417..b951cc1 100644 --- a/src/char/inter.cpp +++ b/src/char/inter.cpp @@ -9,8 +9,6 @@ #include "../strings/mstring.hpp" #include "../strings/fstring.hpp" -#include "../strings/tstring.hpp" -#include "../strings/sstring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -185,8 +183,8 @@ int inter_config_read(ZString cfgName) FString line; while (io::getline(in, line)) { - SString w1; - TString w2; + XString w1; + ZString w2; if (!split_key_value(line, &w1, &w2)) continue; diff --git a/src/common/mmo.hpp b/src/common/mmo.hpp index 16acb88..0e1a7d0 100644 --- a/src/common/mmo.hpp +++ b/src/common/mmo.hpp @@ -65,7 +65,7 @@ class MapName : public strings::_crtp_string<MapName, MapName, strings::ZPair> VString<15> _impl; public: MapName() = default; - MapName(VString<15> v) : _impl(v.oislice_h(std::find(v.begin(), v.end(), '.'))) {} + MapName(VString<15> v) : _impl(v.xislice_h(std::find(v.begin(), v.end(), '.'))) {} iterator begin() const { return &*_impl.begin(); } iterator end() const { return &*_impl.end(); } diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 21440a4..383c711 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -6,8 +6,6 @@ #include <algorithm> #include "../strings/fstring.hpp" -#include "../strings/tstring.hpp" -#include "../strings/sstring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -65,27 +63,25 @@ int config_switch(ZString str) abort(); } -bool split_key_value(const FString& line, SString *w1, TString *w2) +bool split_key_value(ZString line, XString *w1, ZString *w2) { - FString::iterator begin = line.begin(), end = line.end(); - if (line.startswith("//")) return false; - if (begin == end) + if (!line) return false; - if (std::find_if(begin, end, + if (std::find_if(line.begin(), line.end(), [](unsigned char c) { return c < ' '; } ) != line.end()) return false; - FString::iterator colon = std::find(begin, end, ':'); - if (colon == end) + ZString::iterator colon = std::find(line.begin(), line.end(), ':'); + if (colon == line.end()) return false; - *w1 = line.oislice(begin, colon); + *w1 = line.xislice_h(colon); ++colon; while (std::isspace(*colon)) ++colon; - *w2 = line.oislice(colon, end); + *w2 = line.xislice_t(colon); return true; } diff --git a/src/common/utils.hpp b/src/common/utils.hpp index 66b1654..b0ee2bc 100644 --- a/src/common/utils.hpp +++ b/src/common/utils.hpp @@ -27,7 +27,7 @@ struct is_trivially_copyable bool e_mail_check(XString email); int config_switch (ZString str); -bool split_key_value(const FString& line, SString *w1, TString *w2); +bool split_key_value(ZString line, XString *w1, ZString *w2); inline void really_memcpy(uint8_t *dest, const uint8_t *src, size_t n) diff --git a/src/login/login.cpp b/src/login/login.cpp index c029844..679552a 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -17,8 +17,6 @@ #include "../strings/mstring.hpp" #include "../strings/fstring.hpp" -#include "../strings/tstring.hpp" -#include "../strings/sstring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" #include "../strings/vstring.hpp" @@ -794,7 +792,7 @@ int mmo_auth(struct mmo_account *account, int fd) && (account->userid.size() - 2) >= 4 && account->passwd.size() >= 4) { new_account_sex = account->userid.back(); - account->userid = stringish<AccountName>(account->userid.orslice_h(2)); + account->userid = stringish<AccountName>(account->userid.xrslice_h(2)); } // Strict account search @@ -3190,8 +3188,8 @@ int login_lan_config_read(ZString lancfgName) FString line; while (io::getline(in, line)) { - SString w1; - TString w2; + XString w1; + ZString w2; if (!split_key_value(line, &w1, &w2)) continue; @@ -3272,8 +3270,8 @@ int login_config_read(ZString cfgName) FString line; while (io::getline(in, line)) { - SString w1; - TString w2; + XString w1; + ZString w2; if (!split_key_value(line, &w1, &w2)) continue; diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index b7a0caa..e4d1745 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -8,8 +8,6 @@ #include "../strings/mstring.hpp" #include "../strings/fstring.hpp" -#include "../strings/tstring.hpp" -#include "../strings/sstring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" #include "../strings/vstring.hpp" @@ -592,8 +590,8 @@ int atcommand_config_read(ZString cfgName) FString line; while (io::getline(in, line)) { - SString w1; - TString w2; + XString w1; + ZString w2; if (!split_key_value(line, &w1, &w2)) continue; AtCommandInfo *p = get_atcommandinfo_byname(w1); @@ -1784,8 +1782,8 @@ int atcommand_help(const int fd, dumb_ptr<map_session_data> sd, FString line; while (io::getline(in, line)) { - SString w1; - TString w2; + XString w1; + ZString w2; if (!split_key_value(line, &w1, &w2)) continue; int level; diff --git a/src/map/battle.cpp b/src/map/battle.cpp index c5cb8e3..7bdac86 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -5,8 +5,6 @@ #include <fstream> #include "../strings/fstring.hpp" -#include "../strings/tstring.hpp" -#include "../strings/sstring.hpp" #include "../strings/zstring.hpp" #include "../common/cxxstdio.hpp" @@ -2525,8 +2523,8 @@ int battle_config_read(ZString cfgName) BATTLE_CONFIG_VAR(mob_splash_radius), }; - SString w1; - TString w2; + XString w1; + ZString w2; if (!split_key_value(line, &w1, &w2)) continue; diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 90c9f4d..8287b18 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -3761,7 +3761,7 @@ void clif_parse_GetCharNameRequest(int fd, dumb_ptr<map_session_data> sd) NpcName name = bl->as_npc()->name; // [fate] elim hashed out/invisible names for the client auto it = std::find(name.begin(), name.end(), '#'); - WFIFO_STRING(fd, 6, name.oislice_h(it), 24); + WFIFO_STRING(fd, 6, name.xislice_h(it), 24); WFIFOSET(fd, clif_parse_func_table[0x95].len); } break; diff --git a/src/map/map.cpp b/src/map/map.cpp index 9c5f074..f8bda41 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -13,8 +13,6 @@ #include <fstream> #include "../strings/fstring.hpp" -#include "../strings/tstring.hpp" -#include "../strings/sstring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" #include "../strings/vstring.hpp" @@ -1441,8 +1439,8 @@ int map_config_read(ZString cfgName) FString line; while (io::getline(in, line)) { - SString w1; - TString w2; + XString w1; + ZString w2; if (!split_key_value(line, &w1, &w2)) continue; if (w1 == "userid") diff --git a/src/monitor/main.cpp b/src/monitor/main.cpp index 2ab0a79..e20e2e3 100644 --- a/src/monitor/main.cpp +++ b/src/monitor/main.cpp @@ -18,8 +18,6 @@ #include "../strings/mstring.hpp" #include "../strings/fstring.hpp" -#include "../strings/tstring.hpp" -#include "../strings/sstring.hpp" #include "../strings/zstring.hpp" #include "../strings/xstring.hpp" @@ -91,8 +89,8 @@ void read_config(ZString filename) FString line; while (io::getline(in, line)) { - SString name; - TString value; + XString name; + ZString value; if (!split_key_value(line, &name, &value)) continue; diff --git a/src/strings/base.hpp b/src/strings/base.hpp index 2ea303f..8c0e924 100644 --- a/src/strings/base.hpp +++ b/src/strings/base.hpp @@ -190,14 +190,6 @@ namespace strings auto operator > (const L& l, const R& r) -> decltype((pair_compare(l, r), true)); template<class L, class R, typename=typename std::enable_if<string_comparison_allowed<L, R>::value>::type> auto operator >= (const L& l, const R& r) -> decltype((pair_compare(l, r), true)); - - // sadness - typedef MString MS; - typedef FString FS; - typedef TString TS; - typedef SString SS; - typedef ZString ZS; - typedef XString XS; } // namespace strings #include "base.tcc" diff --git a/src/strings/fstring.cpp b/src/strings/fstring.cpp index 4b20852..32d19fe 100644 --- a/src/strings/fstring.cpp +++ b/src/strings/fstring.cpp @@ -85,25 +85,6 @@ namespace strings return &*begin(); } - TS FS::oslice_t(size_t o) const - { return TS(*this, o); } - SS FS::oslice_h(size_t o) const - { return SS(*this, 0, o); } - TS FS::orslice_t(size_t no) const - { return TS(*this, size() - no); } - SS FS::orslice_h(size_t no) const - { return SS(*this, 0, size() - no); } - TS FS::oislice_t(iterator it) const - { return TS(*this, it - begin()); } - SS FS::oislice_h(iterator it) const - { return SS(*this, 0, it - begin()); } - SS FS::olslice(size_t o, size_t l) const - { return SS(*this, o, o + l); } - SS FS::opslice(size_t b, size_t e) const - { return SS(*this, b, e); } - SS FS::oislice(iterator b, iterator e) const - { return SS(*this, b - begin(), e - begin()); } - const char *decay_for_printf(const FString& fs) { return fs.c_str(); diff --git a/src/strings/fstring.hpp b/src/strings/fstring.hpp index 0f4f09d..8538b70 100644 --- a/src/strings/fstring.hpp +++ b/src/strings/fstring.hpp @@ -65,16 +65,6 @@ namespace strings iterator end() const; const FString *base() const; const char *c_str() const; - - TString oslice_t(size_t o) const; - SString oslice_h(size_t o) const; - TString orslice_t(size_t no) const; - SString orslice_h(size_t no) const; - TString oislice_t(iterator it) const; - SString oislice_h(iterator it) const; - SString olslice(size_t o, size_t l) const; - SString opslice(size_t b, size_t e) const; - SString oislice(iterator b, iterator e) const; }; // cxxstdio helpers diff --git a/src/strings/sstring.cpp b/src/strings/sstring.cpp index bcbcb58..99f91ed 100644 --- a/src/strings/sstring.cpp +++ b/src/strings/sstring.cpp @@ -69,23 +69,4 @@ namespace strings { return &_s; } - - SS SS::oslice_t(size_t o) const - { return SS(_s, _b + o, _e); } - SS SS::oslice_h(size_t o) const - { return SS(_s, _b, _b + o); } - SS SS::orslice_t(size_t no) const - { return SS(_s, _e - no, _e); } - SS SS::orslice_h(size_t no) const - { return SS(_s, _b, _e - no); } - SS SS::oislice_t(iterator it) const - { return SS(_s, _b + it - begin(), _e); } - SS SS::oislice_h(iterator it) const - { return SS(_s, _b, _b + it - begin()); } - SS SS::olslice(size_t o, size_t l) const - { return SS(_s, _b + o, _b + o + l); } - SS SS::opslice(size_t b, size_t e) const - { return SS(_s, _b + b, _b + e); } - SS SS::oislice(iterator b, iterator e) const - { return SS(_s, _b + b - begin(), _b + e - begin()); } } // namespace strings diff --git a/src/strings/sstring.hpp b/src/strings/sstring.hpp index 6f55f9a..a9558c9 100644 --- a/src/strings/sstring.hpp +++ b/src/strings/sstring.hpp @@ -51,16 +51,6 @@ namespace strings iterator begin() const; iterator end() const; const FString *base() const; - - SString oslice_t(size_t o) const; - SString oslice_h(size_t o) const; - SString orslice_t(size_t no) const; - SString orslice_h(size_t no) const; - SString oislice_t(iterator it) const; - SString oislice_h(iterator it) const; - SString olslice(size_t o, size_t l) const; - SString opslice(size_t b, size_t e) const; - SString oislice(iterator b, iterator e) const; }; } // namespace strings diff --git a/src/strings/strings_test.cpp b/src/strings/strings_test.cpp index b7a7d39..82d39d8 100644 --- a/src/strings/strings_test.cpp +++ b/src/strings/strings_test.cpp @@ -163,21 +163,6 @@ TYPED_TEST_P(StringTest, xslice) EXPECT_TRUE(hi.endswith("World!")); } -TYPED_TEST_P(StringTest, oslice) -{ - TypeParam hi("Hello, World!"); - EXPECT_EQ(" World!", hi.oslice_t(6)); - EXPECT_EQ("Hello,", hi.oslice_h(6)); - EXPECT_EQ("World!", hi.orslice_t(6)); - EXPECT_EQ("Hello, ", hi.orslice_h(6)); - typename TypeParam::iterator it = std::find(hi.begin(), hi.end(), ' '); - EXPECT_EQ(" World!", hi.oislice_t(it)); - EXPECT_EQ("Hello,", hi.oislice_h(it)); - EXPECT_EQ("World", hi.olslice(7, 5)); - EXPECT_EQ("World", hi.opslice(7, 12)); - EXPECT_EQ("World", hi.oislice(hi.begin() + 7, hi.begin() + 12)); -} - TYPED_TEST_P(StringTest, convert) { constexpr bool is_zstring = std::is_same<TypeParam, ZString>::value; @@ -249,7 +234,7 @@ TYPED_TEST_P(StringTest, convert) } REGISTER_TYPED_TEST_CASE_P(StringTest, - basic, order, iterators, xslice, oslice, convert); + basic, order, iterators, xslice, convert); typedef ::testing::Types< FString, TString, SString, ZString, XString, VString<255> diff --git a/src/strings/tstring.cpp b/src/strings/tstring.cpp index 9decc61..2d13888 100644 --- a/src/strings/tstring.cpp +++ b/src/strings/tstring.cpp @@ -72,25 +72,6 @@ namespace strings return &*begin(); } - TS TS::oslice_t(size_t o) const - { return TS(_s, _o + o); } - SS TS::oslice_h(size_t o) const - { return SS(_s, _o, _o + o); } - TS TS::orslice_t(size_t no) const - { return TS(_s, _s.size() - no); } - SS TS::orslice_h(size_t no) const - { return SS(_s, _o, _s.size() - no); } - TS TS::oislice_t(iterator it) const - { return TS(_s, _o + it - begin()); } - SS TS::oislice_h(iterator it) const - { return SS(_s, _o, _o + it - begin()); } - SS TS::olslice(size_t o, size_t l) const - { return SS(_s, _o + o, _o + o + l); } - SS TS::opslice(size_t b, size_t e) const - { return SS(_s, _o + b, _o + e); } - SS TS::oislice(iterator b, iterator e) const - { return SS(_s, _o + b - begin(), _o + e - begin()); } - const char *decay_for_printf(const TString& ts) { return ts.c_str(); diff --git a/src/strings/tstring.hpp b/src/strings/tstring.hpp index 63f3b7a..5d283fa 100644 --- a/src/strings/tstring.hpp +++ b/src/strings/tstring.hpp @@ -52,16 +52,6 @@ namespace strings iterator end() const; const FString *base() const; const char *c_str() const; - - TString oslice_t(size_t o) const; - SString oslice_h(size_t o) const; - TString orslice_t(size_t no) const; - SString orslice_h(size_t no) const; - TString oislice_t(iterator it) const; - SString oislice_h(iterator it) const; - SString olslice(size_t o, size_t l) const; - SString opslice(size_t b, size_t e) const; - SString oislice(iterator b, iterator e) const; }; // cxxstdio helpers diff --git a/src/strings/vstring.hpp b/src/strings/vstring.hpp index 527c2b4..7864b7d 100644 --- a/src/strings/vstring.hpp +++ b/src/strings/vstring.hpp @@ -50,16 +50,6 @@ namespace strings iterator end() const; const FString *base() const; const char *c_str() const; - - VString oslice_t(size_t o) const { return this->xslice_t(o); } - VString oslice_h(size_t o) const { return this->xslice_h(o); } - VString orslice_t(size_t no) const { return this->xrslice_t(no); } - VString orslice_h(size_t no) const { return this->xrslice_h(no); } - VString oislice_t(iterator it) const { return this->xislice_t(it); } - VString oislice_h(iterator it) const { return this->xislice_h(it); } - VString olslice(size_t o, size_t l) const { return this->xlslice(o, l); } - VString opslice(size_t b, size_t e) const { return this->xpslice(b, e); } - VString oislice(iterator b, iterator e) const { return this->xislice(b, e); } }; // cxxstdio helpers diff --git a/src/strings/xstring.hpp b/src/strings/xstring.hpp index 448d0ba..72cae1e 100644 --- a/src/strings/xstring.hpp +++ b/src/strings/xstring.hpp @@ -53,16 +53,6 @@ namespace strings iterator begin() const; iterator end() const; const FString *base() const; - - XString oslice_t(size_t o) const { return xslice_t(o); } - XString oslice_h(size_t o) const { return xslice_h(o); } - XString orslice_t(size_t no) const { return xrslice_t(no); } - XString orslice_h(size_t no) const { return xrslice_h(no); } - XString oislice_t(iterator it) const { return xislice_t(it); } - XString oislice_h(iterator it) const { return xislice_h(it); } - XString olslice(size_t o, size_t l) const { return xlslice(o, l); } - XString opslice(size_t b, size_t e) const { return xpslice(b, e); } - XString oislice(iterator b, iterator e) const { return xislice(b, e); } }; } // namespace strings diff --git a/src/strings/zstring.cpp b/src/strings/zstring.cpp index 3b86b0e..0de836c 100644 --- a/src/strings/zstring.cpp +++ b/src/strings/zstring.cpp @@ -56,25 +56,6 @@ namespace strings return &*begin(); } - ZS ZS::oslice_t(size_t o) const - { return ZS(really_construct_from_a_pointer, &begin()[o], base()); } - XS ZS::oslice_h(size_t o) const - { return XS(&*begin(), &begin()[o], base()); } - ZS ZS::orslice_t(size_t no) const - { return ZS(really_construct_from_a_pointer, &end()[-no], base()); } - XS ZS::orslice_h(size_t no) const - { return XS(&*begin(), &end()[-no], base()); } - ZS ZS::oislice_t(iterator it) const - { return ZS(really_construct_from_a_pointer, &*it, base()); } - XS ZS::oislice_h(iterator it) const - { return XS(&*begin(), &*it, base()); } - XS ZS::olslice(size_t o, size_t l) const - { return XS(&begin()[o], &begin()[o + l], base()); } - XS ZS::opslice(size_t b, size_t e) const - { return XS(&begin()[b], &begin()[e], base()); } - XS ZS::oislice(iterator b, iterator e) const - { return XS(&*b, &*e, base()); } - const char *decay_for_printf(const ZString& zs) { return zs.c_str(); diff --git a/src/strings/zstring.hpp b/src/strings/zstring.hpp index 1b7e7fc..358e3bc 100644 --- a/src/strings/zstring.hpp +++ b/src/strings/zstring.hpp @@ -54,16 +54,6 @@ namespace strings iterator end() const; const FString *base() const; const char *c_str() const; - - ZString oslice_t(size_t o) const; - XString oslice_h(size_t o) const; - ZString orslice_t(size_t no) const; - XString orslice_h(size_t no) const; - ZString oislice_t(iterator it) const; - XString oislice_h(iterator it) const; - XString olslice(size_t o, size_t l) const; - XString opslice(size_t b, size_t e) const; - XString oislice(iterator b, iterator e) const; }; // cxxstdio helpers |