diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-09 14:10:28 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-09 14:10:28 +0000 |
commit | e75ca99d2137d2ae0d19c46bcc4dafb0d2cd5e45 (patch) | |
tree | a5b69b26d2b3ee28dd596f37cb4f134980c40463 | |
parent | Simplify parser templates (diff) | |
download | libadhocutil-e75ca99d2137d2ae0d19c46bcc4dafb0d2cd5e45.tar.bz2 libadhocutil-e75ca99d2137d2ae0d19c46bcc4dafb0d2cd5e45.tar.xz libadhocutil-e75ca99d2137d2ae0d19c46bcc4dafb0d2cd5e45.zip |
Split parser buffer from upto buffer (simpler)
-rw-r--r-- | libadhocutil/compileTimeFormatter.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libadhocutil/compileTimeFormatter.h b/libadhocutil/compileTimeFormatter.h index d45d662..064c4e3 100644 --- a/libadhocutil/compileTimeFormatter.h +++ b/libadhocutil/compileTimeFormatter.h @@ -117,6 +117,8 @@ namespace AdHoc { static int err; }; + template <bool, char...> struct ParserBuffer { }; + template <const char * const & S, int offset, int roffset, char s0, char ... sn> struct Parser { static auto parse() @@ -128,19 +130,19 @@ namespace AdHoc { return Parser<S, offset + 1, roffset + 1, S[offset + 1], sn..., s0>::innerparse(); } template<char...ssn> - static auto append(const Buffer<true, 0, ssn...> & b) + static auto append(const ParserBuffer<true, ssn...> & b) { return join(b, Parser<S, offset + 1 + WRAP_AT, 0, S[offset + 1 + WRAP_AT]>::parse()); } template<char...ssn> - static auto append(const Buffer<false, 0, ssn...> & b) + static auto append(const ParserBuffer<false, ssn...> & b) { return b; } template<bool more, char...ssn, char...ssm> - static auto join(const Buffer<true, 0, ssn...> &, const Buffer<more, 0, ssm...> &) + static auto join(const ParserBuffer<true, ssn...> &, const ParserBuffer<more, ssm...> &) { - return Buffer<more, 0, ssn..., ssm...>(); + return ParserBuffer<more, ssn..., ssm...>(); } }; @@ -152,7 +154,7 @@ namespace AdHoc { } static auto innerparse() { - return Buffer<more, 0, sn...>(); + return ParserBuffer<more, sn...>(); } }; @@ -173,8 +175,8 @@ namespace AdHoc { run(Parser<S, 0, 0, *S>::parse(), s, pn...); } - template<typename stream, char...ssn, template<bool, int, char...> class Buffer, typename ... Pn> - static void run(const Buffer<false, 0, ssn...> &, stream & s, const Pn & ... pn) + template<typename stream, char...ssn, template<bool, char...> class ParserBuffer, typename ... Pn> + static void run(const ParserBuffer<false, ssn...> &, stream & s, const Pn & ... pn) { StreamWriter<S, 0, stream, ssn...>::write(s, pn...); } |