From 046cdae1a14a686238ab91b1f883335b2de5a78c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 1 Jun 2021 00:17:38 +0100 Subject: Generate DbStmt templates from .sql files m4 generator and related code. Reshuffles some CTF stuff to avoid pulling in all of CTF and iostream for its fixed_string. Moves CTF out of AdHoc namespace. Add some initial SQL statements. --- lib/compileTimeFormatter.h | 72 +++++++--------------------------------------- 1 file changed, 10 insertions(+), 62 deletions(-) (limited to 'lib/compileTimeFormatter.h') diff --git a/lib/compileTimeFormatter.h b/lib/compileTimeFormatter.h index 17da62e..09aae53 100644 --- a/lib/compileTimeFormatter.h +++ b/lib/compileTimeFormatter.h @@ -1,6 +1,7 @@ -#ifndef ADHOCUTIL_COMPILE_TIME_FORMATTER_H -#define ADHOCUTIL_COMPILE_TIME_FORMATTER_H +#ifndef MYGRATE_COMPILE_TIME_FORMATTER_H +#define MYGRATE_COMPILE_TIME_FORMATTER_H +#include "fixedString.h" #include #include #include @@ -9,7 +10,7 @@ #include // IWYU pragma: export #include -namespace AdHoc { +namespace MyGrate { // Template char utils template constexpr bool @@ -235,82 +236,29 @@ namespace AdHoc { }; }; - // New C++20 implementation - namespace support { - template class basic_fixed_string { - public: - // cppcheck-suppress noExplicitConstructor - constexpr basic_fixed_string(const CharT (&str)[N + 1]) - { - for (decltype(N) x = 0; x < N; x++) { - arr.at(x) = str[x]; - } - arr.at(N) = '\0'; - } - constexpr basic_fixed_string(const CharT * str, decltype(N) len) - { - for (decltype(N) x = 0; x < len; x++) { - arr.at(x) = str[x]; - } - arr.at(N) = '\0'; - } - constexpr const char * - s() const - { - return arr.data(); - } - constexpr operator const char *() const - { - return s(); - } - constexpr std::string_view - v() const - { - return {arr.data(), arr.size() - 1}; - } - constexpr auto & - operator[](std::size_t n) const - { - return arr[n]; - } - constexpr auto - size() const - { - return arr.size() - 1; - } - - std::array arr; - }; - - template - basic_fixed_string(const CharT (&str)[N]) -> basic_fixed_string; - } - - template class LiteralFormatter : public FormatterDetail { + template class LiteralFormatter : public FormatterDetail { }; template class Formatter : - public FormatterDetail::type, L>(S, L), L> { + public FormatterDetail::type, L>(S, L), L> { }; -#define AdHocFormatter(name, str) using name = ::AdHoc::LiteralFormatter - - template + template inline auto scprintf(const Pn &... pn) { return FormatterDetail::get(pn...); } - template + template inline auto & scprintf(stream & strm, const Pn &... pn) { return FormatterDetail::write(strm, pn...); } - template + template inline auto & cprintf(const Pn &... pn) { @@ -327,7 +275,7 @@ namespace AdHoc { #include #include -namespace AdHoc { +namespace MyGrate { #define BASICCONV(PARAMTYPE, OP, ...) \ StreamWriterT(__VA_ARGS__) { \ template \ -- cgit v1.2.3