config_parser: Cleanups and modern c++ standards
This was exposing many functions and semantics that are unused by the
application. The goal is to simplify the interface and convert to using
types like `string_view` and referenceable lists where possible.
Change-Id: I4cba6326f9a96a943d384165e656f8589f931959
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/util.cpp b/src/util.cpp
index 803d26e..de0bc9d 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -376,27 +376,22 @@
systemd::config::networkFileSuffix;
confPath /= fileName;
- auto rc = config::ReturnCode::SUCCESS;
- config::ValueList values;
config::Parser parser(confPath.string());
-
- std::tie(rc, values) = parser.getValues("Network", "DHCP");
- if (rc != config::ReturnCode::SUCCESS)
+ const auto& values = parser.getValues("Network", "DHCP");
+ if (values.empty())
{
- log<level::DEBUG>("Unable to get the value for Network[DHCP]",
- entry("RC=%d", rc));
+ log<level::NOTICE>("Unable to get the value for Network[DHCP]");
return dhcp;
}
- // There will be only single value for DHCP key.
- if (values[0] == "true")
+ if (values.back() == "true")
{
dhcp = EthernetInterfaceIntf::DHCPConf::both;
}
- else if (values[0] == "ipv4")
+ else if (values.back() == "ipv4")
{
dhcp = EthernetInterfaceIntf::DHCPConf::v4;
}
- else if (values[0] == "ipv6")
+ else if (values.back() == "ipv6")
{
dhcp = EthernetInterfaceIntf::DHCPConf::v6;
}