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);
66 AttributeMap()
noexcept {}
75 attributes.reserve(attributes_.size());
77 for (
const auto &item : attributes_)
79 const void *data =
nullptr;
80 auto type = CExports::CVTAT_Undefined;
81 if (holds_alternative<std::string>(item.second))
83 data = get<std::string>(item.second).c_str();
84 type = CExports::CVTAT_String;
86 else if (holds_alternative<double>(item.second))
88 data = &get<double>(item.second);
89 type = CExports::CVTAT_Double;
91 else if (holds_alternative<bool>(item.second))
93 data = &get<bool>(item.second);
94 type = CExports::CVTAT_Bool;
96 else if (holds_alternative<int64_t>(item.second))
98 data = &get<int64_t>(item.second);
99 type = CExports::CVTAT_Int64;
103 CExports::CVTAttribute attribute;
104 attribute.Name = item.first.c_str();
105 attribute.Type = type;
106 attribute.Data =
const_cast<void *
>(data);
107 attributes.push_back(attribute);
110 CExports::CVTAttributeMapStore(handle_, attributes.data(), attributes.size());
118 void *handle_ =
nullptr;