From b2f0d495cd85188e0f9f2d4d363655da40e6e5e6 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Thu, 22 Jan 2015 12:25:18 -0800 Subject: Have I mentioned that I hate ADL? --- src/io/extract.hpp | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) (limited to 'src/io/extract.hpp') diff --git a/src/io/extract.hpp b/src/io/extract.hpp index 174243e..897f50e 100644 --- a/src/io/extract.hpp +++ b/src/io/extract.hpp @@ -39,10 +39,10 @@ namespace tmwa { template -bool do_extract(XString str, T t); +bool extract(XString str, T t); template::value && !std::is_same::value && !std::is_same::value>::type> -bool extract(XString str, T *iv) +bool impl_extract(XString str, T *iv) { if (!str || str.size() > 20) return false; @@ -75,7 +75,7 @@ bool extract(XString str, T *iv) } inline -bool extract(XString str, TimeT *tv) +bool impl_extract(XString str, TimeT *tv) { return extract(str, &tv->value); } @@ -93,12 +93,12 @@ bool extract_as_int(XString str, T *iv) return true; } -bool extract(XString str, XString *rv); -bool extract(XString str, RString *rv); -bool extract(XString str, AString *rv); +bool impl_extract(XString str, XString *rv); +bool impl_extract(XString str, RString *rv); +bool impl_extract(XString str, AString *rv); template -bool extract(XString str, VString *out) +bool impl_extract(XString str, VString *out) { if (str.size() > N) return false; @@ -107,7 +107,7 @@ bool extract(XString str, VString *out) } inline -bool extract(XString str, LString exact) +bool impl_extract(XString str, LString exact) { return str == exact; } @@ -126,7 +126,7 @@ LStripper lstripping(T v) } template -bool extract(XString str, LStripper out) +bool impl_extract(XString str, LStripper out) { return extract(str.lstrip(), out.impl); } @@ -163,13 +163,13 @@ Record record(T... t) } template -bool extract(XString str, Record) +bool impl_extract(XString str, Record) { return !str; } template -bool extract(XString str, Record rec) +bool impl_extract(XString str, Record rec) { XString::iterator s = std::find(str.begin(), str.end(), split); XString::iterator s2 = s; @@ -198,7 +198,7 @@ VRecord vrec(std::vector *arr) } template -bool extract(XString str, VRecord rec) +bool impl_extract(XString str, VRecord rec) { if (!str) return true; @@ -210,23 +210,25 @@ bool extract(XString str, VRecord rec) && extract(str.xislice_t(s + 1), rec); } -template -bool do_extract(XString str, T t) -{ - return extract(str, t); -} - template -bool extract(XString str, Wrapped *w) +bool impl_extract(XString str, Wrapped *w) { return extract(str, &w->_value); } -bool extract(XString str, std::chrono::nanoseconds *ns); -bool extract(XString str, std::chrono::microseconds *us); -bool extract(XString str, std::chrono::milliseconds *ms); -bool extract(XString str, std::chrono::seconds *s); -bool extract(XString str, std::chrono::minutes *min); -bool extract(XString str, std::chrono::hours *h); -bool extract(XString str, std::chrono::duration> *d); +bool impl_extract(XString str, std::chrono::nanoseconds *ns); +bool impl_extract(XString str, std::chrono::microseconds *us); +bool impl_extract(XString str, std::chrono::milliseconds *ms); +bool impl_extract(XString str, std::chrono::seconds *s); +bool impl_extract(XString str, std::chrono::minutes *min); +bool impl_extract(XString str, std::chrono::hours *h); +bool impl_extract(XString str, std::chrono::duration> *d); + +// this must come after all non-`namespace tmwa` `impl_extract`s. +// In particular, the ones for `*int*` and `std::chrono::*` +template +bool extract(XString str, T t) +{ + return impl_extract(str, t); +} } // namespace tmwa -- cgit v1.2.3-60-g2f50