From ad049a15b43b7ddba3fe7d0a898652fc8022629d Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 22 Apr 2014 11:46:23 -0700 Subject: Use strict ID types Possibly some missing for the far side of the network. AccountId and BlockId are still terribly entangled. --- src/mmo/extract.hpp | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'src/mmo/extract.hpp') diff --git a/src/mmo/extract.hpp b/src/mmo/extract.hpp index f3df0f3..ab65661 100644 --- a/src/mmo/extract.hpp +++ b/src/mmo/extract.hpp @@ -19,7 +19,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -# include "../sanity.hpp" +# include "fwd.hpp" # include # include @@ -27,11 +27,17 @@ # include # include +# include "../ints/wrap.hpp" + # include "../strings/xstring.hpp" -# include "mmo.hpp" +# include "../generic/enum.hpp" + # include "utils.hpp" +template +bool do_extract(XString str, T t); + template::value && !std::is_same::value && !std::is_same::value>::type> bool extract(XString str, T *iv) { @@ -98,6 +104,12 @@ bool extract(XString str, VString *out) return true; } +inline +bool extract(XString str, LString exact) +{ + return str == exact; +} + template class LStripper { @@ -200,27 +212,20 @@ bool extract(XString str, struct global_reg *var); bool extract(XString str, struct item *it); -inline -bool extract(XString str, MapName *m) -{ - XString::iterator it = std::find(str.begin(), str.end(), '.'); - str = str.xislice_h(it); - VString<15> tmp; - bool rv = extract(str, &tmp); - *m = tmp; - return rv; +bool extract(XString str, MapName *m); + +bool extract(XString str, CharName *out); + +template +bool do_extract(XString str, T t) +{ + return extract(str, t); } -inline -bool extract(XString str, CharName *out) +template +bool extract(XString str, Wrapped *w) { - VString<23> tmp; - if (extract(str, &tmp)) - { - *out = CharName(tmp); - return true; - } - return false; + return extract(str, &w->_value); } #endif // TMWA_MMO_EXTRACT_HPP -- cgit v1.2.3-70-g09d2