Move variant usage to std

Since sdbusplus now uses std, it's cleaner just to
use the variant type directly not behind the namespace.

This was primarily done with sed commands

Tested-by: It builds

Change-Id: I87a90a2942cfc6da312cb0e045cce7cd40a644e5
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/Utils.hpp b/include/Utils.hpp
index 7c58e2a..a1c9d37 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -14,9 +14,8 @@
 const std::regex illegalDbusRegex("[^A-Za-z0-9_]");
 
 using BasicVariantType =
-    sdbusplus::message::variant<std::vector<std::string>, std::string, int64_t,
-                                uint64_t, double, int32_t, uint32_t, int16_t,
-                                uint16_t, uint8_t, bool>;
+    std::variant<std::vector<std::string>, std::string, int64_t, uint64_t,
+                 double, int32_t, uint32_t, int16_t, uint16_t, uint8_t, bool>;
 
 using ManagedObjectType = boost::container::flat_map<
     sdbusplus::message::object_path,
@@ -66,18 +65,15 @@
     }
     if constexpr (std::is_same_v<T, double>)
     {
-        return sdbusplus::message::variant_ns::visit(VariantToDoubleVisitor(),
-                                                     it->second);
+        return std::visit(VariantToDoubleVisitor(), it->second);
     }
     else if constexpr (std::is_unsigned_v<T>)
     {
-        return sdbusplus::message::variant_ns::visit(
-            VariantToUnsignedIntVisitor(), it->second);
+        return std::visit(VariantToUnsignedIntVisitor(), it->second);
     }
     else if constexpr (std::is_same_v<T, std::string>)
     {
-        return sdbusplus::message::variant_ns::visit(VariantToStringVisitor(),
-                                                     it->second);
+        return std::visit(VariantToStringVisitor(), it->second);
     }
     else
     {
diff --git a/include/VariantVisitors.hpp b/include/VariantVisitors.hpp
index 7a8677f..7b23977 100644
--- a/include/VariantVisitors.hpp
+++ b/include/VariantVisitors.hpp
@@ -17,6 +17,7 @@
 #pragma once
 #include <stdexcept>
 #include <string>
+#include <variant>
 
 struct VariantToFloatVisitor
 {
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index 7f7f812..98b41a0 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -30,7 +30,7 @@
 static constexpr bool DEBUG = false;
 
 namespace fs = std::filesystem;
-namespace variant_ns = sdbusplus::message::variant_ns;
+
 static constexpr std::array<const char*, 1> sensorTypes = {
     "xyz.openbmc_project.Configuration.ADC"};
 static std::regex inputRegex(R"(in(\d+)_input)");
@@ -133,8 +133,8 @@
                 continue;
             }
 
-            unsigned int number = sdbusplus::message::variant_ns::visit(
-                VariantToUnsignedIntVisitor(), findIndex->second);
+            unsigned int number =
+                std::visit(VariantToUnsignedIntVisitor(), findIndex->second);
 
             if (number != index)
             {
@@ -165,9 +165,7 @@
                       << path.string() << "\n";
             continue;
         }
-        std::string sensorName =
-            sdbusplus::message::variant_ns::get<std::string>(
-                findSensorName->second);
+        std::string sensorName = std::get<std::string>(findSensorName->second);
 
         // on rescans, only update sensors we were signaled by
         auto findSensor = sensors.find(sensorName);
@@ -201,16 +199,16 @@
         float scaleFactor = 1.0;
         if (findScaleFactor != baseConfiguration->second.end())
         {
-            scaleFactor = variant_ns::visit(VariantToFloatVisitor(),
-                                            findScaleFactor->second);
+            scaleFactor =
+                std::visit(VariantToFloatVisitor(), findScaleFactor->second);
         }
 
         auto findPowerOn = baseConfiguration->second.find("PowerState");
         PowerState readState = PowerState::always;
         if (findPowerOn != baseConfiguration->second.end())
         {
-            std::string powerState = variant_ns::visit(VariantToStringVisitor(),
-                                                       findPowerOn->second);
+            std::string powerState =
+                std::visit(VariantToStringVisitor(), findPowerOn->second);
             setReadState(powerState, readState);
         }
 
diff --git a/src/CPUSensorMain.cpp b/src/CPUSensorMain.cpp
index e2d4730..3af20a0 100644
--- a/src/CPUSensorMain.cpp
+++ b/src/CPUSensorMain.cpp
@@ -68,7 +68,7 @@
 static constexpr const unsigned int rankNumMax = 8;
 
 namespace fs = std::filesystem;
-namespace variant_ns = sdbusplus::message::variant_ns;
+
 static constexpr const char* configPrefix =
     "xyz.openbmc_project.Configuration.";
 static constexpr std::array<const char*, 3> sensorTypes = {
@@ -216,10 +216,8 @@
                 continue;
             }
 
-            if (sdbusplus::message::variant_ns::get<uint64_t>(
-                    configurationBus->second) != bus ||
-                sdbusplus::message::variant_ns::get<uint64_t>(
-                    configurationAddress->second) != addr)
+            if (std::get<uint64_t>(configurationBus->second) != bus ||
+                std::get<uint64_t>(configurationAddress->second) != addr)
             {
                 continue;
             }
@@ -240,7 +238,7 @@
             continue;
         }
         int cpuId =
