1818
1919namespace lcf {
2020
21- std::unique_ptr<lcf::rpg::TreeMap> LMT_Reader::Load (const std::string& filename, const std::string& encoding) {
22- std::ifstream stream (filename. c_str ( ), std::ios::binary);
21+ std::unique_ptr<lcf::rpg::TreeMap> LMT_Reader::Load (StringView filename, StringView encoding) {
22+ std::ifstream stream (ToString (filename ), std::ios::binary);
2323 if (!stream.is_open ()) {
24- fprintf (stderr, " Failed to open LMT file `%s' for reading : %s\n " , filename.c_str (), strerror (errno));
24+ fprintf (stderr, " Failed to open LMT file `%s' for reading : %s\n " , ToString ( filename) .c_str (), strerror (errno));
2525 return nullptr ;
2626 }
2727 return LMT_Reader::Load (stream, encoding);
2828}
2929
30- bool LMT_Reader::Save (const std::string& filename, const lcf::rpg::TreeMap& tmap, EngineVersion engine, const std::string& encoding, SaveOpt opt) {
31- std::ofstream stream (filename. c_str ( ), std::ios::binary);
30+ bool LMT_Reader::Save (StringView filename, const lcf::rpg::TreeMap& tmap, EngineVersion engine, StringView encoding, SaveOpt opt) {
31+ std::ofstream stream (ToString (filename ), std::ios::binary);
3232 if (!stream.is_open ()) {
33- fprintf (stderr, " Failed to open LMT file `%s' for writing : %s\n " , filename.c_str (), strerror (errno));
33+ fprintf (stderr, " Failed to open LMT file `%s' for writing : %s\n " , ToString ( filename) .c_str (), strerror (errno));
3434 return false ;
3535 }
3636 return LMT_Reader::Save (stream, tmap, engine, encoding, opt);
3737}
3838
39- bool LMT_Reader::SaveXml (const std::string& filename, const lcf::rpg::TreeMap& tmap, EngineVersion engine) {
40- std::ofstream stream (filename. c_str ( ), std::ios::binary);
39+ bool LMT_Reader::SaveXml (StringView filename, const lcf::rpg::TreeMap& tmap, EngineVersion engine) {
40+ std::ofstream stream (ToString (filename ), std::ios::binary);
4141 if (!stream.is_open ()) {
42- fprintf (stderr, " Failed to open LMT XML file `%s' for writing : %s\n " , filename.c_str (), strerror (errno));
42+ fprintf (stderr, " Failed to open LMT XML file `%s' for writing : %s\n " , ToString ( filename) .c_str (), strerror (errno));
4343 return false ;
4444 }
4545 return LMT_Reader::SaveXml (stream, tmap, engine);
4646}
4747
48- std::unique_ptr<lcf::rpg::TreeMap> LMT_Reader::LoadXml (const std::string& filename) {
49- std::ifstream stream (filename. c_str ( ), std::ios::binary);
48+ std::unique_ptr<lcf::rpg::TreeMap> LMT_Reader::LoadXml (StringView filename) {
49+ std::ifstream stream (ToString (filename ), std::ios::binary);
5050 if (!stream.is_open ()) {
51- fprintf (stderr, " Failed to open LMT XML file `%s' for reading : %s\n " , filename.c_str (), strerror (errno));
51+ fprintf (stderr, " Failed to open LMT XML file `%s' for reading : %s\n " , ToString ( filename) .c_str (), strerror (errno));
5252 return nullptr ;
5353 }
5454 return LMT_Reader::LoadXml (stream);
5555}
5656
57- std::unique_ptr<lcf::rpg::TreeMap> LMT_Reader::Load (std::istream& filestream, const std::string & encoding) {
58- LcfReader reader (filestream, encoding);
57+ std::unique_ptr<lcf::rpg::TreeMap> LMT_Reader::Load (std::istream& filestream, StringView encoding) {
58+ LcfReader reader (filestream, ToString ( encoding) );
5959 if (!reader.IsOk ()) {
6060 LcfReader::SetError (" Couldn't parse map tree file.\n " );
6161 return nullptr ;
@@ -75,8 +75,8 @@ std::unique_ptr<lcf::rpg::TreeMap> LMT_Reader::Load(std::istream& filestream, co
7575 return tmap;
7676}
7777
78- bool LMT_Reader::Save (std::ostream& filestream, const lcf::rpg::TreeMap& tmap, EngineVersion engine, const std::string & encoding, SaveOpt opt) {
79- LcfWriter writer (filestream, engine, encoding);
78+ bool LMT_Reader::Save (std::ostream& filestream, const lcf::rpg::TreeMap& tmap, EngineVersion engine, StringView encoding, SaveOpt opt) {
79+ LcfWriter writer (filestream, engine, ToString ( encoding) );
8080 if (!writer.IsOk ()) {
8181 LcfReader::SetError (" Couldn't parse map tree file.\n " );
8282 return false ;
0 commit comments