Remove custom version of getPtr

Now that sdbusplus variant supports std::get_if, we can remove our
custom, mapbox namespaced implementation that does the same thing.

Change-Id: I854c473003e28e41dd45dba08ca683433f1c1774
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/include/dbus_singleton.hpp b/include/dbus_singleton.hpp
index 9fe966f..63c88b7 100644
--- a/include/dbus_singleton.hpp
+++ b/include/dbus_singleton.hpp
@@ -1,18 +1,5 @@
 #pragma once
-#include <iostream>
 #include <sdbusplus/asio/connection.hpp>
-#include <sdbusplus/message/types.hpp>
-#include <type_traits>
-
-namespace mapbox
-{
-template <typename T, typename... Types>
-const T* getPtr(const sdbusplus::message::variant<Types...>& v)
-{
-    namespace variant_ns = sdbusplus::message::variant_ns;
-    return variant_ns::get_if<std::remove_const_t<T>, Types...>(&v);
-}
-} // namespace mapbox
 
 namespace crow
 {
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index aba69c1..a93407a 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -317,8 +317,8 @@
                                     if (property.first == "UserEnabled")
                                     {
                                         const bool* userEnabled =
-                                            mapbox::getPtr<const bool>(
-                                                property.second);
+                                            sdbusplus::message::variant_ns::
+                                                get_if<bool>(&property.second);
                                         if (userEnabled == nullptr)
                                         {
                                             BMCWEB_LOG_ERROR
@@ -332,8 +332,8 @@
                                              "UserLockedForFailedAttempt")
                                     {
                                         const bool* userLocked =
-                                            mapbox::getPtr<const bool>(
-                                                property.second);
+                                            sdbusplus::message::variant_ns::
+                                                get_if<bool>(&property.second);
                                         if (userLocked == nullptr)
                                         {
                                             BMCWEB_LOG_ERROR
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 0f2b92b..0e1cf1b 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -198,8 +198,8 @@
                                      &property : propertiesList)
                             {
                                 const std::string *value =
-                                    mapbox::getPtr<const std::string>(
-                                        property.second);
+                                    sdbusplus::message::variant_ns::get_if<
+                                        std::string>(&property.second);
                                 if (value != nullptr)
                                 {
                                     asyncResp->res.jsonValue[property.first] =
diff --git a/redfish-core/lib/cpudimm.hpp b/redfish-core/lib/cpudimm.hpp
index 6001d63..ef73150 100644
--- a/redfish-core/lib/cpudimm.hpp
+++ b/redfish-core/lib/cpudimm.hpp
@@ -93,7 +93,8 @@
                 return;
             }
             const uint16_t *coresCount =
-                mapbox::getPtr<const uint16_t>(coresCountProperty->second);
+                sdbusplus::message::variant_ns::get_if<uint16_t>(
+                    &coresCountProperty->second);
             if (coresCount == nullptr)
             {
                 // Important property not in desired type
@@ -123,7 +124,8 @@
                 {
                     aResp->res.jsonValue["Manufacturer"] = property.second;
                     const std::string *value =
-                        mapbox::getPtr<const std::string>(property.second);
+                        sdbusplus::message::variant_ns::get_if<std::string>(
+                            &property.second);
                     if (value != nullptr)
                     {
                         // Otherwise would be unexpected.
@@ -224,7 +226,8 @@
                 return;
             }
             const uint32_t *memorySize =
-                mapbox::getPtr<const uint32_t>(memorySizeProperty->second);
+                sdbusplus::message::variant_ns::get_if<uint32_t>(
+                    &memorySizeProperty->second);
             if (memorySize == nullptr)
             {
                 // Important property not in desired type
@@ -253,7 +256,8 @@
                 else if (property.first == "MemoryType")
                 {
                     const auto *value =
-                        mapbox::getPtr<const std::string>(property.second);
+                        sdbusplus::message::variant_ns::get_if<std::string>(
+                            &property.second);
                     if (value != nullptr)
                     {
                         aResp->res.jsonValue["MemoryDeviceType"] = *value;
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 8712710..58896d8 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -171,8 +171,8 @@
                         if (propertyPair.first == "MACAddress")
                         {
                             const std::string *mac =
-                                mapbox::getPtr<const std::string>(
-                                    propertyPair.second);
+                                sdbusplus::message::variant_ns::get_if<
+                                    std::string>(&propertyPair.second);
                             if (mac != nullptr)
                             {
                                 ethData.mac_address = *mac;
@@ -186,8 +186,9 @@
                     {
                         if (propertyPair.first == "Id")
                         {
-                            const uint32_t *id = mapbox::getPtr<const uint32_t>(
-                                propertyPair.second);
+                            const uint32_t *id =
+                                sdbusplus::message::variant_ns::get_if<
+                                    uint32_t>(&propertyPair.second);
                             if (id != nullptr)
                             {
                                 ethData.vlan_id = *id;
@@ -203,7 +204,8 @@
                         if (propertyPair.first == "AutoNeg")
                         {
                             const bool *auto_neg =
-                                mapbox::getPtr<const bool>(propertyPair.second);
+                                sdbusplus::message::variant_ns::get_if<bool>(
+                                    &propertyPair.second);
                             if (auto_neg != nullptr)
                             {
                                 ethData.auto_neg = *auto_neg;
@@ -212,8 +214,8 @@
                         else if (propertyPair.first == "Speed")
                         {
                             const uint32_t *speed =
-                                mapbox::getPtr<const uint32_t>(
-                                    propertyPair.second);
+                                sdbusplus::message::variant_ns::get_if<
+                                    uint32_t>(&propertyPair.second);
                             if (speed != nullptr)
                             {
                                 ethData.speed = *speed;
@@ -229,8 +231,8 @@
                         if (propertyPair.first == "HostName")
                         {
                             const std::string *hostname =
-                                mapbox::getPtr<const std::string>(
-                                    propertyPair.second);
+                                sdbusplus::message::variant_ns::get_if<
+                                    std::string>(&propertyPair.second);
                             if (hostname != nullptr)
                             {
                                 ethData.hostname = *hostname;
@@ -239,8 +241,8 @@
                         else if (propertyPair.first == "DefaultGateway")
                         {
                             const std::string *defaultGateway =
-                                mapbox::getPtr<const std::string>(
-                                    propertyPair.second);
+                                sdbusplus::message::variant_ns::get_if<
+                                    std::string>(&propertyPair.second);
                             if (defaultGateway != nullptr)
                             {
                                 ethData.default_gateway = *defaultGateway;
@@ -286,8 +288,8 @@
                         if (property.first == "Address")
                         {
                             const std::string *address =
-                                mapbox::getPtr<const std::string>(
-                                    property.second);
+                                sdbusplus::message::variant_ns::get_if<
+                                    std::string>(&property.second);
                             if (address != nullptr)
                             {
                                 ipv4_address.address = *address;
@@ -296,8 +298,8 @@
                         else if (property.first == "Gateway")
                         {
                             const std::string *gateway =
-                                mapbox::getPtr<const std::string>(
-                                    property.second);
+                                sdbusplus::message::variant_ns::get_if<
+                                    std::string>(&property.second);
                             if (gateway != nullptr)
                             {
                                 ipv4_address.gateway = *gateway;
@@ -306,8 +308,8 @@
                         else if (property.first == "Origin")
                         {
                             const std::string *origin =
-                                mapbox::getPtr<const std::string>(
-                                    property.second);
+                                sdbusplus::message::variant_ns::get_if<
+                                    std::string>(&property.second);
                             if (origin != nullptr)
                             {
                                 ipv4_address.origin =
@@ -318,7 +320,8 @@
                         else if (property.first == "PrefixLength")
                         {
                             const uint8_t *mask =
-                                mapbox::getPtr<uint8_t>(property.second);
+                                sdbusplus::message::variant_ns::get_if<uint8_t>(
+                                    &property.second);
                             if (mask != nullptr)
                             {
                                 // convert it to the string
@@ -1739,7 +1742,6 @@
             messages::internalError(asyncResp->res);
             return;
         }
-
         nlohmann::json postReq;
         if (!json_util::processJsonFromRequest(res, req, postReq))
         {
@@ -1747,6 +1749,7 @@
         }
 
         auto vlanIdJson = postReq.find("VLANId");
+
         if (vlanIdJson == postReq.end())
         {
             messages::propertyMissing(asyncResp->res, "VLANId");
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index cf4af02..6f87307 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1102,7 +1102,7 @@
                     return;
                 }
                 const std::string *log =
-                    mapbox::getPtr<const std::string>(resp);
+                    sdbusplus::message::variant_ns::get_if<std::string>(&resp);
                 if (log == nullptr)
                 {
                     messages::internalError(asyncResp->res);
@@ -1204,8 +1204,9 @@
                     std::string, sdbusplus::message::variant<std::string>>>
                 interfacesAdded;
             m.read(objPath, interfacesAdded);
-            const std::string *log = mapbox::getPtr<const std::string>(
-                interfacesAdded[cpuLogInterface]["Log"]);
+            const std::string *log =
+                sdbusplus::message::variant_ns::get_if<std::string>(
+                    &interfacesAdded[cpuLogInterface]["Log"]);
             if (log == nullptr)
             {
                 messages::internalError(asyncResp->res);
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 44725b1..f3c3ec3 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -174,7 +174,8 @@
                         return;
                     }
                     const std::string* namePtr =
-                        mapbox::getPtr<const std::string>(findName->second);
+                        sdbusplus::message::variant_ns::get_if<std::string>(
+                            &findName->second);
                     if (namePtr == nullptr)
                     {
                         BMCWEB_LOG_ERROR << "Pid Name Field illegal";
@@ -214,8 +215,9 @@
                         // zones
                         if (intfPair.first == pidZoneConfigurationIface)
                         {
-                            const double* ptr = mapbox::getPtr<const double>(
-                                propertyPair.second);
+                            const double* ptr =
+                                sdbusplus::message::variant_ns::get_if<double>(
+                                    &propertyPair.second);
                             if (ptr == nullptr)
                             {
                                 BMCWEB_LOG_ERROR << "Field Illegal "
@@ -233,8 +235,9 @@
                             auto findClass = intfPair.second.find("Class");
                             if (findClass != intfPair.second.end())
                             {
-                                classPtr = mapbox::getPtr<const std::string>(
-                                    findClass->second);
+                                classPtr =
+                                    sdbusplus::message::variant_ns::get_if<
+                                        std::string>(&findClass->second);
                             }
                             if (classPtr == nullptr)
                             {
@@ -274,9 +277,9 @@
                             if (propertyPair.first == "Zones")
                             {
                                 const std::vector<std::string>* inputs =
-                                    mapbox::getPtr<
-                                        const std::vector<std::string>>(
-                                        propertyPair.second);
+                                    sdbusplus::message::variant_ns::get_if<
+                                        std::vector<std::string>>(
+                                        &propertyPair.second);
 
                                 if (inputs == nullptr)
                                 {
@@ -309,9 +312,9 @@
                             {
                                 auto& data = element[propertyPair.first];
                                 const std::vector<std::string>* inputs =
-                                    mapbox::getPtr<
-                                        const std::vector<std::string>>(
-                                        propertyPair.second);
+                                    sdbusplus::message::variant_ns::get_if<
+                                        std::vector<std::string>>(
+                                        &propertyPair.second);
 
                                 if (inputs == nullptr)
                                 {
@@ -335,8 +338,8 @@
                                      propertyPair.first == "SlewPos")
                             {
                                 const double* ptr =
-                                    mapbox::getPtr<const double>(
-                                        propertyPair.second);
+                                    sdbusplus::message::variant_ns::get_if<
+                                        double>(&propertyPair.second);
                                 if (ptr == nullptr)
                                 {
                                     BMCWEB_LOG_ERROR << "Field Illegal "
@@ -752,8 +755,8 @@
                                 if (property.first == "Version")
                                 {
                                     const std::string* value =
-                                        mapbox::getPtr<const std::string>(
-                                            property.second);
+                                        sdbusplus::message::variant_ns::get_if<
+                                            std::string>(&property.second);
                                     if (value == nullptr)
                                     {
                                         continue;
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index 47244e0..90f12dd 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -166,9 +166,10 @@
                                 }
                                 const std::vector<std::tuple<
                                     std::string, std::string>>* responsePtr =
-                                    mapbox::getPtr<const std::vector<
-                                        std::tuple<std::string, std::string>>>(
-                                        resp);
+                                    sdbusplus::message::variant_ns::get_if<
+                                        std::vector<std::tuple<std::string,
+                                                               std::string>>>(
+                                        &resp);
                                 if (responsePtr == nullptr ||
                                     responsePtr->size() < 1)
                                 {
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index b689f09..f866e5d 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -273,7 +273,7 @@
     if (scaleIt != valueIt->second.end())
     {
         const int64_t* int64Value =
-            mapbox::getPtr<const int64_t>(scaleIt->second);
+            sdbusplus::message::variant_ns::get_if<int64_t>(&scaleIt->second);
         if (int64Value != nullptr)
         {
             scaleMultiplier = *int64Value;
@@ -370,10 +370,12 @@
                 nlohmann::json& valueIt = sensor_json[std::get<2>(p)];
                 // Attempt to pull the int64 directly
                 const int64_t* int64Value =
-                    mapbox::getPtr<const int64_t>(valueVariant);
+                    sdbusplus::message::variant_ns::get_if<int64_t>(
+                        &valueVariant);
 
                 const double* doubleValue =
-                    mapbox::getPtr<const double>(valueVariant);
+                    sdbusplus::message::variant_ns::get_if<double>(
+                        &valueVariant);
                 double temp = 0.0;
                 if (int64Value != nullptr)
                 {
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 7d0cc02..12f15d1 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -87,8 +87,8 @@
                                      &property : propertiesList)
                             {
                                 const std::string *value =
-                                    mapbox::getPtr<const std::string>(
-                                        property.second);
+                                    sdbusplus::message::variant_ns::get_if<
+                                        std::string>(&property.second);
                                 if (value != nullptr)
                                 {
                                     aResp->res.jsonValue[property.first] =
@@ -140,9 +140,10 @@
                                                 "MemorySizeInKb")
                                             {
                                                 const uint64_t *value =
-                                                    mapbox::getPtr<
-                                                        const uint64_t>(
-                                                        property.second);
+                                                    sdbusplus::message::
+                                                        variant_ns::get_if<
+                                                            uint64_t>(
+                                                            &property.second);
                                                 if (value != nullptr)
                                                 {
                                                     aResp->res.jsonValue
@@ -188,9 +189,10 @@
                                                 "ProcessorFamily")
                                             {
                                                 const std::string *value =
-                                                    mapbox::getPtr<
-                                                        const std::string>(
-                                                        property.second);
+                                                    sdbusplus::message::
+                                                        variant_ns::get_if<
+                                                            std::string>(
+                                                            &property.second);
                                                 if (value != nullptr)
                                                 {
                                                     nlohmann::json
@@ -245,9 +247,10 @@
                                             if (property.first == "BIOSVer")
                                             {
                                                 const std::string *value =
-                                                    mapbox::getPtr<
-                                                        const std::string>(
-                                                        property.second);
+                                                    sdbusplus::message::
+                                                        variant_ns::get_if<
+                                                            std::string>(
+                                                            &property.second);
                                                 if (value != nullptr)
                                                 {
                                                     aResp->res.jsonValue
@@ -258,9 +261,10 @@
                                             if (property.first == "UUID")
                                             {
                                                 const std::string *value =
-                                                    mapbox::getPtr<
-                                                        const std::string>(
-                                                        property.second);
+                                                    sdbusplus::message::
+                                                        variant_ns::get_if<
+                                                            std::string>(
+                                                            &property.second);
 
                                                 if (value != nullptr)
                                                 {
@@ -351,8 +355,8 @@
                                 if (property.first == "Asserted")
                                 {
                                     const bool *asserted =
-                                        mapbox::getPtr<const bool>(
-                                            property.second);
+                                        sdbusplus::message::variant_ns::get_if<
+                                            bool>(&property.second);
                                     if (nullptr != asserted)
                                     {
                                         callback(*asserted, aResp);
@@ -395,7 +399,8 @@
                 if (property.first == "State")
                 {
                     const std::string *s =
-                        mapbox::getPtr<std::string>(property.second);
+                        sdbusplus::message::variant_ns::get_if<std::string>(
+                            &property.second);
                     if (nullptr != s)
                     {
                         BMCWEB_LOG_DEBUG << "Identify Led State: " << *s;
@@ -449,7 +454,8 @@
                 return;
             }
 
-            const std::string *s = mapbox::getPtr<const std::string>(hostState);
+            const std::string *s =
+                sdbusplus::message::variant_ns::get_if<std::string>(&hostState);
             BMCWEB_LOG_DEBUG << "Host state: " << *s;
             if (s != nullptr)
             {
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index f600c14..d5ecf24 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -260,8 +260,8 @@
                                 }
 
                                 const std::string *swActivationStatus =
-                                    mapbox::getPtr<const std::string>(
-                                        activation);
+                                    sdbusplus::message::variant_ns::get_if<
+                                        std::string>(&activation);
                                 if (swActivationStatus == nullptr)
                                 {
                                     messages::internalError(asyncResp->res);
@@ -401,7 +401,8 @@
                                 return;
                             }
                             const std::string *swInvPurpose =
-                                mapbox::getPtr<const std::string>(it->second);
+                                sdbusplus::message::variant_ns::get_if<
+                                    std::string>(&it->second);
                             if (swInvPurpose == nullptr)
                             {
                                 BMCWEB_LOG_DEBUG
@@ -426,7 +427,8 @@
                             BMCWEB_LOG_DEBUG << "Version found!";
 
                             const std::string *version =
-                                mapbox::getPtr<const std::string>(it->second);
+                                sdbusplus::message::variant_ns::get_if<
+                                    std::string>(&it->second);
 
                             if (version == nullptr)
                             {