-            variant_ns::visit(VariantToUnsignedIntVisitor(), findCpuId->second);
+            std::visit(VariantToUnsignedIntVisitor(), findCpuId->second);
 
         auto directory = hwmonNamePath.parent_path();
         std::vector<fs::path> inputPaths;
@@ -549,8 +547,8 @@
                 {
                     continue;
                 }
-                std::string nameRaw = variant_ns::visit(
-                    VariantToStringVisitor(), findName->second);
+                std::string nameRaw =
+                    std::visit(VariantToStringVisitor(), findName->second);
                 std::string name =
                     std::regex_replace(nameRaw, illegalDbusRegex, "_");
 
@@ -560,8 +558,8 @@
                     std::cerr << "Can't find 'Bus' setting in " << name << "\n";
                     continue;
                 }
-                uint64_t bus = variant_ns::visit(VariantToUnsignedIntVisitor(),
-                                                 findBus->second);
+                uint64_t bus =
+                    std::visit(VariantToUnsignedIntVisitor(), findBus->second);
 
                 auto findAddress = config.second.find("Address");
                 if (findAddress == config.second.end())
@@ -570,8 +568,8 @@
                               << "\n";
                     continue;
                 }
-                uint64_t addr = variant_ns::visit(VariantToUnsignedIntVisitor(),
-                                                  findAddress->second);
+                uint64_t addr = std::visit(VariantToUnsignedIntVisitor(),
+                                           findAddress->second);
 
                 if (DEBUG)
                 {
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index a8a5748..06eddc0 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -53,8 +53,8 @@
     std::function<void(sdbusplus::message::message & message)> eventHandler =
         [callback{std::move(callback)}](sdbusplus::message::message& message) {
             std::string objectName;
-            boost::container::flat_map<
-                std::string, sdbusplus::message::variant<double, int64_t>>
+            boost::container::flat_map<std::string,
+                                       std::variant<double, int64_t>>
                 values;
             message.read(objectName, values);
             auto findValue = values.find("Value");
@@ -62,8 +62,8 @@
             {
                 return;
             }
-            double value = sdbusplus::message::variant_ns::visit(
-                VariantToDoubleVisitor(), findValue->second);
+            double value =
+                std::visit(VariantToDoubleVisitor(), findValue->second);
             if (std::isnan(value))
             {
                 return;
@@ -328,8 +328,7 @@
                 return;
             }
 
-            inletTemp = sdbusplus::message::variant_ns::visit(
-                VariantToDoubleVisitor(), value);
+            inletTemp = std::visit(VariantToDoubleVisitor(), value);
         },
         "xyz.openbmc_project.HwmonTempSensor",
         std::string("/xyz/openbmc_project/sensors/") + inletTemperatureSensor,
@@ -517,8 +516,7 @@
         throw std::invalid_argument("Key Missing");
     }
     BasicVariantType copy = it->second;
-    std::vector<std::string> config =
-        sdbusplus::message::variant_ns::get<std::vector<std::string>>(copy);
+    std::vector<std::string> config = std::get<std::vector<std::string>>(copy);
     for (auto& str : config)
     {
         boost::replace_all(str, " ", "_");
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index fd5e7af..48ed692 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -32,7 +32,7 @@
 static constexpr bool DEBUG = false;
 
 namespace fs = std::filesystem;
-namespace variant_ns = sdbusplus::message::variant_ns;
+
 static constexpr std::array<const char*, 2> sensorTypes = {
     "xyz.openbmc_project.Configuration.AspeedFan",
     "xyz.openbmc_project.Configuration.I2CFan"};
@@ -151,8 +151,8 @@
                 std::cerr << baseConfiguration->first << " missing index\n";
                 continue;
             }
