From 713b8d500665240f01ec7e6574ac4f34f44e57dd Mon Sep 17 00:00:00 2001 From: Ivan Shynkarenka Date: Sun, 25 Sep 2016 18:20:39 +0300 Subject: [PATCH] Extend ArgLists to support serialization/deserialization in third-party components --- fmt/format.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fmt/format.h b/fmt/format.h index 0f471cc4..8aabc0c7 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -1004,6 +1004,7 @@ struct Value { void *formatter, const void *arg, void *format_str_ptr); struct CustomValue { + std::size_t size; const void *value; FormatFunc format; }; @@ -1303,6 +1304,7 @@ class MakeValue : public Arg { MakeValue(const T &value, typename EnableIf::value>::value, int>::type = 0) { + custom.size = sizeof(T); custom.value = &value; custom.format = &format_custom_arg; } @@ -1377,10 +1379,13 @@ class ArgList { }; internal::Arg::Type type(unsigned index) const { + return type(types_, index); + } + static internal::Arg::Type type(uint64_t types, unsigned index) { unsigned shift = index * 4; uint64_t mask = 0xf; return static_cast( - (types_ & (mask << shift)) >> shift); + (types & (mask << shift)) >> shift); } template @@ -1397,6 +1402,8 @@ class ArgList { ArgList(ULongLong types, const internal::Arg *args) : types_(types), args_(args) {} + uint64_t types() const { return types_; } + /** Returns the argument at specified index. */ internal::Arg operator[](unsigned index) const { using internal::Arg;