aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/base/songloading/songloading_strategy_txt.cpp21
-rw-r--r--src/base/songloading/songloading_strategy_txt.hpp10
2 files changed, 31 insertions, 0 deletions
diff --git a/src/base/songloading/songloading_strategy_txt.cpp b/src/base/songloading/songloading_strategy_txt.cpp
index 1a2c8eaf..2a74dd1d 100644
--- a/src/base/songloading/songloading_strategy_txt.cpp
+++ b/src/base/songloading/songloading_strategy_txt.cpp
@@ -85,6 +85,16 @@ namespace usdx
return line;
}
+ std::string& SongloadingStrategyTxt::ltrim_newlines(std::string& line)
+ {
+ std::size_t found = line.find_first_not_of("\n\r");
+ if (found != std::string::npos) {
+ line.erase(0, found - 1);
+ }
+
+ return line;
+ }
+
std::string& SongloadingStrategyTxt::rtrim(std::string& line)
{
std::size_t found = line.find_last_not_of(" \t\n\r");
@@ -95,6 +105,16 @@ namespace usdx
return line;
}
+ std::string& SongloadingStrategyTxt::rtrim_newlines(std::string& line)
+ {
+ std::size_t found = line.find_last_not_of("\n\r");
+ if (found != std::string::npos) {
+ line.erase(found + 1);
+ }
+
+ return line;
+ }
+
std::string& SongloadingStrategyTxt::trim(std::string& line)
{
return ltrim(rtrim(line));
@@ -196,6 +216,7 @@ namespace usdx
linestream >> beat >> length >> height >> std::noskipws;
linestream.ignore();
getline(linestream, lyric);
+ rtrim_newlines(lyric);
LOG4CXX_DEBUG(log, "Found lyric: '" << lyric << "' at line: " << line_number <<
" at beat: " << beat << " with length: " << length <<
diff --git a/src/base/songloading/songloading_strategy_txt.hpp b/src/base/songloading/songloading_strategy_txt.hpp
index 0330772b..0f9fd23d 100644
--- a/src/base/songloading/songloading_strategy_txt.hpp
+++ b/src/base/songloading/songloading_strategy_txt.hpp
@@ -55,6 +55,16 @@ namespace usdx
std::string& rtrim(std::string& line);
/**
+ * Removes ''\r'' and ''\n'' in front of the string.
+ */
+ std::string& ltrim_newlines(std::string& line);
+
+ /**
+ * Removes ''\r'' and ''\n'' behind the string.
+ */
+ std::string& rtrim_newlines(std::string& line);
+
+ /**
* Removes whitespaces in front of the string and behind it.
*/
std::string& trim(std::string& line);