-            unsigned int configIndex = variant_ns::visit(
-                VariantToUnsignedIntVisitor(), findIndex->second);
+            unsigned int configIndex =
+                std::visit(VariantToUnsignedIntVisitor(), findIndex->second);
             if (configIndex != index)
             {
                 continue;
@@ -175,9 +175,9 @@
                               << " missing bus or address\n";
                     continue;
                 }
-                unsigned int configBus = variant_ns::visit(
-                    VariantToUnsignedIntVisitor(), findBus->second);
-                unsigned int configAddress = variant_ns::visit(
+                unsigned int configBus =
+                    std::visit(VariantToUnsignedIntVisitor(), findBus->second);
+                unsigned int configAddress = std::visit(
                     VariantToUnsignedIntVisitor(), findAddress->second);
 
                 if (configBus == bus && configAddress == configAddress)
@@ -200,9 +200,7 @@
                       << path.string() << "\n";
             continue;
         }
-        std::string sensorName =
-            sdbusplus::message::variant_ns::get<std::string>(
-                findSensorName->second);
+        std::string sensorName = std::get<std::string>(findSensorName->second);
         // on rescans, only update sensors we were signaled by
         auto findSensor = tachSensors.find(sensorName);
         if (!firstScan && findSensor != tachSensors.end())
@@ -249,9 +247,9 @@
             }
             else
             {
-                size_t index = variant_ns::get<uint64_t>(findIndex->second);
+                size_t index = std::get<uint64_t>(findIndex->second);
                 bool inverted =
-                    variant_ns::get<std::string>(findPolarity->second) == "Low";
+                    std::get<std::string>(findPolarity->second) == "Low";
                 presenceSensor =
                     std::make_unique<PresenceSensor>(index, inverted, io);
             }
@@ -329,8 +327,8 @@
                                 sensor.second->name);
                         }
                         systemRedundancy = std::make_unique<RedundancySensor>(
-                            variant_ns::get<uint64_t>(findCount->second),
-                            sensorList, objectServer);
+                            std::get<uint64_t>(findCount->second), sensorList,
+                            objectServer);
 
                         return;
                     }
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index 0a19636..430793a 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -138,10 +138,8 @@
                 continue;
             }
 
-            if (sdbusplus::message::variant_ns::get<uint64_t>(
-                    configurationBus->second) != bus ||
-                sdbusplus::message::variant_ns::get<uint64_t>(
-                    configurationAddress->second) != addr)
+            if (std::get<uint64_t>(configurationBus->second) != bus ||
+                std::get<uint64_t>(configurationAddress->second) != addr)
             {
                 continue;
             }
@@ -162,9 +160,7 @@
                       << deviceName << "\n";
             continue;
         }
-        std::string sensorName =
-            sdbusplus::message::variant_ns::get<std::string>(
-                findSensorName->second);
+        std::string sensorName = std::get<std::string>(findSensorName->second);
         // on rescans, only update sensors we were signaled by
         auto findSensor = sensors.find(sensorName);
         if (!firstScan && findSensor != sensors.end())
@@ -203,8 +199,7 @@
             continue;
         }
 
-        sensorName = sdbusplus::message::variant_ns::get<std::string>(
-            findSecondName->second);
+        sensorName = std::get<std::string>(findSecondName->second);
         sensors[sensorName] = std::make_unique<HwmonTempSensor>(
             directory.string() + "/temp2_input", sensorType, objectServer,
             dbusConnection, io, sensorName,
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index 10b1674..1494396 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -10,7 +10,6 @@
 static constexpr bool DEBUG = false;
 static constexpr size_t maxThresholds = 4;
 
-namespace variant_ns = sdbusplus::message::variant_ns;
 namespace thresholds
 {
 unsigned int toBusValue(const Level &level)
@@ -67,8 +66,8 @@
             auto labelFind = item.second.find("Label");
             if (labelFind == item.second.end())
                 continue;
-            if (variant_ns::visit(VariantToStringVisitor(),
-                                  labelFind->second) != *matchLabel)
+            if (std::visit(VariantToStringVisitor(), labelFind->second) !=
+                *matchLabel)
                 continue;
         }
         auto directionFind = item.second.find("Direction");
@@ -83,8 +82,8 @@
         }
         Level level;
         Direction direction;
-        if (variant_ns::visit(VariantToUnsignedIntVisitor(),
-                              severityFind->second) == 0)
+        if (std::visit(VariantToUnsignedIntVisitor(), severityFind->second) ==
+            0)
         {
             level = Level::WARNING;
         }
