Skip to content

Commit

Permalink
rename public namespace of library
Browse files Browse the repository at this point in the history
  • Loading branch information
BigPeet committed Mar 18, 2021
1 parent 72e5066 commit e700a95
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions lib/mtgo_utils/include/mtgo_utils/gamelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>
#include <vector>

namespace gl {
namespace mtgo_utils {

/**
* \brief Take the given input file, parse its content and return the parsed lines.
Expand Down Expand Up @@ -42,6 +42,6 @@ std::vector<std::string> 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 */
10 changes: 5 additions & 5 deletions lib/mtgo_utils/src/gamelog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "mtgo_utils/gamelog.h"

namespace gl {
namespace mtgo_utils {

namespace internal {

Expand Down Expand Up @@ -172,21 +172,21 @@ static std::vector<std::string> Split(std::string const& content)

std::vector<std::string> 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<std::string> 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<std::string> ParseGameLogFile(std::string const& file_content)
{
return gl::internal::Split(file_content);
return mtgo_utils::internal::Split(file_content);
}


Expand All @@ -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
32 changes: 16 additions & 16 deletions lib/mtgo_utils/tests/test_gamelog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}


Expand All @@ -32,25 +32,25 @@ 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<std::string> expected{};
ASSERT_EQ(gl::ParseGameLogFile(std::string{}), expected);
ASSERT_EQ(mtgo_utils::ParseGameLogFile(std::string{}), expected);
}


TEST_F(GameLogTest, ParseGameLogFileStr_Empty_02) // NOLINT
{
std::string content{"Here is some nonsense.\nNo sentinel characters included."};
std::vector<std::string> expected{};
ASSERT_EQ(gl::ParseGameLogFile(content), expected);
ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected);
}


Expand All @@ -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<std::string> expected{s2};
ASSERT_EQ(gl::ParseGameLogFile(content), expected);
ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected);
}


Expand All @@ -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<std::string> expected{s2, s3};
ASSERT_EQ(gl::ParseGameLogFile(content), expected);
ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected);
}


Expand All @@ -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<std::string> expected{s2, s3};
ASSERT_EQ(gl::ParseGameLogFile(content), expected);
ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected);
}


Expand All @@ -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<std::string> expected{s2, s3};
ASSERT_EQ(gl::ParseGameLogFile(content), expected);
ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected);
}


Expand All @@ -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<std::string> expected{s2};
ASSERT_EQ(gl::ParseGameLogFile(content), expected);
ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected);
}


Expand All @@ -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<std::string> expected{s2};
ASSERT_EQ(gl::ParseGameLogFile(content), expected);
ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected);
}


Expand All @@ -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<std::string> expected{prefix1, prefix2, t1, t2};
ASSERT_EQ(gl::ParseGameLogFile(content), expected);
ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected);
}


Expand All @@ -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<std::string> expected{s2};
ASSERT_EQ(gl::ParseGameLogFile(content), expected);
ASSERT_EQ(mtgo_utils::ParseGameLogFile(content), expected);
}
8 changes: 4 additions & 4 deletions src/file_parser/src/file_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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";
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
Expand Down

0 comments on commit e700a95

Please sign in to comment.