diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-04-22 11:46:23 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-04-22 13:20:52 -0700 |
commit | ad049a15b43b7ddba3fe7d0a898652fc8022629d (patch) | |
tree | 142624e70ead3e89a8da6d56de41651f171524d0 /src/mmo/extract.hpp | |
parent | ceeda2e337077b2edaf1af09cc4df2c30e8205a1 (diff) | |
download | tmwa-ad049a15b43b7ddba3fe7d0a898652fc8022629d.tar.gz tmwa-ad049a15b43b7ddba3fe7d0a898652fc8022629d.tar.bz2 tmwa-ad049a15b43b7ddba3fe7d0a898652fc8022629d.tar.xz tmwa-ad049a15b43b7ddba3fe7d0a898652fc8022629d.zip |
Use strict ID types
Possibly some missing for the far side of the network.
AccountId and BlockId are still terribly entangled.
Diffstat (limited to 'src/mmo/extract.hpp')
-rw-r--r-- | src/mmo/extract.hpp | 45 |
1 files changed, 25 insertions, 20 deletions
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 <http://www.gnu.org/licenses/>. -# include "../sanity.hpp" +# include "fwd.hpp" # include <cerrno> # include <cstdlib> @@ -27,11 +27,17 @@ # include <algorithm> # include <vector> +# include "../ints/wrap.hpp" + # include "../strings/xstring.hpp" -# include "mmo.hpp" +# include "../generic/enum.hpp" + # include "utils.hpp" +template<class T> +bool do_extract(XString str, T t); + template<class T, typename=typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, char>::value && !std::is_same<T, bool>::value>::type> bool extract(XString str, T *iv) { @@ -98,6 +104,12 @@ bool extract(XString str, VString<N> *out) return true; } +inline +bool extract(XString str, LString exact) +{ + return str == exact; +} + template<class T> 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<class T> +bool do_extract(XString str, T t) +{ + return extract(str, t); } -inline -bool extract(XString str, CharName *out) +template<class R> +bool extract(XString str, Wrapped<R> *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 |