17 using Attribute = variant<bool, int64_t, double, std::string>;
35 AttributeMap(
const AttributeMap &other) =
delete;
36 AttributeMap& operator=(
const AttributeMap &other) =
delete;
37 AttributeMap(AttributeMap&& other) noexcept
38 : attributes_(
std::move(other.attributes_))
42 AttributeMap& operator=(AttributeMap&& other)
noexcept
46 attributes_ =
std::move(other.attributes_);
51 virtual ~AttributeMap() =
default;
54 AttributeMap &operator()(
const std::string &key,
const T &value);
60 AttributeMap &operator()(
const std::string &key,
void *value);
72 explicit operator bool() const noexcept
74 return handle_ !=
nullptr;
87 attributes.reserve(attributes_.size());
89 for (
const auto &item : attributes_)
91 const void *data =
nullptr;
92 auto type = CExports::CVTAT_Undefined;
93 if (holds_alternative<std::string>(item.second))
95 data = get<std::string>(item.second).c_str();
96 type = CExports::CVTAT_String;
98 else if (holds_alternative<double>(item.second))
100 data = &get<double>(item.second);
101 type = CExports::CVTAT_Double;
103 else if (holds_alternative<bool>(item.second))
105 data = &get<bool>(item.second);
106 type = CExports::CVTAT_Bool;
108 else if (holds_alternative<int64_t>(item.second))
110 data = &get<int64_t>(item.second);
111 type = CExports::CVTAT_Int64;
115 CExports::CVTAttribute attribute;
116 attribute.Name = item.first.c_str();
117 attribute.Type = type;
118 attribute.Data =
const_cast<void *
>(data);
119 attributes.push_back(attribute);
122 CExports::CVTAttributeMapStore(handle_, attributes.data(), attributes.size());
130 void *handle_ =
nullptr;
131 std::map<std::string, Attribute> attributes_;