@@ -92,8 +91,8 @@
         {
             level = Level::CRITICAL;
         }
-        if (variant_ns::visit(VariantToStringVisitor(),
-                              directionFind->second) == "less than")
+        if (std::visit(VariantToStringVisitor(), directionFind->second) ==
+            "less than")
         {
             direction = Direction::LOW;
         }
@@ -101,8 +100,7 @@
         {
             direction = Direction::HIGH;
         }
-        float val =
-            variant_ns::visit(VariantToFloatVisitor(), valueFind->second);
+        float val = std::visit(VariantToFloatVisitor(), valueFind->second);
 
         thresholdVector.emplace_back(level, direction, val);
     }
@@ -136,18 +134,18 @@
                     std::cerr << "Malformed threshold in configuration\n";
                     return;
                 }
-                unsigned int level = variant_ns::visit(
-                    VariantToUnsignedIntVisitor(), severityFind->second);
+                unsigned int level = std::visit(VariantToUnsignedIntVisitor(),
+                                                severityFind->second);
 
-                std::string dir = variant_ns::visit(VariantToStringVisitor(),
-                                                    directionFind->second);
+                std::string dir =
+                    std::visit(VariantToStringVisitor(), directionFind->second);
                 if ((toBusValue(threshold.level) != level) ||
                     (toBusValue(threshold.direction) != dir))
                 {
                     return; // not the droid we're looking for
                 }
 
-                sdbusplus::message::variant<double> value(threshold.value);
+                std::variant<double> value(threshold.value);
                 conn->async_method_call(
                     [](const boost::system::error_code &ec) {
                         if (ec)
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 4e7e029..ff06428 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -135,21 +135,18 @@
     std::function<void(sdbusplus::message::message & message)> eventHandler =
         [](sdbusplus::message::message& message) {
             std::string objectName;
-            boost::container::flat_map<
-                std::string, sdbusplus::message::variant<int32_t, bool>>
+            boost::container::flat_map<std::string, std::variant<int32_t, bool>>
                 values;
             message.read(objectName, values);
             auto findPgood = values.find("pgood");
             if (findPgood != values.end())
             {
-                powerStatusOn = sdbusplus::message::variant_ns::get<int32_t>(
-                    findPgood->second);
+                powerStatusOn = std::get<int32_t>(findPgood->second);
             }
             auto findPostComplete = values.find("post_complete");
             if (findPostComplete != values.end())
             {
-                biosHasPost = sdbusplus::message::variant_ns::get<bool>(
-                    findPostComplete->second);
+                biosHasPost = std::get<bool>(findPostComplete->second);
             }
         };
 
@@ -161,28 +158,26 @@
         eventHandler);
 
     conn->async_method_call(
-        [](boost::system::error_code ec,
-           const sdbusplus::message::variant<int32_t>& pgood) {
+        [](boost::system::error_code ec, const std::variant<int32_t>& pgood) {
             if (ec)
             {
                 std::cerr << "Error getting initial power status\n";
                 return;
             }
-            powerStatusOn = sdbusplus::message::variant_ns::get<int32_t>(pgood);
+            powerStatusOn = std::get<int32_t>(pgood);
         },
         powerInterfaceName, powerObjectName, "org.freedesktop.DBus.Properties",
         "Get", powerInterfaceName, "pgood");
 
     conn->async_method_call(
         [](boost::system::error_code ec,
-           const sdbusplus::message::variant<int32_t>& postComplete) {
+           const std::variant<int32_t>& postComplete) {
             if (ec)
             {
                 std::cerr << "Error getting initial post status\n";
                 return;
             }
-            biosHasPost =
-                sdbusplus::message::variant_ns::get<int32_t>(postComplete);
+            biosHasPost = std::get<int32_t>(postComplete);
         },
         powerInterfaceName, powerObjectName, "org.freedesktop.DBus.Properties",
         "Get", powerInterfaceName, "post_complete");
@@ -201,12 +196,10 @@
 
     if (minFind != data->second.end())
     {
-        limits.first = sdbusplus::message::variant_ns::visit(
-            VariantToDoubleVisitor(), minFind->second);
+        limits.first = std::visit(VariantToDoubleVisitor(), minFind->second);
     }
     if (maxFind != data->second.end())
     {
-        limits.second = sdbusplus::message::variant_ns::visit(
-            VariantToDoubleVisitor(), maxFind->second);
+        limits.second = std::visit(VariantToDoubleVisitor(), maxFind->second);
     }
 }