aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/base/database.cpp28
-rw-r--r--src/base/database.hpp8
-rw-r--r--src/base/lyric_word.cpp10
-rw-r--r--src/base/lyric_word.hpp4
-rw-r--r--src/base/song.cpp104
-rw-r--r--src/base/song.hpp60
-rw-r--r--src/base/songloading/songloading_strategy_txt.cpp107
-rw-r--r--src/base/songloading/songloading_strategy_txt.hpp18
-rw-r--r--src/base/stats.cpp48
-rw-r--r--src/base/stats.hpp30
-rw-r--r--src/base/stats_database.cpp114
-rw-r--r--src/base/stats_database.hpp6
-rw-r--r--src/utils/file.cpp11
-rw-r--r--src/utils/file.hpp4
-rw-r--r--src/utils/locale_independent_float.cpp18
-rw-r--r--src/utils/locale_independent_float.hpp8
-rw-r--r--test/Makefile2
-rw-r--r--test/base/songloading.cpp25
18 files changed, 308 insertions, 297 deletions
diff --git a/src/base/database.cpp b/src/base/database.cpp
index a8b9aded..998179c0 100644
--- a/src/base/database.cpp
+++ b/src/base/database.cpp
@@ -49,33 +49,33 @@ namespace usdx
database = NULL;
}
- sqlite3_stmt *Database::sqlite_prepare(const std::string sqlStatement)
+ sqlite3_stmt *Database::sqlite_prepare(const std::wstring sqlStatement)
{
sqlite3_stmt *sqliteStatement;
- if (SQLITE_OK != sqlite3_prepare_v2(database, sqlStatement.c_str(), sqlStatement.length(), &sqliteStatement, NULL)) {
+ if (SQLITE_OK != sqlite3_prepare16_v2(database, sqlStatement.c_str(), sqlStatement.length(), &sqliteStatement, NULL)) {
sqlite3_finalize(sqliteStatement);
- LOG4CXX_ERROR(log, "Error '" << sqlite3_errmsg(database) << "' in SQL '" << sqlStatement << "'");
+ LOG4CXX_ERROR(log, L"Error '" << sqlite3_errmsg(database) << L"' in SQL '" << sqlStatement << L"'");
throw "Error preparing statement.";
}
return sqliteStatement;
}
- void Database::sqlite_exec(const std::string sqlStatement)
+ void Database::sqlite_exec(const std::wstring sqlStatement)
{
sqlite3_stmt *sqliteStatement = sqlite_prepare(sqlStatement);
sqlite3_step(sqliteStatement);
sqlite3_finalize(sqliteStatement);
}
- const bool Database::sqlite_table_exists(const std::string table)
+ const bool Database::sqlite_table_exists(const std::wstring table)
{
- std::string sql = "select [name] from [sqlite_master] where [type] = 'table' and [tbl_name] = ?1;";
+ std::wstring sql = L"select [name] from [sqlite_master] where [type] = 'table' and [tbl_name] = ?1;";
sqlite3_stmt *sqliteStatement = sqlite_prepare(sql);
// bind table name to parameter 1 and execute statement
- sqlite3_bind_text(sqliteStatement, 1, table.c_str(), table.length(), SQLITE_TRANSIENT);
+ sqlite3_bind_text16(sqliteStatement, 1, table.c_str(), table.length(), SQLITE_TRANSIENT);
int rc = sqlite3_step(sqliteStatement);
// if rc is SQLITE_ROW, than result has at lease one row and so
@@ -89,16 +89,16 @@ namespace usdx
return result;
}
- const bool Database::sqlite_table_contains_column(const std::string table, const std::string column)
+ const bool Database::sqlite_table_contains_column(const std::wstring table, const std::wstring column)
{
- sqlite3_stmt *sqliteStatement = sqlite_prepare("PRAGMA TABLE_INFO([" + table + "]);");
+ sqlite3_stmt *sqliteStatement = sqlite_prepare(L"PRAGMA TABLE_INFO([" + table + L"]);");
bool result = false;
int rc = sqlite3_step(sqliteStatement);
while (rc == SQLITE_ROW) {
- const char *column_name = (const char*)sqlite3_column_blob(sqliteStatement, 1);
+ const wchar_t *column_name = (const wchar_t*)sqlite3_column_blob(sqliteStatement, 1);
- if (column == std::string(column_name)) {
+ if (column == std::wstring(column_name)) {
result = true;
break;
}
@@ -113,7 +113,7 @@ namespace usdx
const int Database::get_version(void)
{
int result = -1;
- sqlite3_stmt *sqliteStatement = sqlite_prepare("PRAGMA user_version;");
+ sqlite3_stmt *sqliteStatement = sqlite_prepare(L"PRAGMA user_version;");
int rc = sqlite3_step(sqliteStatement);
if (rc == SQLITE_ROW) {
@@ -127,8 +127,8 @@ namespace usdx
void Database::set_version(const int version)
{
// format the PRAGMA statement (PRAGMA does _not_ support parameters)
- std::ostringstream sqlStatementBuffer (std::ostringstream::out);
- sqlStatementBuffer << "PRAGMA user_version = " << version << ";";
+ std::wostringstream sqlStatementBuffer (std::wostringstream::out);
+ sqlStatementBuffer << L"PRAGMA user_version = " << version << L";";
sqlite_exec(sqlStatementBuffer.str());
}
diff --git a/src/base/database.hpp b/src/base/database.hpp
index ca13ec8c..2a320f45 100644
--- a/src/base/database.hpp
+++ b/src/base/database.hpp
@@ -62,13 +62,13 @@ namespace usdx
* parameters and executing the statement. Need to be freed
* with sqlite3_finalize.
*/
- sqlite3_stmt *sqlite_prepare(const std::string sqlStatement);
+ sqlite3_stmt *sqlite_prepare(const std::wstring sqlStatement);
/**
* Just a quick alias for sqlite_prepare, sqlite3_step and
* sqlite3_finalize.
*/
- void sqlite_exec(const std::string sqlStatement);
+ void sqlite_exec(const std::wstring sqlStatement);
/**
* Check if the given table exists in the database.
@@ -76,7 +76,7 @@ namespace usdx
* @param table Name to check if exists
* @return true, if table exists, false if not
*/
- const bool sqlite_table_exists(const std::string table);
+ const bool sqlite_table_exists(const std::wstring table);
/**
* Check if the given table has the given column by name.
@@ -85,7 +85,7 @@ namespace usdx
* @param column Name of the column to check if exists
* @return true, if column exists in that table, false if not
*/
- const bool sqlite_table_contains_column(const std::string table, const std::string column);
+ const bool sqlite_table_contains_column(const std::wstring table, const std::wstring column);
/**
* Queries the user version from the sqlite database. This is a
diff --git a/src/base/lyric_word.cpp b/src/base/lyric_word.cpp
index c6c5d7d9..979d02a9 100644
--- a/src/base/lyric_word.cpp
+++ b/src/base/lyric_word.cpp
@@ -28,20 +28,20 @@
namespace usdx
{
- LyricWord::LyricWord(const char type,
+ LyricWord::LyricWord(const wchar_t type,
const int beat,
const int length,
const int height,
- const std::string& lyric) :
+ const std::wstring& lyric) :
beat(beat), length(length), height(height), text(lyric)
{
- if (type == ':') {
+ if (type == L':') {
this->type = nt_normal;
}
- else if (type == '*') {
+ else if (type == L'*') {
this->type = nt_golden;
}
- else if (type == 'F') {
+ else if (type == L'F') {
this->type = nt_freestyle;
}
}
diff --git a/src/base/lyric_word.hpp b/src/base/lyric_word.hpp
index 4b19b13c..54f2ea3f 100644
--- a/src/base/lyric_word.hpp
+++ b/src/base/lyric_word.hpp
@@ -44,10 +44,10 @@ namespace usdx
int beat;
int length;
int height;
- std::string text;
+ std::wstring text;
public:
- LyricWord(const char type, const int beat, const int length, const int height, const std::string& lyric);
+ LyricWord(const wchar_t type, const int beat, const int length, const int height, const std::wstring& lyric);
virtual ~LyricWord(void);
};
};
diff --git a/src/base/song.cpp b/src/base/song.cpp
index d4429f04..ff00bbed 100644
--- a/src/base/song.cpp
+++ b/src/base/song.cpp
@@ -38,38 +38,38 @@ namespace usdx
return filename;
}
- Song::Song(const std::string& filename, const std::map<std::string, std::string>& header) :
+ Song::Song(const std::string& filename, const std::map<std::wstring, std::wstring>& header) :
filename(filename), custom_header_tags(header)
{
- std::map<std::string, std::string>::iterator it;
+ std::map<std::wstring, std::wstring>::iterator it;
- title = get_header_tag("TITLE", true);
- artist = get_header_tag("ARTIST", true);
- mp3 = get_header_tag("MP3", true);
+ title = get_header_tag(L"TITLE", true);
+ artist = get_header_tag(L"ARTIST", true);
+ mp3 = get_header_tag(L"MP3", true);
- bpm.push_back(new BPM(get_header_tag_float("BPM", true)));
+ bpm.push_back(new BPM(get_header_tag_float(L"BPM", true)));
- gap = get_header_tag_float("GAP");
- cover = get_header_tag("COVER");
- background = get_header_tag("BACKGROUND");
+ gap = get_header_tag_float(L"GAP");
+ cover = get_header_tag(L"COVER");
+ background = get_header_tag(L"BACKGROUND");
- video = get_header_tag("VIDEO");
- video_gap = get_header_tag_float("VIDEOGAP");
+ video = get_header_tag(L"VIDEO");
+ video_gap = get_header_tag_float(L"VIDEOGAP");
- genre = get_header_tag("GENRE");
- edition = get_header_tag("EDITION");
- creator = get_header_tag("CREATOR");
- language = get_header_tag("LANGUAGE");
+ genre = get_header_tag(L"GENRE");
+ edition = get_header_tag(L"EDITION");
+ creator = get_header_tag(L"CREATOR");
+ language = get_header_tag(L"LANGUAGE");
- year = get_header_tag_int("YEAR");
+ year = get_header_tag_int(L"YEAR");
- start = get_header_tag_float("START");
- stop = get_header_tag_int("END");
+ start = get_header_tag_float(L"START");
+ stop = get_header_tag_int(L"END");
- resolution = get_header_tag_int("RESOLUTION");
- notes_gap = get_header_tag_int("NOTESGAP");
+ resolution = get_header_tag_int(L"RESOLUTION");
+ notes_gap = get_header_tag_int(L"NOTESGAP");
- relative = get_header_tag_bool("RELATIVE");
+ relative = get_header_tag_bool(L"RELATIVE");
// TODO
// EncFile := DecodeFilename(Value);
@@ -97,26 +97,27 @@ namespace usdx
lyrics.clear();
}
- std::string Song::get_header_tag(const std::string& tag, const bool required)
+ std::wstring Song::get_header_tag(const std::wstring& tag, const bool required)
{
- std::map<std::string, std::string>::iterator it;
- std::string result = "";
+ std::map<std::wstring, std::wstring>::iterator it;
+ std::wstring result = L"";
if ((it = custom_header_tags.find(tag)) != custom_header_tags.end()) {
result = it->second;
custom_header_tags.erase(it);
}
else if (required) {
- LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << get_filename() << "'");
+ LOG4CXX_ERROR(log, L"Incomplete Song! Missing '" << tag << L"' Tag in: '" <<
+ std::wstring(get_filename().begin(), get_filename().end()) << L"'");
throw MissingTagException(tag, "Incomplete Song! Missing Tag.");
}
return result;
}
- float Song::get_header_tag_float(const std::string& tag, const bool required)
+ float Song::get_header_tag_float(const std::wstring& tag, const bool required)
{
- std::map<std::string, std::string>::iterator it;
+ std::map<std::wstring, std::wstring>::iterator it;
float result;
if ((it = custom_header_tags.find(tag)) != custom_header_tags.end()) {
@@ -124,46 +125,49 @@ namespace usdx
custom_header_tags.erase(it);
}
else if (required) {
- LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << get_filename() << "'");
+ LOG4CXX_ERROR(log, L"Incomplete Song! Missing '" << tag << L"' Tag in: '" <<
+ std::wstring(get_filename().begin(), get_filename().end()) << L"'");
throw MissingTagException(tag, "Incomplete Song! Missing Tag.");
}
return result;
}
- int Song::get_header_tag_int(const std::string& tag, const bool required)
+ int Song::get_header_tag_int(const std::wstring& tag, const bool required)
{
- std::map<std::string, std::string>::iterator it;
+ std::map<std::wstring, std::wstring>::iterator it;
int result;
if ((it = custom_header_tags.find(tag)) != custom_header_tags.end()) {
- std::istringstream stream(it->second);
+ std::wistringstream stream(it->second);
custom_header_tags.erase(it);
stream >> result;
}
else if (required) {
- LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << get_filename() << "'");
+ LOG4CXX_ERROR(log, L"Incomplete Song! Missing '" << tag << L"' Tag in: '" <<
+ std::wstring(get_filename().begin(), get_filename().end()) << L"'");
throw MissingTagException(tag, "Incomplete Song! Missing Tag.");
}
return result;
}
- bool Song::get_header_tag_bool(const std::string& tag, const bool required)
+ bool Song::get_header_tag_bool(const std::wstring& tag, const bool required)
{
- std::map<std::string, std::string>::iterator it;
+ std::map<std::wstring, std::wstring>::iterator it;
bool result;
if ((it = custom_header_tags.find(tag)) != custom_header_tags.end()) {
// accept all like (YES, JA, TRUE, 1)
- result = (it->second[0] == 'j' || it->second[0] == 'J' ||
- it->second[0] == 'y' || it->second[0] == 'Y' ||
- it->second[0] == 't' || it->second[0] == 'T' ||
- it->second[0] == '1');
+ result = (it->second[0] == L'j' || it->second[0] == L'J' ||
+ it->second[0] == L'y' || it->second[0] == L'Y' ||
+ it->second[0] == L't' || it->second[0] == L'T' ||
+ it->second[0] == L'1');
custom_header_tags.erase(it);
}
else if (required) {
- LOG4CXX_ERROR(log, "Incomplete Song! Missing '" << tag << "' Tag in: '" << get_filename() << "'");
+ LOG4CXX_ERROR(log, L"Incomplete Song! Missing '" << tag << L"' Tag in: '" <<
+ std::wstring(get_filename().begin(), get_filename().end()) << L"'");
throw MissingTagException(tag, "Incomplete Song! Missing Tag.");
}
@@ -186,17 +190,17 @@ namespace usdx
return line;
}
- const std::string& Song::get_title(void) const
+ const std::wstring& Song::get_title(void) const
{
return title;
}
- const std::string& Song::get_artist(void) const
+ const std::wstring& Song::get_artist(void) const
{
return artist;
}
- const std::string& Song::get_mp3(void) const
+ const std::wstring& Song::get_mp3(void) const
{
return mp3;
}
@@ -221,17 +225,17 @@ namespace usdx
return gap;
}
- const std::string& Song::get_cover(void) const
+ const std::wstring& Song::get_cover(void) const
{
return cover;
}
- const std::string& Song::get_background(void) const
+ const std::wstring& Song::get_background(void) const
{
return background;
}
- const std::string& Song::get_video(void) const
+ const std::wstring& Song::get_video(void) const
{
return video;
}
@@ -241,22 +245,22 @@ namespace usdx
return video_gap;
}
- const std::string& Song::get_genre(void) const
+ const std::wstring& Song::get_genre(void) const
{
return genre;
}
- const std::string& Song::get_edition(void) const
+ const std::wstring& Song::get_edition(void) const
{
return edition;
}
- const std::string& Song::get_creator(void) const
+ const std::wstring& Song::get_creator(void) const
{
return creator;
}
- const std::string& Song::get_language(void) const
+ const std::wstring& Song::get_language(void) const
{
return language;
}
@@ -316,7 +320,7 @@ namespace usdx
create_new_lyric_line(line_in + get_relative_beat());
}
- void Song::new_note(const char type, const int beat, const int length, const int height, const std::string& lyric)
+ void Song::new_note(const wchar_t type, const int beat, const int length, const int height, const std::wstring& lyric)
{
get_last_lyric_line()->add_word(new LyricWord(type, beat + get_relative_beat(), length, height, lyric));
}
diff --git a/src/base/song.hpp b/src/base/song.hpp
index d831a91e..d9a6271c 100644
--- a/src/base/song.hpp
+++ b/src/base/song.hpp
@@ -43,16 +43,16 @@ namespace usdx
/**
* TODO: Maybe refactor this to separate sub-classes.
*/
- const std::string tag;
+ const std::wstring tag;
public:
- MissingTagException(const std::string tag,
+ MissingTagException(const std::wstring tag,
const std::string message) :
BaseException(message), tag(tag) {};
~MissingTagException () throw () {};
- virtual const std::string& get_tag() const { return tag; };
+ virtual const std::wstring& get_tag() const { return tag; };
};
class Song
@@ -62,25 +62,25 @@ namespace usdx
std::string filename;
- std::string title;
- std::string artist;
+ std::wstring title;
+ std::wstring artist;
// filenames
- std::string mp3;
+ std::wstring mp3;
- std::string background;
+ std::wstring background;
- std::string video;
+ std::wstring video;
float video_gap;
- std::string cover;
+ std::wstring cover;
// texture cover_tex;
- std::string genre;
- std::string edition;
- std::string language;
+ std::wstring genre;
+ std::wstring edition;
+ std::wstring language;
int year;
- std::string creator;
+ std::wstring creator;
int notes_gap;
float gap; ///< in miliseconds
@@ -94,12 +94,12 @@ namespace usdx
std::list<LyricLine*> lyrics;
- std::map<std::string, std::string> custom_header_tags;
+ std::map<std::wstring, std::wstring> custom_header_tags;
- std::string get_header_tag(const std::string& tag, const bool required = false);
- float get_header_tag_float(const std::string& tag, const bool required = false);
- int get_header_tag_int(const std::string& tag, const bool required = false);
- bool get_header_tag_bool(const std::string& tag, const bool required = false);
+ std::wstring get_header_tag(const std::wstring& tag, const bool required = false);
+ float get_header_tag_float(const std::wstring& tag, const bool required = false);
+ int get_header_tag_int(const std::wstring& tag, const bool required = false);
+ bool get_header_tag_bool(const std::wstring& tag, const bool required = false);
LyricLine* get_last_lyric_line(void);
LyricLine* create_new_lyric_line(int start);
@@ -114,24 +114,24 @@ namespace usdx
// TODO: Encoding: TEncoding;
public:
- Song(const std::string& filename, const std::map<std::string, std::string>& header);
+ Song(const std::string& filename, const std::map<std::wstring, std::wstring>& header);
virtual ~Song(void);
const std::string& get_filename(void) const;
- const std::string& get_title(void) const;
- const std::string& get_artist(void) const;
- const std::string& get_mp3(void) const;
+ const std::wstring& get_title(void) const;
+ const std::wstring& get_artist(void) const;
+ const std::wstring& get_mp3(void) const;
const float get_bpm(int beat) const;
const float get_gap(void) const;
- const std::string& get_cover(void) const;
- const std::string& get_background(void) const;
- const std::string& get_video(void) const;
+ const std::wstring& get_cover(void) const;
+ const std::wstring& get_background(void) const;
+ const std::wstring& get_video(void) const;
const float get_video_gap(void) const;
- const std::string& get_genre(void) const;
- const std::string& get_edition(void) const;
- const std::string& get_creator(void) const;
- const std::string& get_language(void) const;
+ const std::wstring& get_genre(void) const;
+ const std::wstring& get_edition(void) const;
+ const std::wstring& get_creator(void) const;
+ const std::wstring& get_language(void) const;
const int get_year(void) const;
const float get_start(void) const;
const int get_stop(void) const;
@@ -144,7 +144,7 @@ namespace usdx
void new_bpm(const int beat, const float new_bpm);
void new_line(const int line_out, const int line_in);
- void new_note(const char type, const int beat, const int length, const int height, const std::string& lyric);
+ void new_note(const wchar_t type, const int beat, const int length, const int height, const std::wstring& lyric);
};
};
diff --git a/src/base/songloading/songloading_strategy_txt.cpp b/src/base/songloading/songloading_strategy_txt.cpp
index 0f9e3fff..c65e9347 100644
--- a/src/base/songloading/songloading_strategy_txt.cpp
+++ b/src/base/songloading/songloading_strategy_txt.cpp
@@ -47,16 +47,16 @@ namespace usdx
{
}
- std::pair<std::string, std::string> SongloadingStrategyTxt::split_header_field(std::string &line)
+ std::pair<std::wstring, std::wstring> SongloadingStrategyTxt::split_header_field(std::wstring &line)
{
- std::size_t pos = line.find(':');
+ std::size_t pos = line.find(L':');
- if (line[0] != '#' || pos == std::string::npos) {
- LOG4CXX_DEBUG(log, "Tried to parse invalid header line: '" << line << "'");
+ if (line[0] != L'#' || pos == std::wstring::npos) {
+ LOG4CXX_DEBUG(log, L"Tried to parse invalid header line: '" << line << L"'");
throw "Invalid header!";
}
- std::pair<std::string, std::string> result;
+ std::pair<std::wstring, std::wstring> result;
// copy the substring until ':', without # to result.first and
// transform to upper case
@@ -72,52 +72,52 @@ namespace usdx
// line is already rtrimmed
ltrim(result.second);
- LOG4CXX_DEBUG(log, "Found header: '" << result.first << "' with value '" << result.second << "'");
+ LOG4CXX_DEBUG(log, L"Found header: '" << result.first << L"' with value '" << result.second << L"'");
return result;
}
- std::string& SongloadingStrategyTxt::ltrim(std::string& line)
+ std::wstring& SongloadingStrategyTxt::ltrim(std::wstring& line)
{
- std::size_t found = line.find_first_not_of(" \t\n\r");
- if (found != std::string::npos && found >= 1) {
+ std::size_t found = line.find_first_not_of(L" \t\n\r");
+ if (found != std::wstring::npos && found >= 1) {
line.erase(0, found - 1);
}
return line;
}
- std::string& SongloadingStrategyTxt::ltrim_newlines(std::string& line)
+ std::wstring& SongloadingStrategyTxt::ltrim_newlines(std::wstring& line)
{
- std::size_t found = line.find_first_not_of("\n\r");
- if (found != std::string::npos) {
+ std::size_t found = line.find_first_not_of(L"\n\r");
+ if (found != std::wstring::npos) {
line.erase(0, found - 1);
}
return line;
}
- std::string& SongloadingStrategyTxt::rtrim(std::string& line)
+ std::wstring& SongloadingStrategyTxt::rtrim(std::wstring& line)
{
- std::size_t found = line.find_last_not_of(" \t\n\r");
- if (found != std::string::npos) {
+ std::size_t found = line.find_last_not_of(L" \t\n\r");
+ if (found != std::wstring::npos) {
line.erase(found + 1);
}
return line;
}
- std::string& SongloadingStrategyTxt::rtrim_newlines(std::string& line)
+ std::wstring& SongloadingStrategyTxt::rtrim_newlines(std::wstring& line)
{
- std::size_t found = line.find_last_not_of("\n\r");
- if (found != std::string::npos) {
+ std::size_t found = line.find_last_not_of(L"\n\r");
+ if (found != std::wstring::npos) {
line.erase(found + 1);
}
return line;
}
- std::string& SongloadingStrategyTxt::trim(std::string& line)
+ std::wstring& SongloadingStrategyTxt::trim(std::wstring& line)
{
return ltrim(rtrim(line));
}
@@ -139,17 +139,17 @@ namespace usdx
bool SongloadingStrategyTxt::parse_line(Song* song, File& file, const int line_number)
{
try {
- std::string line;
+ std::wstring line;
std::getline(file.stream(), line);
- char type;
- std::istringstream linestream(line);
+ wchar_t type;
+ std::wistringstream linestream(line);
linestream >> std::skipws >> type;
- if (type == '#') {
+ if (type == L'#') {
// ignore, header already read
}
- else if (type == 'E') {
+ else if (type == L'E') {
// song end
if (file.stream().eof()) {
LOG4CXX_WARN(log, "End marker found in line " << line_number <<
@@ -158,30 +158,31 @@ namespace usdx
return false;
}
- else if (type == '-') {
+ else if (type == L'-') {
parse_newline(song, linestream, line_number);
}
- else if (type == 'B') {
+ else if (type == L'B') {
parse_bpm(song, linestream, line_number);
}
- else if (type == ':' || type == 'F' || type == '*') {
+ else if (type == L':' || type == L'F' || type == L'*') {
parse_note(song, type, linestream, line_number);
}
else {
- LOG4CXX_WARN(log, "Unknown line in song: '" << line <<
- "' in file: " << song->get_filename() <<
- " at line " << line_number);
+ LOG4CXX_WARN(log, L"Unknown line in song: '" << line <<
+ L"' in file: " << std::wstring(song->get_filename().begin(),
+ song->get_filename().end()) <<
+ L" at line " << line_number);
}
}
catch (std::exception &e) {
- LOG4CXX_WARN(log, "Error in song file at line " <<
- line_number << ": " << e.what());
+ LOG4CXX_WARN(log, L"Error in song file at line " <<
+ line_number << L": " << e.what());
}
return true;
}
- void SongloadingStrategyTxt::parse_newline(Song *song, std::istringstream& linestream, const int line_number)
+ void SongloadingStrategyTxt::parse_newline(Song *song, std::wistringstream& linestream, const int line_number)
{
// line break
int line_out, line_in = -1;
@@ -189,63 +190,63 @@ namespace usdx
linestream >> line_out;
if (linestream.good()) {
linestream >> line_in;
- LOG4CXX_DEBUG(log, "Found newline in line " <<
- line_number << " with out of last line with "
- << line_out << " and in of next line " << line_in);
+ LOG4CXX_DEBUG(log, L"Found newline in line " <<
+ line_number << L" with out of last line with " <<
+ line_out << L" and in of next line " << line_in);
}
else {
- LOG4CXX_DEBUG(log, "Found newline in line " <<
- line_number << " with out of last line with "
- << line_out);
+ LOG4CXX_DEBUG(log, L"Found newline in line " <<
+ line_number << L" with out of last line with " <<
+ line_out);
}
song->new_line(line_out, line_in);
}
- void SongloadingStrategyTxt::parse_bpm(Song *song, std::istringstream& linestream, const int line_number)
+ void SongloadingStrategyTxt::parse_bpm(Song *song, std::wistringstream& linestream, const int line_number)
{
// new bpm
int beat;
LocaleIndependentFloat new_bpm;
linestream >> beat >> new_bpm;
- LOG4CXX_DEBUG(log, "Found new bpm in line " <<
- line_number << " starting at beat: " <<
- beat << " and new bpm of " << new_bpm.get_value());
+ LOG4CXX_DEBUG(log, L"Found new bpm in line " <<
+ line_number << L" starting at beat: " <<
+ beat << L" and new bpm of " << new_bpm.get_value());
song->new_bpm(beat, new_bpm.get_value());
}
- void SongloadingStrategyTxt::parse_note(Song *song, char type, std::istringstream& linestream, const int line_number)
+ void SongloadingStrategyTxt::parse_note(Song *song, wchar_t type, std::wistringstream& linestream, const int line_number)
{
// normal line
int beat, length, height;
- std::string lyric;
+ std::wstring lyric;
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 <<
- " at height: " << height);
+ LOG4CXX_DEBUG(log, L"Found lyric: '" << lyric << L"' at line: " << line_number <<
+ L" at beat: " << beat << L" with length: " << length <<
+ L" at height: " << height);
song->new_note(type, beat, length, height, lyric);
}
Song* SongloadingStrategyTxt::load_header(const std::string& filename)
{
File file(filename);
- std::string line;
- std::map<std::string, std::string> header_fields;
+ std::wstring line;
+ std::map<std::wstring, std::wstring> header_fields;
bool header = true, notes_found = false;
while (file.stream().good()) {
std::getline(file.stream(), line);
trim(line);
- LOG4CXX_DEBUG(log, "Line: " << line);
+ LOG4CXX_DEBUG(log, L"Line: " << line);
- if (header && line[0] == '#') {
+ if (header && line[0] == L'#') {
// header
header_fields.insert(split_header_field(line));
@@ -256,7 +257,7 @@ namespace usdx
header = false;
}
- if (line[0] == ':' || line[0] == '*' || line[0] == 'F') {
+ if (line[0] == L':' || line[0] == L'*' || line[0] == L'F') {
notes_found = true;
break;
}
diff --git a/src/base/songloading/songloading_strategy_txt.hpp b/src/base/songloading/songloading_strategy_txt.hpp
index 0f9fd23d..097f35cf 100644
--- a/src/base/songloading/songloading_strategy_txt.hpp
+++ b/src/base/songloading/songloading_strategy_txt.hpp
@@ -42,37 +42,37 @@ namespace usdx
/**
* Split the header field in name and value.
*/
- std::pair<std::string, std::string> split_header_field(std::string &line);
+ std::pair<std::wstring, std::wstring> split_header_field(std::wstring &line);
/**
* Removes whitespaces in front of the string.
*/
- std::string& ltrim(std::string& line);
+ std::wstring& ltrim(std::wstring& line);
/**
* Removes whitespaces behind the string.
*/
- std::string& rtrim(std::string& line);
+ std::wstring& rtrim(std::wstring& line);
/**
* Removes ''\r'' and ''\n'' in front of the string.
*/
- std::string& ltrim_newlines(std::string& line);
+ std::wstring& ltrim_newlines(std::wstring& line);
/**
* Removes ''\r'' and ''\n'' behind the string.
*/
- std::string& rtrim_newlines(std::string& line);
+ std::wstring& rtrim_newlines(std::wstring& line);
/**
* Removes whitespaces in front of the string and behind it.
*/
- std::string& trim(std::string& line);
+ std::wstring& trim(std::wstring& line);
bool parse_line(Song* song, File& file, const int line_number);
- void parse_newline(Song* song, std::istringstream& linestream, const int line_number);
- void parse_bpm(Song* song, std::istringstream& linestream, const int line_number);
- void parse_note(Song* song, char type, std::istringstream& linestream, const int line_number);
+ void parse_newline(Song* song, std::wistringstream& linestream, const int line_number);
+ void parse_bpm(Song* song, std::wistringstream& linestream, const int line_number);
+ void parse_note(Song* song, wchar_t type, std::wistringstream& linestream, const int line_number);
public:
diff --git a/src/base/stats.cpp b/src/base/stats.cpp
index 613b4f33..7ad32e74 100644
--- a/src/base/stats.cpp
+++ b/src/base/stats.cpp
@@ -49,7 +49,7 @@ namespace usdx
return db;
}
- int Stats::get_count(std::string query)
+ int Stats::get_count(std::wstring query)
{
int result = 0;
sqlite3_stmt *sqliteStatement =
@@ -84,8 +84,8 @@ namespace usdx
int result = -1;
sqlite3_stmt *sqliteStatement = get_database()->sqlite_prepare(
- "SELECT [ResetTime] FROM [" +
- get_database()->usdx_statistics_info + "];");
+ L"SELECT [ResetTime] FROM [" +
+ get_database()->usdx_statistics_info + L"];");
int rc = sqlite3_step(sqliteStatement);
if (rc == SQLITE_ROW) {
@@ -163,19 +163,19 @@ namespace usdx
}
*/
- StatResultBestScores::StatResultBestScores(char *singer, unsigned short score, unsigned short difficulty,
- char* song_artist, char* song_title, time_t date)
+ StatResultBestScores::StatResultBestScores(wchar_t *singer, unsigned short score, unsigned short difficulty,
+ wchar_t* song_artist, wchar_t* song_title, time_t date)
{
- this->singer = std::string(singer);
+ this->singer = std::wstring(singer);
this->score = score;
this->difficulty = difficulty;
- this->song_artist = std::string(song_artist);
- this->song_title = std::string(song_title);
+ this->song_artist = std::wstring(song_artist);
+ this->song_title = std::wstring(song_title);
this->date = date;
this->next = NULL;
}
- StatResultBestScores::StatResultBestScores(char* song_artist, char* song_title)
+ StatResultBestScores::StatResultBestScores(wchar_t* song_artist, wchar_t* song_title)
{
this->next = NULL;
@@ -271,8 +271,8 @@ namespace usdx
int StatResultBestScores::get_count(void)
{
- return Stats::get_count("SELECT COUNT([SongID]) FROM [" +
- get_database()->usdx_scores + "];");
+ return Stats::get_count(L"SELECT COUNT([SongID]) FROM [" +
+ get_database()->usdx_scores + L"];");
}
StatResultBestScores *StatResultBestScores::get_stats()
@@ -283,9 +283,9 @@ namespace usdx
- StatResultBestSingers::StatResultBestSingers(char *singer, unsigned short average_score)
+ StatResultBestSingers::StatResultBestSingers(wchar_t *singer, unsigned short average_score)
{
- this->singer = std::string(singer);
+ this->singer = std::wstring(singer);
this->average_score = average_score;
this->next = NULL;
}
@@ -306,8 +306,8 @@ namespace usdx
int StatResultBestSingers::get_count(void)
{
return Stats::get_count(
- "SELECT COUNT(DISTINCT [Player]) FROM ["
- + get_database()->usdx_scores + "];");
+ L"SELECT COUNT(DISTINCT [Player]) FROM ["
+ + get_database()->usdx_scores + L"];");
}
StatResultBestSingers *StatResultBestSingers::get_stats()
@@ -317,10 +317,10 @@ namespace usdx
}
- StatResultMostSungSong::StatResultMostSungSong(char* song_artist, char* song_title, unsigned short times_sung)
+ StatResultMostSungSong::StatResultMostSungSong(wchar_t* song_artist, wchar_t* song_title, unsigned short times_sung)
{
- this->song_artist = std::string(song_artist);
- this->song_title = std::string(song_title);
+ this->song_artist = std::wstring(song_artist);
+ this->song_title = std::wstring(song_title);
this->times_sung = times_sung;
this->next = NULL;
}
@@ -340,8 +340,8 @@ namespace usdx
int StatResultMostSungSong::get_count(void)
{
- return Stats::get_count("SELECT COUNT([ID]) FROM [" +
- get_database()->usdx_scores + "];");
+ return Stats::get_count(L"SELECT COUNT([ID]) FROM [" +
+ get_database()->usdx_scores + L"];");
}
StatResultMostSungSong *StatResultMostSungSong::get_stats()
@@ -351,9 +351,9 @@ namespace usdx
}
- StatResultMostSungBand::StatResultMostSungBand(char* song_artist, unsigned short times_sung)
+ StatResultMostSungBand::StatResultMostSungBand(wchar_t* song_artist, unsigned short times_sung)
{
- this->song_artist = std::string(song_artist);
+ this->song_artist = std::wstring(song_artist);
this->times_sung = times_sung;
this->next = NULL;
}
@@ -374,8 +374,8 @@ namespace usdx
int StatResultMostSungBand::get_count(void)
{
return Stats::get_count(
- "SELECT COUNT(DISTINCT [Artist]) FROM [" +
- get_database()->usdx_scores + "];");
+ L"SELECT COUNT(DISTINCT [Artist]) FROM [" +
+ get_database()->usdx_scores + L"];");
}
StatResultMostSungBand *StatResultMostSungBand::get_stats()
diff --git a/src/base/stats.hpp b/src/base/stats.hpp
index b3068024..d6bb48ad 100644
--- a/src/base/stats.hpp
+++ b/src/base/stats.hpp
@@ -69,7 +69,7 @@ namespace usdx
/**
* TODO
*/
- static int get_count(std::string query);
+ static int get_count(std::wstring query);
public:
/**
@@ -111,27 +111,27 @@ namespace usdx
class StatResultBestScores : public Stats
{
private:
- std::string singer;
+ std::wstring singer;
unsigned short score;
unsigned short difficulty;
- std::string song_artist;
- std::string song_title;
+ std::wstring song_artist;
+ std::wstring song_title;
time_t date;
StatResultBestScores *next;
StatResultBestScores(
- char *singer,
+ wchar_t *singer,
unsigned short score,
unsigned short difficulty,
- char* song_artist,
- char* song_title,
+ wchar_t* song_artist,
+ wchar_t* song_title,
time_t date);
public:
/**
* TODO
*/
- StatResultBestScores(char* song_artist, char* song_title);
+ StatResultBestScores(wchar_t* song_artist, wchar_t* song_title);
~StatResultBestScores(void);
@@ -145,12 +145,12 @@ namespace usdx
class StatResultBestSingers : public Stats
{
private:
- std::string singer;
+ std::wstring singer;
unsigned short average_score;
StatResultBestSingers *next;
- StatResultBestSingers(char *singer, unsigned short average_score);
+ StatResultBestSingers(wchar_t *singer, unsigned short average_score);
public:
~StatResultBestSingers(void);
@@ -164,13 +164,13 @@ namespace usdx
class StatResultMostSungSong : public Stats
{
private:
- std::string song_artist;
- std::string song_title;
+ std::wstring song_artist;
+ std::wstring song_title;
unsigned short times_sung;
StatResultMostSungSong *next;
- StatResultMostSungSong(char* song_artist, char* song_title, unsigned short times_sung);
+ StatResultMostSungSong(wchar_t* song_artist, wchar_t* song_title, unsigned short times_sung);
public:
~StatResultMostSungSong(void);
@@ -184,12 +184,12 @@ namespace usdx
class StatResultMostSungBand : public Stats
{
private:
- std::string song_artist;
+ std::wstring song_artist;
unsigned short times_sung;
StatResultMostSungBand *next;
- StatResultMostSungBand(char* song_artist, unsigned short times_sung);
+ StatResultMostSungBand(wchar_t* song_artist, unsigned short times_sung);
public:
~StatResultMostSungBand(void);
diff --git a/src/base/stats_database.cpp b/src/base/stats_database.cpp
index deb896ef..a46d9ccb 100644
--- a/src/base/stats_database.cpp
+++ b/src/base/stats_database.cpp
@@ -29,14 +29,14 @@
namespace usdx
{
const int db_version = 1;
- const std::string StatDatabase::usdx_scores =
- "us_scores";
+ const std::wstring StatDatabase::usdx_scores =
+ L"us_scores";
- const std::string StatDatabase::usdx_songs =
- "us_songs";
+ const std::wstring StatDatabase::usdx_songs =
+ L"us_songs";
- const std::string StatDatabase::usdx_statistics_info =
- "us_statistics_info";
+ const std::wstring StatDatabase::usdx_statistics_info =
+ L"us_statistics_info";
log4cxx::LoggerPtr StatDatabase::log =
log4cxx::Logger::getLogger("usdx.base.StatDatabase");
@@ -49,19 +49,19 @@ namespace usdx
if (! sqlite_table_exists(usdx_statistics_info)) {
// add table usdx_statistics_info, needed in the
// conversion from 1.01 to 1.1
- LOG4CXX_INFO(log, "Outdated song database found " <<
- "- missing table'" <<
- usdx_statistics_info << "'");
+ LOG4CXX_INFO(log, L"Outdated song database found " <<
+ L"- missing table'" <<
+ usdx_statistics_info << L"'");
- sqlite_exec("CREATE TABLE IF NOT EXISTS [" +
+ sqlite_exec(L"CREATE TABLE IF NOT EXISTS [" +
usdx_statistics_info +
- "] ([ResetTime] Integer);");
+ L"] ([ResetTime] Integer);");
// insert creation timestamp
sqlite3_stmt *sqliteStatement =
- sqlite_prepare("INSERT INTO [" +
+ sqlite_prepare(L"INSERT INTO [" +
usdx_statistics_info +
- "] ([ResetTime]) VALUES (?1);");
+ L"] ([ResetTime]) VALUES (?1);");
sqlite3_bind_int(sqliteStatement, 1, time(NULL));
sqlite3_step(sqliteStatement);
@@ -71,12 +71,12 @@ namespace usdx
int version = get_version();
bool finalizeConversion = false;
- if (version == 0 && sqlite_table_exists("US_Scores")) {
+ if (version == 0 && sqlite_table_exists(L"US_Scores")) {
// convert data from 1.01 to 1.1
// part #1 - prearrangement: rename old tables
// to be able to insert new table structures
- sqlite_exec("ALTER TABLE US_Scores RENAME TO us_scores_101;");
- sqlite_exec("ALTER TABLE US_Songs RENAME TO us_songs_101;");
+ sqlite_exec(L"ALTER TABLE US_Scores RENAME TO us_scores_101;");
+ sqlite_exec(L"ALTER TABLE US_Songs RENAME TO us_songs_101;");
}
if (version == 0) {
@@ -92,77 +92,77 @@ namespace usdx
// FieldAsInteger). Also take care to write the types in
// upper-case letters although SQLite does not care about this -
// SQLiteTable3 is very sensitive in this regard.
- std::string sqlStatement;
+ std::wstring sqlStatement;
- sqlStatement = "CREATE TABLE IF NOT EXISTS [";
+ sqlStatement = L"CREATE TABLE IF NOT EXISTS [";
sqlStatement += usdx_scores;
- sqlStatement += "] (";
- sqlStatement += "[SongID] INTEGER NOT NULL, ";
- sqlStatement += "[Difficulty] INTEGER NOT NULL, ";
- sqlStatement += "[Player] TEXT NOT NULL, ";
- sqlStatement += "[Score] INTEGER NOT NULL, ";
- sqlStatement += "[Date] INTEGER NULL";
- sqlStatement += ");";
+ sqlStatement += L"] (";
+ sqlStatement += L"[SongID] INTEGER NOT NULL, ";
+ sqlStatement += L"[Difficulty] INTEGER NOT NULL, ";
+ sqlStatement += L"[Player] TEXT NOT NULL, ";
+ sqlStatement += L"[Score] INTEGER NOT NULL, ";
+ sqlStatement += L"[Date] INTEGER NULL";
+ sqlStatement += L");";
sqlite_exec(sqlStatement);
- sqlStatement = "CREATE TABLE IF NOT EXISTS [";
+ sqlStatement = L"CREATE TABLE IF NOT EXISTS [";
sqlStatement += usdx_songs;
- sqlStatement += "] (";
- sqlStatement += "[ID] INTEGER PRIMARY KEY, ";
- sqlStatement += "[Artist] TEXT NOT NULL, ";
- sqlStatement += "[Title] TEXT NOT NULL, ";
- sqlStatement += "[TimesPlayed] INTEGER NOT NULL, ";
- sqlStatement += "[Rating] INTEGER NULL";
- sqlStatement += ");";
+ sqlStatement += L"] (";
+ sqlStatement += L"[ID] INTEGER PRIMARY KEY, ";
+ sqlStatement += L"[Artist] TEXT NOT NULL, ";
+ sqlStatement += L"[Title] TEXT NOT NULL, ";
+ sqlStatement += L"[TimesPlayed] INTEGER NOT NULL, ";
+ sqlStatement += L"[Rating] INTEGER NULL";
+ sqlStatement += L");";
sqlite_exec(sqlStatement);
if (finalizeConversion) {
// convert data from 1.01 to 1.1
// part #2 - accomplishment
- LOG4CXX_INFO(log, "Outdated song database found - " <<
- "begin conversion from V1.01 to V1.1");
+ LOG4CXX_INFO(log, L"Outdated song database found - " <<
+ L"begin conversion from V1.01 to V1.1");
// insert old values into new db-schemes (/tables)
- sqlStatement = "INSERT INTO [";
+ sqlStatement = L"INSERT INTO [";
sqlStatement += usdx_scores;
- sqlStatement += "] SELECT [SongID], ";
- sqlStatement += "[Difficulty], [Player], ";
- sqlStatement += "[Score] FROM [us_scores_101];";
+ sqlStatement += L"] SELECT [SongID], ";
+ sqlStatement += L"[Difficulty], [Player], ";
+ sqlStatement += L"[Score] FROM [us_scores_101];";
sqlite_exec(sqlStatement);
- sqlStatement = "INSERT INTO [";
+ sqlStatement = L"INSERT INTO [";
sqlStatement += usdx_songs;
- sqlStatement += "] SELECT [ID], [Artist], ";
- sqlStatement += "[Title], [TimesPlayed], NULL ";
- sqlStatement += "FROM [us_songs_101];";
+ sqlStatement += L"] SELECT [ID], [Artist], ";
+ sqlStatement += L"[Title], [TimesPlayed], NULL ";
+ sqlStatement += L"FROM [us_songs_101];";
sqlite_exec(sqlStatement);
// now drop old tables
- sqlite_exec("DROP TABLE us_scores_101;");
- sqlite_exec("DROP TABLE us_songs_101;");
+ sqlite_exec(L"DROP TABLE us_scores_101;");
+ sqlite_exec(L"DROP TABLE us_songs_101;");
}
// add column rating to cUS_Songs
// just for users of nightly builds and developers!
- if (! sqlite_table_contains_column(usdx_songs, "Rating")) {
- LOG4CXX_INFO(log, "Outdated song database found - " <<
- "adding column rating to '" <<
- usdx_songs << "'");
+ if (! sqlite_table_contains_column(usdx_songs, L"Rating")) {
+ LOG4CXX_INFO(log, L"Outdated song database found - " <<
+ L"adding column rating to '" <<
+ usdx_songs << L"'");
- sqlite_exec("ALTER TABLE [" + usdx_songs +
- "] ADD COLUMN [Rating] INTEGER NULL;");
+ sqlite_exec(L"ALTER TABLE [" + usdx_songs +
+ L"] ADD COLUMN [Rating] INTEGER NULL;");
}
//add column date to cUS-Scores
- if (! sqlite_table_contains_column(usdx_scores, "Date")) {
- LOG4CXX_INFO(log, "Outdated score database found - " <<
- "adding column date to '" <<
- usdx_scores << "'");
+ if (! sqlite_table_contains_column(usdx_scores, L"Date")) {
+ LOG4CXX_INFO(log, L"Outdated score database found - " <<
+ L"adding column date to '" <<
+ usdx_scores << L"'");
- sqlite_exec("ALTER TABLE [" + usdx_scores +
- "] ADD COLUMN [Date] INTEGER NULL;");
+ sqlite_exec(L"ALTER TABLE [" + usdx_scores +
+ L"] ADD COLUMN [Date] INTEGER NULL;");
}
}
diff --git a/src/base/stats_database.hpp b/src/base/stats_database.hpp
index 8ca3ff9c..6e7f0d01 100644
--- a/src/base/stats_database.hpp
+++ b/src/base/stats_database.hpp
@@ -61,9 +61,9 @@ namespace usdx
*/
static char* format_date(char* time, size_t max, time_t timestamp);
- static const std::string usdx_scores;
- static const std::string usdx_songs;
- static const std::string usdx_statistics_info;
+ static const std::wstring usdx_scores;
+ static const std::wstring usdx_songs;
+ static const std::wstring usdx_statistics_info;
#ifdef STAT_DATABASE_TEST
diff --git a/src/utils/file.cpp b/src/utils/file.cpp
index 3aeb4fc5..a7fc87e8 100644
--- a/src/utils/file.cpp
+++ b/src/utils/file.cpp
@@ -25,11 +25,18 @@
*/
#include "file.hpp"
+#include <string>
+#include <locale>
+
+#include <boost/program_options/detail/utf8_codecvt_facet.hpp>
namespace usdx
{
- File::File(const std::string& filename) : file(filename.c_str(), std::ifstream::in)
+ File::File(const std::string& filename) : file(filename.c_str(), std::wifstream::in)
{
+ std::locale global_loc = std::locale();
+ std::locale loc(global_loc, new boost::program_options::detail::utf8_codecvt_facet());
+ file.imbue(loc);
}
File::~File(void)
@@ -37,7 +44,7 @@ namespace usdx
file.close();
}
- std::istream &File::stream(void)
+ std::wistream &File::stream(void)
{
return file;
}
diff --git a/src/utils/file.hpp b/src/utils/file.hpp
index ed1ec14e..d08d7eb5 100644
--- a/src/utils/file.hpp
+++ b/src/utils/file.hpp
@@ -35,12 +35,12 @@ namespace usdx
class File
{
private:
- std::ifstream file;
+ std::wifstream file;
public:
File(const std::string& filename);
virtual ~File(void);
- std::istream &stream(void);
+ std::wistream &stream(void);
};
};
diff --git a/src/utils/locale_independent_float.cpp b/src/utils/locale_independent_float.cpp
index e0015cee..606ec998 100644
--- a/src/utils/locale_independent_float.cpp
+++ b/src/utils/locale_independent_float.cpp
@@ -38,7 +38,7 @@ namespace usdx
{
}
- LocaleIndependentFloat::LocaleIndependentFloat(std::string& value)
+ LocaleIndependentFloat::LocaleIndependentFloat(std::wstring& value)
{
this->operator=(value);
}
@@ -65,27 +65,27 @@ namespace usdx
return *this;
}
- LocaleIndependentFloat& LocaleIndependentFloat::operator= (std::string& value)
+ LocaleIndependentFloat& LocaleIndependentFloat::operator= (std::wstring& value)
{
- std::size_t found = value.find(',');
- if (found != std::string::npos) {
- value[found] = '.';
+ std::size_t found = value.find(L',');
+ if (found != std::wstring::npos) {
+ value[found] = L'.';
}
- std::istringstream str(value);
+ std::wistringstream str(value);
str >> this->value;
return *this;
}
- std::istream& operator>> (std::istream& is, LocaleIndependentFloat& float_value)
+ std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat& float_value)
{
return is >> &float_value;
}
- std::istream& operator>> (std::istream& is, LocaleIndependentFloat* float_value)
+ std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat* float_value)
{
- std::string str_value;
+ std::wstring str_value;
is >> str_value;
*float_value = str_value;
diff --git a/src/utils/locale_independent_float.hpp b/src/utils/locale_independent_float.hpp
index 82801868..f3674695 100644
--- a/src/utils/locale_independent_float.hpp
+++ b/src/utils/locale_independent_float.hpp
@@ -37,7 +37,7 @@ namespace usdx
float value;
public:
LocaleIndependentFloat();
- LocaleIndependentFloat(std::string& value);
+ LocaleIndependentFloat(std::wstring& value);
virtual ~LocaleIndependentFloat();
@@ -46,11 +46,11 @@ namespace usdx
LocaleIndependentFloat& operator= (const LocaleIndependentFloat& value);
LocaleIndependentFloat& operator= (const float& vaule);
- LocaleIndependentFloat& operator= (std::string& vaule);
+ LocaleIndependentFloat& operator= (std::wstring& vaule);
};
- std::istream& operator>> (std::istream& is, LocaleIndependentFloat& float_value);
- std::istream& operator>> (std::istream& is, LocaleIndependentFloat* float_value);
+ std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat& float_value);
+ std::wistream& operator>> (std::wistream& is, LocaleIndependentFloat* float_value);
};
diff --git a/test/Makefile b/test/Makefile
index c9360cfe..a9dd4e9b 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,5 +1,5 @@
CXXFLAGS:=-Wall -Werror -lcppunit -I../src/ -I../src/base -I../src/menu -I../src/media -I../src/screens -g
-LDFLAGS:=-lsqlite3 -lSDL -llog4cxx
+LDFLAGS:=-lsqlite3 -lSDL -llog4cxx -lboost_program_options-mt
PROJECT:=usdx-tests
TARGET:=$(PROJECT)
diff --git a/test/base/songloading.cpp b/test/base/songloading.cpp
index e8fd1bde..9f7fcb47 100644
--- a/test/base/songloading.cpp
+++ b/test/base/songloading.cpp
@@ -62,22 +62,23 @@ namespace usdx
void testSongloadingTxtHeader()
{
Song *song = Songloader::get_instance()->load_header("testdata/testsong_correct.txt");
-
- CPPUNIT_ASSERT( "Test Ärtist" == song->get_artist() );
- CPPUNIT_ASSERT( "Test Title" == song->get_title() );
- CPPUNIT_ASSERT( "Test.mp3" == song->get_mp3() );
+
+ CPPUNIT_ASSERT( L"Test Ärtist" == song->get_artist() );
+ CPPUNIT_ASSERT( 11 == song->get_artist().length() );
+ CPPUNIT_ASSERT( L"Test Title" == song->get_title() );
+ CPPUNIT_ASSERT( L"Test.mp3" == song->get_mp3() );
CPPUNIT_ASSERT( 42.23f == song->get_bpm(0) );
- CPPUNIT_ASSERT( 42.23f == song->get_bpm(10) );
+ CPPUNIT_ASSERT( 42.23f == song->get_bpm(10) );
CPPUNIT_ASSERT( 10 == song->get_gap() );
- CPPUNIT_ASSERT( "Test[BG].jpg" == song->get_background() );
- CPPUNIT_ASSERT( "Test[CO].jpg" == song->get_cover() );
- CPPUNIT_ASSERT( "Test Genre" == song->get_genre() );
+ CPPUNIT_ASSERT( L"Test[BG].jpg" == song->get_background() );
+ CPPUNIT_ASSERT( L"Test[CO].jpg" == song->get_cover() );
+ CPPUNIT_ASSERT( L"Test Genre" == song->get_genre() );
CPPUNIT_ASSERT( false == song->get_relative() );
- CPPUNIT_ASSERT( "Cpp" == song->get_language() );
- CPPUNIT_ASSERT( "Test[VD#12,3].mkv" == song->get_video() );
+ CPPUNIT_ASSERT( L"Cpp" == song->get_language() );
+ CPPUNIT_ASSERT( L"Test[VD#12,3].mkv" == song->get_video() );
CPPUNIT_ASSERT( 12.3f == song->get_video_gap() );
CPPUNIT_ASSERT( 0 == song->get_start() );
- CPPUNIT_ASSERT( "Test0r" == song->get_creator() );
+ CPPUNIT_ASSERT( L"Test0r" == song->get_creator() );
CPPUNIT_ASSERT( 7 == song->get_year() );
CPPUNIT_ASSERT( 666 == song->get_stop() );
CPPUNIT_ASSERT( 0 == song->get_notes_gap() );
@@ -131,8 +132,6 @@ namespace usdx
Songloader::get_instance()->
load_header("testdata/testsong_missing_bpm.txt");
}
-
-
};
CPPUNIT_TEST_SUITE_REGISTRATION(SongloadingTest);