diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compileTimeFormatter.h | 22 | ||||
-rw-r--r-- | lib/mysql_types.cpp | 36 | ||||
-rw-r--r-- | lib/rawDataReader.cpp | 8 |
3 files changed, 34 insertions, 32 deletions
diff --git a/lib/compileTimeFormatter.h b/lib/compileTimeFormatter.h index 7d69d4b..341e229 100644 --- a/lib/compileTimeFormatter.h +++ b/lib/compileTimeFormatter.h @@ -99,15 +99,15 @@ namespace MyGrate { } }; -#define StreamWriterT(C...) \ +#define StreamWriterT(...) \ template<const auto S, auto L, auto pos, typename stream, auto... sn> \ - struct StreamWriter<S, L, pos, stream, void, '%', C, sn...> : \ - public StreamWriterBase<S, L, BOOST_PP_VARIADIC_SIZE(C) + pos, stream> + struct StreamWriter<S, L, pos, stream, void, '%', __VA_ARGS__, sn...> : \ + public StreamWriterBase<S, L, BOOST_PP_VARIADIC_SIZE(__VA_ARGS__) + pos, stream> -#define StreamWriterTP(P, C...) \ +#define StreamWriterTP(P, ...) \ template<const auto S, auto L, auto pos, typename stream, auto P, auto... sn> \ - struct StreamWriter<S, L, pos, stream, void, '%', C, sn...> : \ - public StreamWriterBase<S, L, BOOST_PP_VARIADIC_SIZE(C) + pos, stream> + struct StreamWriter<S, L, pos, stream, void, '%', __VA_ARGS__, sn...> : \ + public StreamWriterBase<S, L, BOOST_PP_VARIADIC_SIZE(__VA_ARGS__) + pos, stream> // Default stream writer formatter StreamWriterT('?') { @@ -300,7 +300,7 @@ namespace MyGrate { BASICCONV(BASE, OP, CONV); \ BASICCONV(short BASE, OP, 'h', CONV); \ BASICCONV(long BASE, OP, 'l', CONV); \ - BASICCONV(long long BASE, OP, 'l', 'l', CONV); + BASICCONV(long long BASE, OP, 'l', 'l', CONV) INTCONV(int, s << std::dec << p, 'i'); INTCONV(int, s << std::dec << p, 'd'); INTCONV(unsigned int, s << std::oct << p, 'o'); @@ -323,7 +323,7 @@ namespace MyGrate { // Floating point (a, A, e, E, f, F, g, G) #define FPCONV(BASE, OP, CONV) \ BASICCONV(BASE, OP, CONV); \ - BASICCONV(long BASE, OP, 'L', CONV); + BASICCONV(long BASE, OP, 'L', CONV) FPCONV(double, s << std::nouppercase << std::hexfloat << p, 'a'); FPCONV(double, s << std::uppercase << std::hexfloat << p, 'A'); FPCONV(double, s << std::nouppercase << std::scientific << p, 'e'); @@ -415,7 +415,7 @@ namespace MyGrate { StreamWriter<S, L, pos + BOOST_PP_ADD(d, 1), stream, void, '%', nn, sn...>::write(s, pn...); \ } \ }; - BOOST_PP_REPEAT(6, FMTWIDTH, void); + BOOST_PP_REPEAT(6, FMTWIDTH, void) #define FMTPRECISION(unused, d, data) \ template<const auto S, auto L, auto pos, typename stream, BOOST_PP_REPEAT(BOOST_PP_ADD(d, 1), AUTON, n), auto nn, \ auto... sn> \ @@ -431,7 +431,7 @@ namespace MyGrate { StreamWriter<S, L, pos + BOOST_PP_ADD(d, 2), stream, void, '%', nn, sn...>::write(s, pn...); \ } \ }; - BOOST_PP_REPEAT(6, FMTPRECISION, void); + BOOST_PP_REPEAT(6, FMTPRECISION, void) #undef AUTON #undef NS #undef ISDIGIT @@ -467,7 +467,7 @@ namespace MyGrate { OP; \ StreamWriter<S, L, pos + 1, stream, void, '%', sn...>::write(s, pn...); \ } \ - }; + } FLAGCONV(s << std::showbase, '#'); FLAGCONV(s << std::setfill('0'), '0'); FLAGCONV(s << std::left, '-'); diff --git a/lib/mysql_types.cpp b/lib/mysql_types.cpp index 4480d23..626e789 100644 --- a/lib/mysql_types.cpp +++ b/lib/mysql_types.cpp @@ -15,8 +15,8 @@ namespace MyGrate::MySQL { x = bswap_##B(x); \ return x; \ } - NTOH(32); - NTOH(64); + NTOH(32) + NTOH(64) typename Type<MYSQL_TYPE_NULL, false>::C Type<MYSQL_TYPE_NULL, false>::read(RawDataReader &, RawDataReader &) @@ -33,10 +33,10 @@ namespace MyGrate::MySQL { { \ return data.readValue<typename Type<ET, true>::C>(); \ } - INTEGER_TYPE(MYSQL_TYPE_TINY); - INTEGER_TYPE(MYSQL_TYPE_SHORT); - INTEGER_TYPE(MYSQL_TYPE_LONG); - INTEGER_TYPE(MYSQL_TYPE_LONGLONG); + INTEGER_TYPE(MYSQL_TYPE_TINY) + INTEGER_TYPE(MYSQL_TYPE_SHORT) + INTEGER_TYPE(MYSQL_TYPE_LONG) + INTEGER_TYPE(MYSQL_TYPE_LONGLONG) #undef INTEGER_TYPE #define FLOAT_TYPE(ET) \ @@ -45,8 +45,8 @@ namespace MyGrate::MySQL { verify<std::length_error>(sizeof(typename Type<ET>::C) == md.readValue<uint8_t>(), "Invalid " #ET " size"); \ return data.readValue<typename Type<ET>::C>(); \ } - FLOAT_TYPE(MYSQL_TYPE_FLOAT); - FLOAT_TYPE(MYSQL_TYPE_DOUBLE); + FLOAT_TYPE(MYSQL_TYPE_FLOAT) + FLOAT_TYPE(MYSQL_TYPE_DOUBLE) #undef FLOAT_TYPE typename Type<MYSQL_TYPE_DECIMAL>::C @@ -66,8 +66,8 @@ namespace MyGrate::MySQL { { \ return data.readValue<typename Type<ET, s>::C, l>(); \ } - INTEGER_TYPE(MYSQL_TYPE_INT24, false, 3); - INTEGER_TYPE(MYSQL_TYPE_INT24, true, 3); + INTEGER_TYPE(MYSQL_TYPE_INT24, false, 3) + INTEGER_TYPE(MYSQL_TYPE_INT24, true, 3) #undef INTEGER_TYPE typename Type<MYSQL_TYPE_YEAR, false>::C @@ -92,10 +92,10 @@ namespace MyGrate::MySQL { { \ return readBlob(md, data); \ } - BLOB_TYPE(MYSQL_TYPE_TINY_BLOB); - BLOB_TYPE(MYSQL_TYPE_MEDIUM_BLOB); - BLOB_TYPE(MYSQL_TYPE_LONG_BLOB); - BLOB_TYPE(MYSQL_TYPE_GEOMETRY); // Ummm, pass this to the target to handle? + BLOB_TYPE(MYSQL_TYPE_TINY_BLOB) + BLOB_TYPE(MYSQL_TYPE_MEDIUM_BLOB) + BLOB_TYPE(MYSQL_TYPE_LONG_BLOB) + BLOB_TYPE(MYSQL_TYPE_GEOMETRY) // Ummm, pass this to the target to handle? #undef BLOB_TYPE typename Type<MYSQL_TYPE_BLOB, false>::C @@ -126,10 +126,10 @@ namespace MyGrate::MySQL { } \ throw std::logic_error("Didn't return a value: " + std::to_string(realtype)); \ } - STRING_TYPE(MYSQL_TYPE_STRING); - STRING_TYPE(MYSQL_TYPE_JSON); - STRING_TYPE(MYSQL_TYPE_SET); - STRING_TYPE(MYSQL_TYPE_ENUM); + STRING_TYPE(MYSQL_TYPE_STRING) + STRING_TYPE(MYSQL_TYPE_JSON) + STRING_TYPE(MYSQL_TYPE_SET) + STRING_TYPE(MYSQL_TYPE_ENUM) #undef STRING_TYPE typename Type<MYSQL_TYPE_VARCHAR>::C diff --git a/lib/rawDataReader.cpp b/lib/rawDataReader.cpp index 90e227a..c0f32b5 100644 --- a/lib/rawDataReader.cpp +++ b/lib/rawDataReader.cpp @@ -26,9 +26,11 @@ namespace MyGrate { uint64_t RawDataReader::readValue<PackedInteger>() { - switch (const auto byte1 {readValue<uint8_t>()}) { - case 0 ... 250: // The value as-is - return byte1; + const auto byte1 {readValue<uint8_t>()}; + if (byte1 <= 250) { + return byte1; + } + switch (byte1) { case 252: // 2 bytes return readValue<uint16_t, 2>(); case 253: // 3 bytes |