#ifndef OPENTRACING_VALUE_H #define OPENTRACING_VALUE_H #include #include #include #include #include #include #include namespace opentracing { BEGIN_OPENTRACING_ABI_NAMESPACE // Variant value types for span tags and log payloads. class Value; typedef std::unordered_map Dictionary; typedef std::vector Values; typedef util::variant, util::recursive_wrapper> variant_type; class Value : public variant_type { public: Value() noexcept : variant_type(nullptr) {} Value(std::nullptr_t) noexcept : variant_type(nullptr) {} // variant_type's constructors will do some undesirable casting, for example // variant_type(123) // will construct a bool variant; hence, constructors are expanded // out so as to provide more sensible behavior. Value(bool x) noexcept : variant_type(x) {} template ::value && std::is_signed::value>::type* = nullptr> Value(T t) noexcept : variant_type(static_cast(t)) {} template ::value && std::is_unsigned::value>::type* = nullptr> Value(T t) noexcept : variant_type(static_cast(t)) {} template ::value>::type* = nullptr> Value(T t) noexcept : variant_type(static_cast(t)) {} Value(const char* s) noexcept : variant_type(s) {} template Value(const char (&cstr)[N]) : variant_type(std::string(cstr)) {} Value(const std::string& s) : variant_type(s) {} Value(std::string&& s) : variant_type(std::move(s)) {} Value(opentracing::string_view s) noexcept : variant_type(s) {} Value(const Values& values) : variant_type(values) {} Value(Values&& values) : variant_type(std::move(values)) {} Value(const Dictionary& values) : variant_type(values) {} Value(Dictionary&& values) : variant_type(std::move(values)) {} }; END_OPENTRACING_ABI_NAMESPACE } // namespace opentracing #endif // OPENTRACING_VALUE_H