diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-09 14:11:51 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-09 14:11:51 +0000 |
commit | 1dc8cd000779a07c21eb631472e6061780c84c8c (patch) | |
tree | 5d6af27fd75a7f0b9887e68bd15ef58f791fd6bf | |
parent | Split parser buffer from upto buffer (simpler) (diff) | |
download | libadhocutil-1dc8cd000779a07c21eb631472e6061780c84c8c.tar.bz2 libadhocutil-1dc8cd000779a07c21eb631472e6061780c84c8c.tar.xz libadhocutil-1dc8cd000779a07c21eb631472e6061780c84c8c.zip |
Simplify the upto buffer
-rw-r--r-- | libadhocutil/compileTimeFormatter.h | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/libadhocutil/compileTimeFormatter.h b/libadhocutil/compileTimeFormatter.h index 064c4e3..64581ea 100644 --- a/libadhocutil/compileTimeFormatter.h +++ b/libadhocutil/compileTimeFormatter.h @@ -5,12 +5,12 @@ namespace AdHoc { constexpr int WRAP_AT = 120; - template <bool, int, char...> struct Buffer { }; + template <int, char...> struct Buffer { }; template <const char * const & S, char stop, int start, int offset, char ...> struct Upto { template<typename stream> - static auto stuff(stream &, const Buffer<false, start> & f) + static auto stuff(stream &, const Buffer<start> & f) { return f; } @@ -18,54 +18,54 @@ namespace AdHoc { template <const char * const & S, char stop, int start, int offset, char s0, char... sn> struct Upto<S, stop, start, offset, s0, sn...> { template<typename stream, int len, char... sm> - static auto stuff(stream & s, const Buffer<false, len, sm...> &) + static auto stuff(stream & s, const Buffer<len, sm...> &) { - return Upto<S, stop, start, offset + 1, sn...>::stuff(s, Buffer<false, len, sm..., s0>()); + return Upto<S, stop, start, offset + 1, sn...>::stuff(s, Buffer<len, sm..., s0>()); } }; template <const char * const & S, char stop, int start, int offset, char... sn> struct Upto<S, stop, start, offset, stop, sn...> { template<typename stream, int len, char... sm> - static auto stuff(stream & s, const Buffer<false, len, sm...> &) + static auto stuff(stream & s, const Buffer<len, sm...> &) { s.write(S + start, sizeof...(sm)); - return Buffer<false, sizeof...(sm), stop, sn...>(); + return Buffer<sizeof...(sm), stop, sn...>(); } }; template <const char * const & S, char stop, int start, int offset, char... sn> struct Upto<S, stop, start, offset, 0, sn...> { template<typename stream, int len, char... sm> - static auto stuff(stream & s, const Buffer<false, len, sm...> &) + static auto stuff(stream & s, const Buffer<len, sm...> &) { s.write(S + start, sizeof...(sm)); - return Buffer<false, sizeof...(sm), 0, sn...>(); + return Buffer<sizeof...(sm), 0, sn...>(); } }; template <const char * const & S, char stop, int start, char s0, char... sn> struct Upto<S, stop, start, WRAP_AT, s0, sn...> { template<typename stream, int len, char... sm> - static auto stuff(stream & s, const Buffer<false, len, sm...> &) + static auto stuff(stream & s, const Buffer<len, sm...> &) { s.write(S + start, sizeof...(sm)); - return Buffer<false, sizeof...(sm), s0, sn...>(); + return Buffer<sizeof...(sm), s0, sn...>(); } }; template <const char * const & S, char stop, int start, char... sn> struct Upto<S, stop, start, WRAP_AT, stop, sn...> { template<typename stream, int len, char... sm> - static auto stuff(stream & s, const Buffer<false, len, sm...> &) + static auto stuff(stream & s, const Buffer<len, sm...> &) { s.write(S + start, sizeof...(sm)); - return Buffer<false, sizeof...(sm), stop, sn...>(); + return Buffer<sizeof...(sm), stop, sn...>(); } }; template <const char * const & S, char stop, int start, char... sn> struct Upto<S, stop, start, WRAP_AT, 0, sn...> { template<typename stream, int len, char... sm> - static auto stuff(stream & s, const Buffer<false, len, sm...> &) + static auto stuff(stream & s, const Buffer<len, sm...> &) { s.write(S + start, sizeof...(sm)); - return Buffer<false, sizeof...(sm), 0, sn...>(); + return Buffer<sizeof...(sm), 0, sn...>(); } }; @@ -74,10 +74,10 @@ namespace AdHoc { template<typename ... Pn> static void write(stream & s, const Pn & ... pn) { - next(s, Upto<S, '%', start, 0, sn...>::stuff(s, Buffer<false, 0>()), pn...); + next(s, Upto<S, '%', start, 0, sn...>::stuff(s, Buffer<0>()), pn...); } - template<typename ... Pn, int len, char... ssn, template <bool, int, char...> class Buffer> - static void next(stream & s, const Buffer<false, len, ssn...>&, const Pn & ... pn) + template<typename ... Pn, int len, char... ssn, template <int, char...> class Buffer> + static void next(stream & s, const Buffer<len, ssn...>&, const Pn & ... pn) { StreamWriter<S, start + len, stream, ssn...>::write(s, pn...); } |