From 2dad3138850d0b58850ea0cb23af5c73dd455882 Mon Sep 17 00:00:00 2001 From: Joshua Scott Date: Thu, 20 Dec 2018 15:45:52 +0000 Subject: [PATCH] pclass: Add value_caster specialization for json to bit integer --- include/ki/pclass/Casters.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/ki/pclass/Casters.h b/include/ki/pclass/Casters.h index 540c465..eb981bd 100644 --- a/include/ki/pclass/Casters.h +++ b/include/ki/pclass/Casters.h @@ -183,6 +183,24 @@ namespace detail } }; + /** + * Caster implementation for casting from json to + * bit integers (bi and bui) + */ + template + struct value_caster> + : value_caster_impl> + { + using type = typename BitInteger::type; + + BitInteger cast_value(const nlohmann::json &value) const override + { + return BitInteger( + static_cast(value) + ); + } + }; + /** * Caster implementation for casting from json to a * std::string.