diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-01-28 11:32:39 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-01-05 17:17:46 +0100 |
commit | 271c7cabf5e16a1afed560b9f707b3955b3ec725 (patch) | |
tree | 026b6678c6973205e32698af795830d58c5121d6 /src/base/stats_database.cpp | |
parent | 2adaea29500b412c342838e22df2f8b4ac2eb02d (diff) | |
download | usdx-271c7cabf5e16a1afed560b9f707b3955b3ec725.tar.gz usdx-271c7cabf5e16a1afed560b9f707b3955b3ec725.tar.xz usdx-271c7cabf5e16a1afed560b9f707b3955b3ec725.zip |
converted all strings and chars to wstrings and wchar_ts
all strings with displayable content are now the wide strings for
proper
unicode handling
added boost dependency for proper reading unicode from files
Diffstat (limited to '')
-rw-r--r-- | src/base/stats_database.cpp | 114 |
1 files changed, 57 insertions, 57 deletions
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;"); } } |