#ifndef LLARP_UTIL_STATUS_HPP #define LLARP_UTIL_STATUS_HPP #include #include #include #include #include #include namespace llarp { namespace util { using StatusObject_Impl = json::Document; using Value_t = json::Value; struct StatusObject { using String_t = string_view; using Variant = absl::variant< uint64_t, std::string, bool, StatusObject, std::vector< std::string >, std::vector< StatusObject > >; using value_type = std::tuple< String_t, Variant >; StatusObject(const StatusObject&); ~StatusObject(); StatusObject(std::initializer_list< value_type > vals) { Impl.SetObject(); std::for_each(vals.begin(), vals.end(), [&](const value_type& item) { Put(item); }); } void Put(String_t name, const Variant& value); void Put(const value_type& value); StatusObject_Impl Impl; private: void PutBool(String_t name, bool val); void PutInt(String_t name, uint64_t val); void PutObject(String_t name, const StatusObject& val); void PutObjectArray(String_t name, const std::vector< StatusObject >& arr); void PutStringArray(String_t name, const std::vector< std::string >& arr); void PutString(String_t name, const std::string& val); }; /// an entity that has a status that can be extracted struct IStateful { virtual ~IStateful(){}; virtual StatusObject ExtractStatus() const = 0; }; } // namespace util } // namespace llarp #endif