From 91c1ba87ccb78172edfb741fe054472023fa0a28 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 17 Jul 2019 09:48:13 +0100 Subject: [PATCH] Change ConfigParser too --- llarp/config/config.cpp | 2 +- llarp/config/ini.cpp | 6 +----- llarp/config/ini.hpp | 2 +- test/config/test_llarp_config_ini.cpp | 12 ++++++------ 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index 4c182922b..bf10ff91d 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -418,7 +418,7 @@ namespace llarp Config::LoadFromStr(string_view str) { ConfigParser parser; - if(!parser.LoadString(str)) + if(!parser.LoadFromStr(str)) { return false; } diff --git a/llarp/config/ini.cpp b/llarp/config/ini.cpp index 886887656..c83c325ac 100644 --- a/llarp/config/ini.cpp +++ b/llarp/config/ini.cpp @@ -6,10 +6,6 @@ #include #include -#ifdef LoadString -#undef LoadString -#endif - namespace llarp { bool @@ -32,7 +28,7 @@ namespace llarp } bool - ConfigParser::LoadString(string_view str) + ConfigParser::LoadFromStr(string_view str) { m_Data.resize(str.size()); std::copy(str.begin(), str.end(), m_Data.begin()); diff --git a/llarp/config/ini.hpp b/llarp/config/ini.hpp index 1610dcea6..3fa9ad2b9 100644 --- a/llarp/config/ini.hpp +++ b/llarp/config/ini.hpp @@ -31,7 +31,7 @@ namespace llarp /// return true on success /// return false on error bool - LoadString(string_view str); + LoadFromStr(string_view str); /// iterate all sections and thier values void diff --git a/test/config/test_llarp_config_ini.cpp b/test/config/test_llarp_config_ini.cpp index 64081ff67..0e82aeb24 100644 --- a/test/config/test_llarp_config_ini.cpp +++ b/test/config/test_llarp_config_ini.cpp @@ -15,7 +15,7 @@ struct TestINIParser : public ::testing::Test TEST_F(TestINIParser, TestParseEmpty) { - ASSERT_TRUE(parser.LoadString("")); + ASSERT_TRUE(parser.LoadFromStr("")); } TEST_F(TestINIParser, TestParseOneSection) @@ -26,7 +26,7 @@ TEST_F(TestINIParser, TestParseOneSection) sect = section; return true; }; - ASSERT_TRUE(parser.LoadString("[test]\nkey=val \n")); + ASSERT_TRUE(parser.LoadFromStr("[test]\nkey=val \n")); ASSERT_TRUE(parser.VisitSection("test", assertVisit)); auto itr = sect.find("notfound"); ASSERT_EQ(itr, sect.end()); @@ -41,7 +41,7 @@ TEST_F(TestINIParser, TestParseOneSection) TEST_F(TestINIParser, TestParseSectionDuplicateKeys) { - ASSERT_TRUE(parser.LoadString("[test]\nkey1=val1\nkey1=val2")); + ASSERT_TRUE(parser.LoadFromStr("[test]\nkey1=val1\nkey1=val2")); size_t num = 0; auto visit = [&num](const auto& section) -> bool { num = section.count("key1"); @@ -53,12 +53,12 @@ TEST_F(TestINIParser, TestParseSectionDuplicateKeys) TEST_F(TestINIParser, TestNoKey) { - ASSERT_FALSE(parser.LoadString("[test]\n=1090\n")); + ASSERT_FALSE(parser.LoadFromStr("[test]\n=1090\n")); } TEST_F(TestINIParser, TestParseInvalid) { ASSERT_FALSE( - parser.LoadString("srged5ghe5\nf34wtge5\nw34tgfs4ygsd5yg=4;\n#" - "g4syhgd5\n")); + parser.LoadFromStr("srged5ghe5\nf34wtge5\nw34tgfs4ygsd5yg=4;\n#" + "g4syhgd5\n")); }