diff --git a/lib/mtgo_utils/include/mtgo_utils/gamelog.h b/lib/mtgo_utils/include/mtgo_utils/gamelog.h index f434fd8..d5d913e 100644 --- a/lib/mtgo_utils/include/mtgo_utils/gamelog.h +++ b/lib/mtgo_utils/include/mtgo_utils/gamelog.h @@ -6,7 +6,7 @@ #include #include -namespace gl { +namespace mtgo_utils { /** * \brief Take the given input file, parse its content and return the parsed lines. @@ -42,6 +42,6 @@ std::vector ParseGameLogFile(std::string const& file_content); */ bool IsMatchGameLog(std::filesystem::path const& file_path); -} // namespace gl +} // namespace mtgo_utils #endif /* ifndef LIB_MTGO_UTILS_INCLUDE_MTGO_UTILS_GAMELOG_H */ \ No newline at end of file diff --git a/lib/mtgo_utils/src/gamelog.cpp b/lib/mtgo_utils/src/gamelog.cpp index aa806b9..f774903 100644 --- a/lib/mtgo_utils/src/gamelog.cpp +++ b/lib/mtgo_utils/src/gamelog.cpp @@ -9,7 +9,7 @@ #include "mtgo_utils/gamelog.h" -namespace gl { +namespace mtgo_utils { namespace internal { @@ -172,21 +172,21 @@ static std::vector Split(std::string const& content) std::vector ParseGameLogFile(std::filesystem::path const& file_path) { - auto const text = gl::internal::Read(file_path); + auto const text = mtgo_utils::internal::Read(file_path); return ParseGameLogFile(text); } std::vector ParseGameLogFile(std::ifstream&& file_stream) { - auto const text = gl::internal::Read(std::move(file_stream)); + auto const text = mtgo_utils::internal::Read(std::move(file_stream)); return ParseGameLogFile(text); } std::vector ParseGameLogFile(std::string const& file_content) { - return gl::internal::Split(file_content); + return mtgo_utils::internal::Split(file_content); } @@ -196,4 +196,4 @@ bool IsMatchGameLog(std::filesystem::path const& file_path) (file_path.filename().string().find("Match_GameLog_") == 0); } -} // namespace gl +} // namespace mtgo_utils diff --git a/lib/mtgo_utils/tests/test_gamelog.cpp b/lib/mtgo_utils/tests/test_gamelog.cpp index 4ef3eae..04f240d 100644 --- a/lib/mtgo_utils/tests/test_gamelog.cpp +++ b/lib/mtgo_utils/tests/test_gamelog.cpp @@ -20,8 +20,8 @@ TEST_F(GameLogTest, IsMatchGameLog_Valid) // NOLINT std::filesystem::path const valid_01{"Match_GameLog_1234.dat"}; std::filesystem::path const valid_02{"/some/path/Match_GameLog_1234.dat"}; - ASSERT_TRUE(gl::IsMatchGameLog(valid_01)); - ASSERT_TRUE(gl::IsMatchGameLog(valid_02)); + ASSERT_TRUE(mtgo_utils::IsMatchGameLog(valid_01)); + ASSERT_TRUE(mtgo_utils::IsMatchGameLog(valid_02)); } @@ -32,17 +32,17 @@ TEST_F(GameLogTest, IsMatchGameLog_Invalid) // NOLINT std::filesystem::path const invalid_03{"MyGamelog.dat"}; std::filesystem::path const invalid_04{"Match_GameChat_1234.dat"}; - ASSERT_FALSE(gl::IsMatchGameLog(invalid_01)); - ASSERT_FALSE(gl::IsMatchGameLog(invalid_02)); - ASSERT_FALSE(gl::IsMatchGameLog(invalid_03)); - ASSERT_FALSE(gl::IsMatchGameLog(invalid_04)); + ASSERT_FALSE(mtgo_utils::IsMatchGameLog(invalid_01)); + ASSERT_FALSE(mtgo_utils::IsMatchGameLog(invalid_02)); + ASSERT_FALSE(mtgo_utils::IsMatchGameLog(invalid_03)); + ASSERT_FALSE(mtgo_utils::IsMatchGameLog(invalid_04)); } TEST_F(GameLogTest, ParseGameLogFileStr_Empty_01) // NOLINT { std::vector expected{}; - ASSERT_EQ(gl::ParseGameLogFile(std::string{}), expected); + ASSERT_EQ(mtgo_utils::ParseGameLogFile(std::string{}), expected); } @@ -50,7 +50,7 @@ TEST_F(GameLogTest, ParseGameLogFileStr_Empty_02) // NOLINT { std::string content{"Here is some nonsense.\nNo sentinel characters included."}; std::vector expected{}; - ASSERT_EQ(gl::ParseGameLogFile(content), expected); + ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected); } @@ -60,7 +60,7 @@ TEST_F(GameLogTest, ParseGameLogFileStr_Sentinel_01) // NOLINT std::string s2{" single sentinel character."}; std::string content{s1 + m_sentinel + s2}; std::vector expected{s2}; - ASSERT_EQ(gl::ParseGameLogFile(content), expected); + ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected); } @@ -71,7 +71,7 @@ TEST_F(GameLogTest, ParseGameLogFileStr_Sentinel_02) // NOLINT std::string s3{"Another sentence."}; std::string content{s1 + m_sentinel + s2 + m_sentinel + s3}; std::vector expected{s2, s3}; - ASSERT_EQ(gl::ParseGameLogFile(content), expected); + ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected); } @@ -82,7 +82,7 @@ TEST_F(GameLogTest, ParseGameLogFileStr_Sentinel_03) // NOLINT std::string s3{"Another sentence."}; std::string content{s1 + m_sentinel + s2 + m_sentinel + m_sentinel + s3}; std::vector expected{s2, s3}; - ASSERT_EQ(gl::ParseGameLogFile(content), expected); + ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected); } @@ -94,7 +94,7 @@ TEST_F(GameLogTest, ParseGameLogFileStr_CutOff_01) // NOLINT std::string non_ascii{"ſþÖÄ"}; std::string content{s1 + m_sentinel + s2 + non_ascii + m_sentinel + s3}; std::vector expected{s2, s3}; - ASSERT_EQ(gl::ParseGameLogFile(content), expected); + ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected); } @@ -104,7 +104,7 @@ TEST_F(GameLogTest, ParseGameLogFileStr_CutOff_02) // NOLINT std::string s2{"a single sentinel character but an additional sentence. Another sentence."}; std::string content{s1 + m_sentinel + s2}; std::vector expected{s2}; - ASSERT_EQ(gl::ParseGameLogFile(content), expected); + ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected); } @@ -115,7 +115,7 @@ TEST_F(GameLogTest, ParseGameLogFileStr_CutOff_03) // NOLINT std::string s3{"Another sentence which should not be in the result."}; std::string content{s1 + m_sentinel + s2 + '\n' + s3}; std::vector expected{s2}; - ASSERT_EQ(gl::ParseGameLogFile(content), expected); + ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected); } @@ -129,7 +129,7 @@ TEST_F(GameLogTest, ParseGameLogFileStr_CutOff_04) // NOLINT std::string content{m_sentinel + prefix1 + m_sentinel + prefix2 + m_sentinel + t1 + m_sentinel + t2 + ignored}; std::vector expected{prefix1, prefix2, t1, t2}; - ASSERT_EQ(gl::ParseGameLogFile(content), expected); + ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected); } @@ -139,5 +139,5 @@ TEST_F(GameLogTest, ParseGameLogFileStr_CutOff_05) // NOLINT std::string s2{"a single sentinel character (and some reminder text example...)."}; std::string content{s1 + m_sentinel + s2}; std::vector expected{s2}; - ASSERT_EQ(gl::ParseGameLogFile(content), expected); + ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected); } diff --git a/src/file_parser/src/file_parser.cpp b/src/file_parser/src/file_parser.cpp index 4d05d15..3e8454b 100644 --- a/src/file_parser/src/file_parser.cpp +++ b/src/file_parser/src/file_parser.cpp @@ -29,7 +29,7 @@ static void show_usage(std::string const& exec_name) static void ParseFile(std::filesystem::path const& to_parse, std::filesystem::path const& output) { std::cout << "Parsing " << to_parse.filename() << ":\n"; - auto const lines = gl::ParseGameLogFile(to_parse); + auto const lines = mtgo_utils::ParseGameLogFile(to_parse); std::ofstream out{output}; for (auto const& line : lines) @@ -42,7 +42,7 @@ static void ParseFile(std::filesystem::path const& to_parse, std::filesystem::pa static void ParseFile(std::filesystem::path const& to_parse) { - auto const lines = gl::ParseGameLogFile(to_parse); + auto const lines = mtgo_utils::ParseGameLogFile(to_parse); for (auto const& line : lines) { std::cout << line << "\n"; @@ -123,7 +123,7 @@ int main(int argc, char* const* argv) // Iterate through directory and parse all match game logs. for (auto const& file : std::filesystem::recursive_directory_iterator{file_name}) { - if ((std::filesystem::is_regular_file(file)) && (gl::IsMatchGameLog(file))) + if ((std::filesystem::is_regular_file(file)) && (mtgo_utils::IsMatchGameLog(file))) { if (output_to_file) { @@ -140,7 +140,7 @@ int main(int argc, char* const* argv) else if (std::filesystem::is_regular_file(file_name)) { // Parse given file (if it is a match game log). - if (!gl::IsMatchGameLog(file_name)) + if (!mtgo_utils::IsMatchGameLog(file_name)) { std::cerr << "Error: " << file_name << " is (likely) no MTGO match game log.\n"; return 1;