aboutsummaryrefslogtreecommitdiffstats
path: root/src/base/songloading
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-01-18 02:55:02 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:45 +0100
commit7bced9e7855d0292be2da10d40aceb53a6c2575f (patch)
tree903eaf854a53932d4f0fc5e0b8a07373ad382d79 /src/base/songloading
parentf2d97dfee2d1a4e67f9fdbb8a1857e8383e5f300 (diff)
downloadusdx-7bced9e7855d0292be2da10d40aceb53a6c2575f.tar.gz
usdx-7bced9e7855d0292be2da10d40aceb53a6c2575f.tar.xz
usdx-7bced9e7855d0292be2da10d40aceb53a6c2575f.zip
added {r,l}trim_newline that only remove '\r' and '\n', remove '\r' from lyrics
Diffstat (limited to 'src/base/songloading')
-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);