Condense std::variants
Where possible, reduce to a single std::variant type to reduce binary
size.
Change-Id: I73b59765109ce1ccd7339f0e214d1ec3929e1ffc
Signed-off-by: Jason M. Bills <jason.m.bills@intel.com>
diff --git a/include/biosxml.hpp b/include/biosxml.hpp
index 6b170bd..ad092df 100644
--- a/include/biosxml.hpp
+++ b/include/biosxml.hpp
@@ -4,6 +4,7 @@
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
+#include <types.hpp>
#include <map>
#include <sstream>
@@ -18,7 +19,7 @@
* For example
* <option text="TIS" value="0x0"/>
*/
-using OptionType = std::tuple<std::string, std::variant<int64_t, std::string>>;
+using OptionType = std::tuple<std::string, ipmi::DbusVariant>;
/* Can hold one 'options'
* For example
@@ -45,8 +46,7 @@
*/
using BiosBaseTableTypeEntry =
std::tuple<std::string, bool, std::string, std::string, std::string,
- std::variant<int64_t, std::string>,
- std::variant<int64_t, std::string>, OptionTypeVector>;
+ ipmi::DbusVariant, ipmi::DbusVariant, OptionTypeVector>;
/* Can hold one 'biosknobs'
* biosknobs has array of 'knob' */
diff --git a/include/manufacturingcommands.hpp b/include/manufacturingcommands.hpp
index 82039f5..e0ff303 100644
--- a/include/manufacturingcommands.hpp
+++ b/include/manufacturingcommands.hpp
@@ -22,7 +22,6 @@
#include <sdbusplus/bus.hpp>
#include <sdbusplus/message.hpp>
#include <sdbusplus/timer.hpp>
-#include <variantvisitors.hpp>
#include <vector>
diff --git a/include/smbiosmdrv2handler.hpp b/include/smbiosmdrv2handler.hpp
index b83e2d4..9bfb54f 100644
--- a/include/smbiosmdrv2handler.hpp
+++ b/include/smbiosmdrv2handler.hpp
@@ -20,6 +20,7 @@
#include <oemcommands.hpp>
#include <sdbusplus/timer.hpp>
+#include <types.hpp>
static constexpr const char* mdrType2File = "/var/lib/smbios/smbios2";
static constexpr const char* smbiosPath = "/var/lib/smbios";
@@ -273,7 +274,7 @@
bool smbiosTryLock(uint8_t flag, uint8_t index, uint16_t* session,
uint16_t timeout);
int sdplusMdrv2GetProperty(const std::string& name,
- std::variant<uint8_t>& value,
+ ipmi::DbusVariant& value,
const std::string& service);
Mdr2DirStruct smbiosDir{smbiosAgentVersion,
diff --git a/include/types.hpp b/include/types.hpp
index 373835c..fc68b5e 100644
--- a/include/types.hpp
+++ b/include/types.hpp
@@ -30,7 +30,9 @@
using DbusVariant =
std::variant<std::string, bool, uint8_t, uint16_t, int16_t, uint32_t,
- int32_t, uint64_t, int64_t, double, std::vector<Association>>;
+ int32_t, uint64_t, int64_t, double, std::vector<Association>,
+ std::vector<std::string>, std::vector<uint8_t>,
+ std::vector<uint64_t>>;
using GetSubTreeType = std::vector<
std::pair<std::string,
diff --git a/include/variantvisitors.hpp b/include/variantvisitors.hpp
deleted file mode 100644
index b24481c..0000000
--- a/include/variantvisitors.hpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-// Copyright (c) 2017 Intel Corporation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-*/
-
-#pragma once
-#include <sdbusplus/bus.hpp>
-
-#include <cstdint>
-#include <limits>
-namespace ipmi
-{
-
-using DbusVariant = std::variant<std::string, bool, uint8_t, uint16_t, int16_t,
- uint32_t, int32_t, uint64_t, int64_t, double>;
-} // namespace ipmi