Skip to content

Commit

Permalink
Remove wstring
Browse files Browse the repository at this point in the history
  • Loading branch information
VioletXF committed May 21, 2024
1 parent 64dba9d commit 7a233d4
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 161 deletions.
26 changes: 11 additions & 15 deletions example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,12 @@ void parallel_for(int n, std::function<void(int start, int end)> f)
}
}

std::string ws2s(const std::wstring &wstr)
{
return std::string().assign(wstr.begin(), wstr.end());
}




void parse_single_metadata(const std::filesystem::path &bmsFile)
{
std::wstring wpath = bmsFile.wstring();
bms_parser::Parser parser;
bms_parser::Chart *chart;
std::atomic_bool cancel = false;
Expand All @@ -81,11 +77,11 @@ void parse_single_metadata(const std::filesystem::path &bmsFile)
std::cout << "Folder:" << chart->Meta.Folder.string() << std::endl;
std::cout << "MD5: " << chart->Meta.MD5 << std::endl;
std::cout << "SHA256: " << chart->Meta.SHA256 << std::endl;
std::cout << "Title: " << ws2s(chart->Meta.Title) << std::endl;
std::cout << "SubTitle: " << ws2s(chart->Meta.SubTitle) << std::endl;
std::cout << "Artist: " << ws2s(chart->Meta.Artist) << std::endl;
std::cout << "SubArtist: " << ws2s(chart->Meta.SubArtist) << std::endl;
std::cout << "Genre: " << ws2s(chart->Meta.Genre) << std::endl;
std::cout << "Title: " << chart->Meta.Title << std::endl;
std::cout << "SubTitle: " << chart->Meta.SubTitle << std::endl;
std::cout << "Artist: " << chart->Meta.Artist << std::endl;
std::cout << "SubArtist: " << chart->Meta.SubArtist << std::endl;
std::cout << "Genre: " << chart->Meta.Genre << std::endl;
std::cout << "PlayLevel: " << chart->Meta.PlayLevel << std::endl;
std::cout << "Total: " << chart->Meta.Total << std::endl;
std::cout << "StageFile: " << chart->Meta.StageFile.string() << std::endl;
Expand Down Expand Up @@ -397,11 +393,11 @@ bool construct_folder_db(const std::filesystem::path &path)
sqlite3_bind_text(stmt, 1, chart->Meta.BmsPath.string().c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 2, (chart->Meta.MD5).c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 3, (chart->Meta.SHA256).c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 4, ws2s(chart->Meta.Title).c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 5, ws2s(chart->Meta.SubTitle).c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 6, ws2s(chart->Meta.Genre).c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 7, ws2s(chart->Meta.Artist).c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 8, ws2s(chart->Meta.SubArtist).c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 4, chart->Meta.Title.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 5, chart->Meta.SubTitle.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 6, chart->Meta.Genre.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 7, chart->Meta.Artist.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 8, chart->Meta.SubArtist.c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 9, chart->Meta.Folder.string().c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 10, chart->Meta.StageFile.string().c_str(), -1, SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 11, chart->Meta.Banner.string().c_str(), -1, SQLITE_TRANSIENT);
Expand Down
14 changes: 7 additions & 7 deletions src/Chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ namespace bms_parser
std::string MD5;
std::filesystem::path BmsPath;
std::filesystem::path Folder;
std::wstring Artist = L"";
std::wstring SubArtist = L"";
std::string Artist = "";
std::string SubArtist = "";
double Bpm = 0;
std::wstring Genre = L"";
std::wstring Title = L"";
std::wstring SubTitle = L"";
std::string Genre = "";
std::string Title = "";
std::string SubTitle = "";
int Rank = 3;
double Total = 100;
long long PlayLength = 0; // Timing of the last playable note, in microseconds
Expand Down Expand Up @@ -106,7 +106,7 @@ namespace bms_parser
~Chart();
ChartMeta Meta;
std::vector<Measure *> Measures;
std::unordered_map<int, std::wstring> WavTable;
std::unordered_map<int, std::wstring> BmpTable;
std::unordered_map<int, std::string> WavTable;
std::unordered_map<int, std::string> BmpTable;
};
}
Loading

0 comments on commit 7a233d4

Please sign in to comment.