15#include "lcf/lmu/reader.h"
16#include "lcf/lmu/chunks.h"
17#include "lcf/reader_lcf.h"
18#include "lcf/reader_util.h"
23void LMU_Reader::PrepareSave(rpg::Map& map) {
27std::unique_ptr<rpg::Map> LMU_Reader::Load(StringView filename, StringView encoding) {
36bool LMU_Reader::Save(StringView filename,
const rpg::Map& save, EngineVersion engine, StringView encoding, SaveOpt opt) {
45bool LMU_Reader::SaveXml(StringView filename,
const rpg::Map& save, EngineVersion engine) {
54std::unique_ptr<rpg::Map> LMU_Reader::LoadXml(StringView filename) {
60 return LMU_Reader::LoadXml(
stream);
63std::unique_ptr<rpg::Map> LMU_Reader::Load(std::istream& filestream, StringView encoding) {
66 LcfReader::SetError(
"Couldn't parse map file.\n");
67 return std::unique_ptr<rpg::Map>();
71 if (
header.length() != 10) {
72 LcfReader::SetError(
"This is not a valid RPG2000 map.\n");
73 return std::unique_ptr<rpg::Map>();
75 if (
header !=
"LcfMapUnit") {
76 fprintf(
stderr,
"Warning: This header is not LcfMapUnit and might not be a valid RPG2000 map.\n");
79 auto map = std::make_unique<rpg::Map>();
80 map->lmu_header = std::move(
header);
85bool LMU_Reader::Save(std::ostream& filestream,
const rpg::Map& map, EngineVersion engine, StringView encoding, SaveOpt opt) {
88 LcfReader::SetError(
"Couldn't parse map file.\n");
92 if ( map.lmu_header.empty() || !
bool(
opt & SaveOpt::ePreserveHeader)) {
104bool LMU_Reader::SaveXml(std::ostream& filestream,
const rpg::Map& map, EngineVersion engine) {
107 LcfReader::SetError(
"Couldn't parse map file.\n");
110 writer.BeginElement(
"LMU");
116std::unique_ptr<rpg::Map> LMU_Reader::LoadXml(std::istream& filestream) {
119 LcfReader::SetError(
"Couldn't parse map file.\n");
120 return std::unique_ptr<rpg::Map>();
123 auto map = std::make_unique<rpg::Map>();
RootXmlHandler(S &ref, const char *const name)
static void WriteXml(const S &obj, XmlWriter &stream)
static void WriteLcf(const S &obj, LcfWriter &stream)
static void ReadLcf(S &obj, LcfReader &stream)