Case-insensitive configuration file option parsing

This commit is contained in:
Nik Bougalis
2015-10-09 10:46:17 -07:00
parent 21a7b62c2b
commit f00c09d9fc

View File

@@ -28,6 +28,7 @@
#include <beast/http/URL.h>
#include <beast/module/core/text/LexicalCast.h>
#include <beast/streams/debug_ostream.h>
#include <beast/utility/ci_char_traits.h>
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include <boost/regex.hpp>
@@ -378,15 +379,15 @@ void Config::loadFromString (std::string const& fileContents)
if (getSingleSection (secConfig, SECTION_NODE_SIZE, strTemp, j_))
{
if (strTemp == "tiny")
if (beast::ci_equal(strTemp, "tiny"))
NODE_SIZE = 0;
else if (strTemp == "small")
else if (beast::ci_equal(strTemp, "small"))
NODE_SIZE = 1;
else if (strTemp == "medium")
else if (beast::ci_equal(strTemp, "medium"))
NODE_SIZE = 2;
else if (strTemp == "large")
else if (beast::ci_equal(strTemp, "large"))
NODE_SIZE = 3;
else if (strTemp == "huge")
else if (beast::ci_equal(strTemp, "huge"))
NODE_SIZE = 4;
else
{
@@ -453,11 +454,9 @@ void Config::loadFromString (std::string const& fileContents)
if (getSingleSection (secConfig, SECTION_LEDGER_HISTORY, strTemp, j_))
{
boost::to_lower (strTemp);
if (strTemp == "full")
if (beast::ci_equal(strTemp, "full"))
LEDGER_HISTORY = 1000000000u;
else if (strTemp == "none")
else if (beast::ci_equal(strTemp, "none"))
LEDGER_HISTORY = 0;
else
LEDGER_HISTORY = beast::lexicalCastThrow <std::uint32_t> (strTemp);
@@ -465,11 +464,9 @@ void Config::loadFromString (std::string const& fileContents)
if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp, j_))
{
boost::to_lower (strTemp);
if (strTemp == "none")
if (beast::ci_equal(strTemp, "none"))
FETCH_DEPTH = 0;
else if (strTemp == "full")
else if (beast::ci_equal(strTemp, "full"))
FETCH_DEPTH = 1000000000u;
else
FETCH_DEPTH = beast::lexicalCastThrow <std::uint32_t> (strTemp);