Fixup std::variant usage
This change refactors mapbox::variant specific usage onto an API that
mapbox::variant and std::variant both support.
Tested:
Run through unit tests.
Change-Id: Ic35953b4772398495129830ed0d4455409f844ea
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/callout.cpp b/callout.cpp
index eb26d64..3d893bd 100644
--- a/callout.cpp
+++ b/callout.cpp
@@ -99,31 +99,34 @@
auto it = properties.find("BuildDate");
if (it != properties.end())
{
- buildDate(it->second.get<std::string>());
+ buildDate(sdbusplus::message::variant_ns::get<std::string>(it->second));
}
it = properties.find("Manufacturer");
if (it != properties.end())
{
- manufacturer(it->second.get<std::string>());
+ manufacturer(
+ sdbusplus::message::variant_ns::get<std::string>(it->second));
}
it = properties.find("Model");
if (it != properties.end())
{
- model(it->second.get<std::string>());
+ model(sdbusplus::message::variant_ns::get<std::string>(it->second));
}
it = properties.find("PartNumber");
if (it != properties.end())
{
- partNumber(it->second.get<std::string>());
+ partNumber(
+ sdbusplus::message::variant_ns::get<std::string>(it->second));
}
it = properties.find("SerialNumber");
if (it != properties.end())
{
- serialNumber(it->second.get<std::string>());
+ serialNumber(
+ sdbusplus::message::variant_ns::get<std::string>(it->second));
}
emit_object_added();
diff --git a/manager.cpp b/manager.cpp
index 5e05342..2342743 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -194,7 +194,9 @@
const auto& properties = associations->second;
auto assocProperty = properties.find("associations");
- auto assocValue = assocProperty->second.get<AssociationsPropertyType>();
+ auto assocValue =
+ sdbusplus::message::variant_ns::get<AssociationsPropertyType>(
+ assocProperty->second);
auto id = getEntryID(objectPath);
auto calloutNum = 0;
@@ -317,7 +319,8 @@
auto property = interface->second.find("Timestamp");
if (property != interface->second.end())
{
- return property->second.get<uint64_t>();
+ return sdbusplus::message::variant_ns::get<uint64_t>(
+ property->second);
}
}
diff --git a/policy_find.cpp b/policy_find.cpp
index 5771100..51576eb 100644
--- a/policy_find.cpp
+++ b/policy_find.cpp
@@ -44,7 +44,7 @@
if (prop != properties.end())
{
- return prop->second.template get<T>();
+ return sdbusplus::message::variant_ns::get<T>(prop->second);
}
return {};
diff --git a/test/test_callout.cpp b/test/test_callout.cpp
index 3ac2c3e..d5fec71 100644
--- a/test/test_callout.cpp
+++ b/test/test_callout.cpp
@@ -74,14 +74,20 @@
ASSERT_EQ(callout->ts(), ts);
ASSERT_EQ(callout->path(), calloutPath);
ASSERT_EQ(callout->buildDate(),
- assetProps["BuildDate"].get<std::string>());
+ sdbusplus::message::variant_ns::get<std::string>(
+ assetProps["BuildDate"]));
ASSERT_EQ(callout->manufacturer(),
- assetProps["Manufacturer"].get<std::string>());
- ASSERT_EQ(callout->model(), assetProps["Model"].get<std::string>());
+ sdbusplus::message::variant_ns::get<std::string>(
+ assetProps["Manufacturer"]));
+ ASSERT_EQ(callout->model(),
+ sdbusplus::message::variant_ns::get<std::string>(
+ assetProps["Model"]));
ASSERT_EQ(callout->partNumber(),
- assetProps["PartNumber"].get<std::string>());
+ sdbusplus::message::variant_ns::get<std::string>(
+ assetProps["PartNumber"]));
ASSERT_EQ(callout->serialNumber(),
- assetProps["SerialNumber"].get<std::string>());
+ sdbusplus::message::variant_ns::get<std::string>(
+ assetProps["SerialNumber"]));
}
// Test a serialization failure due to a bad timestamp