@@ -22,44 +22,44 @@ void LDB_Reader::PrepareSave(rpg::Database& db) {
2222 ++db.system .save_count ;
2323}
2424
25- std::unique_ptr<lcf::rpg::Database> LDB_Reader::Load (const std::string& filename, const std::string& encoding) {
26- std::ifstream stream (filename. c_str ( ), std::ios::binary);
25+ std::unique_ptr<lcf::rpg::Database> LDB_Reader::Load (StringView filename, StringView encoding) {
26+ std::ifstream stream (ToString (filename ), std::ios::binary);
2727 if (!stream.is_open ()) {
28- fprintf (stderr, " Failed to open LDB file `%s' for reading : %s\n " , filename.c_str (), strerror (errno));
28+ fprintf (stderr, " Failed to open LDB file `%s' for reading : %s\n " , ToString ( filename) .c_str (), strerror (errno));
2929 return nullptr ;
3030 }
3131 return LDB_Reader::Load (stream, encoding);
3232}
3333
34- bool LDB_Reader::Save (const std::string& filename, const lcf::rpg::Database& db, const std::string& encoding, SaveOpt opt) {
35- std::ofstream stream (filename. c_str ( ), std::ios::binary);
34+ bool LDB_Reader::Save (StringView filename, const lcf::rpg::Database& db, StringView encoding, SaveOpt opt) {
35+ std::ofstream stream (ToString (filename ), std::ios::binary);
3636 if (!stream.is_open ()) {
37- fprintf (stderr, " Failed to open LDB file `%s' for writing : %s\n " , filename.c_str (), strerror (errno));
37+ fprintf (stderr, " Failed to open LDB file `%s' for writing : %s\n " , ToString ( filename) .c_str (), strerror (errno));
3838 return false ;
3939 }
4040 return LDB_Reader::Save (stream, db, encoding, opt);
4141}
4242
43- bool LDB_Reader::SaveXml (const std::string& filename, const lcf::rpg::Database& db) {
44- std::ofstream stream (filename. c_str ( ), std::ios::binary);
43+ bool LDB_Reader::SaveXml (StringView filename, const lcf::rpg::Database& db) {
44+ std::ofstream stream (ToString (filename ), std::ios::binary);
4545 if (!stream.is_open ()) {
46- fprintf (stderr, " Failed to open LDB XML file `%s' for writing : %s\n " , filename.c_str (), strerror (errno));
46+ fprintf (stderr, " Failed to open LDB XML file `%s' for writing : %s\n " , ToString ( filename) .c_str (), strerror (errno));
4747 return false ;
4848 }
4949 return LDB_Reader::SaveXml (stream, db);
5050}
5151
52- std::unique_ptr<lcf::rpg::Database> LDB_Reader::LoadXml (const std::string& filename) {
53- std::ifstream stream (filename. c_str ( ), std::ios::binary);
52+ std::unique_ptr<lcf::rpg::Database> LDB_Reader::LoadXml (StringView filename) {
53+ std::ifstream stream (ToString (filename ), std::ios::binary);
5454 if (!stream.is_open ()) {
55- fprintf (stderr, " Failed to open LDB XML file `%s' for reading : %s\n " , filename.c_str (), strerror (errno));
55+ fprintf (stderr, " Failed to open LDB XML file `%s' for reading : %s\n " , ToString ( filename) .c_str (), strerror (errno));
5656 return nullptr ;
5757 }
5858 return LDB_Reader::LoadXml (stream);
5959}
6060
61- std::unique_ptr<lcf::rpg::Database> LDB_Reader::Load (std::istream& filestream, const std::string& encoding) {
62- LcfReader reader (filestream, encoding);
61+ std::unique_ptr<lcf::rpg::Database> LDB_Reader::Load (std::istream& filestream, StringView encoding) {
62+ LcfReader reader (filestream, ToString ( encoding) );
6363 if (!reader.IsOk ()) {
6464 LcfReader::SetError (" Couldn't parse database file.\n " );
6565 return nullptr ;
@@ -87,9 +87,9 @@ std::unique_ptr<lcf::rpg::Database> LDB_Reader::Load(std::istream& filestream, c
8787 return db;
8888}
8989
90- bool LDB_Reader::Save (std::ostream& filestream, const lcf::rpg::Database& db, const std::string& encoding, SaveOpt opt) {
90+ bool LDB_Reader::Save (std::ostream& filestream, const lcf::rpg::Database& db, StringView encoding, SaveOpt opt) {
9191 const auto engine = GetEngineVersion (db);
92- LcfWriter writer (filestream, engine, encoding);
92+ LcfWriter writer (filestream, engine, ToString ( encoding) );
9393 if (!writer.IsOk ()) {
9494 LcfReader::SetError (" Couldn't parse database file.\n " );
9595 return false ;
0 commit comments