Remove dead code

pull/1186/head
Stephen Shelton 4 years ago
parent d82f5e6b93
commit 9f0ae43149
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C

@ -73,26 +73,6 @@ namespace llarp
return val;
}
int
svtoi(string_view val)
{
return std::atoi(val.data());
}
nonstd::optional<bool>
setOptBool(string_view val)
{
if (IsTrueValue(val))
{
return true;
}
else if (IsFalseValue(val))
{
return false;
}
return {};
}
void
RouterConfig::defineConfigOptions(Configuration& conf)
{

@ -15,24 +15,6 @@
#include <vector>
#include <unordered_set>
/*
* section names
* XXX: remove me
*
router = find_section< RouterConfig >(parser, "router");
network = find_section< NetworkConfig >(parser, "network");
connect = find_section< ConnectConfig >(parser, "connect");
netdb = find_section< NetdbConfig >(parser, "netdb");
dns = find_section< DnsConfig >(parser, "dns");
links = find_section< LinksConfig >(parser, "bind");
services = find_section< ServicesConfig >(parser, "services");
system = find_section< SystemConfig >(parser, "system");
api = find_section< ApiConfig >(parser, "api");
lokid = find_section< LokidConfig >(parser, "lokid");
bootstrap = find_section< BootstrapConfig >(parser, "bootstrap");
logging = find_section< LoggingConfig >(parser, "logging");
*/
namespace llarp
{
using SectionValues_t = llarp::ConfigParser::SectionValues_t;

@ -152,40 +152,6 @@ namespace llarp
visit(item.first, item.second);
}
const std::string emptyStr = "";
const std::string&
ConfigParser::getSingleSectionValue(
const SectionValues_t& values,
const std::string& section,
const std::string& key,
bool required,
bool tolerateMultiples) const
{
// section is provided for clarity / sanity check
assert(m_Config.find(section) != m_Config.end());
assert( & m_Config.find(section)->second == &values);
const auto sectionItr = m_Config.find(section);
if (sectionItr == m_Config.end())
throw std::invalid_argument(stringify("could not find section ", section));
const SectionValues_t& sectionValues = sectionItr->second;
if (not tolerateMultiples and sectionValues.count(key) > 1)
throw std::invalid_argument(stringify("config [", section, "]:", key, " cannot have multiple values for ", key));
const auto itr = sectionValues.find(key);
if (itr == sectionValues.end()) {
if (required)
throw std::invalid_argument(stringify("config [", section, "]:", key, " is missing"));
else
return emptyStr;
}
return itr->second;
}
bool
ConfigParser::VisitSection(
const char* name,

@ -40,28 +40,6 @@ namespace llarp
VisitSection(const char* name,
std::function< bool(const SectionValues_t&) > visit) const;
/// Obtain a section value for the given key, additionally imposing the
/// provided constraints. an `invalid_argument` will be thrown if the
/// constraints aren't met.
///
/// The `section` parameter is redundant and added for readability, but a call to
/// m_Config[section] should result in the same object as `values`.
///
/// @param values is the SectionValues map in which to search for values
/// @param section should correspond to INI section tag related to this config
/// @param key is the key to look up
/// @param bool constrains whether this key must exist
/// @param tolerateMultiples constrains whether multiples are allowed
/// @return the first matching entry if found or empty string if not found
/// @throws std::invalid_argument if constrants aren't met or if `section` is not found
const std::string&
getSingleSectionValue(
const SectionValues_t& values,
const std::string& section,
const std::string& key,
bool required,
bool tolerateMultiples = false) const;
private:
bool
Parse();

Loading…
Cancel
Save