metaforce/DataSpec/DNACommon/ELSC.cpp

52 lines
1.6 KiB
C++
Raw Normal View History

#include "DataSpec/DNACommon/ELSC.hpp"
#include "DataSpec/DNACommon/PAK.hpp"
2016-03-08 20:49:44 -08:00
2018-12-07 21:30:43 -08:00
namespace DataSpec::DNAParticle {
2018-02-21 23:24:51 -08:00
template struct PPImpl<_ELSM<UniqueID32>>;
template struct PPImpl<_ELSM<UniqueID64>>;
2016-03-08 20:49:44 -08:00
AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_ELSM<UniqueID32>>)
AT_SUBSPECIALIZE_DNA_YAML(PPImpl<_ELSM<UniqueID64>>)
2018-02-21 23:24:51 -08:00
template <>
2019-10-01 00:38:03 -07:00
std::string_view ELSM<UniqueID32>::DNAType() {
2021-04-10 01:42:06 -07:00
return "ELSM<UniqueID32>"sv;
2018-12-07 21:30:43 -08:00
}
2018-02-21 23:24:51 -08:00
template <>
2019-10-01 00:38:03 -07:00
std::string_view ELSM<UniqueID64>::DNAType() {
2021-04-10 01:42:06 -07:00
return "ELSM<UniqueID64>"sv;
2018-12-07 21:30:43 -08:00
}
2018-02-21 23:24:51 -08:00
2016-03-08 20:49:44 -08:00
template <class IDType>
2018-12-07 21:30:43 -08:00
bool ExtractELSM(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) {
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen()) {
ELSM<IDType> elsm;
elsm.read(rs);
athena::io::ToYAMLStream(elsm, writer);
return true;
}
return false;
2016-03-08 20:49:44 -08:00
}
template bool ExtractELSM<UniqueID32>(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
template bool ExtractELSM<UniqueID64>(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
template <class IDType>
2018-12-07 21:30:43 -08:00
bool WriteELSM(const ELSM<IDType>& elsm, const hecl::ProjectPath& outPath) {
athena::io::FileWriter w(outPath.getAbsolutePath(), true, false);
if (w.hasError())
return false;
elsm.write(w);
int64_t rem = w.position() % 32;
if (rem)
for (int64_t i = 0; i < 32 - rem; ++i)
w.writeUByte(0xff);
return true;
2016-03-08 20:49:44 -08:00
}
template bool WriteELSM<UniqueID32>(const ELSM<UniqueID32>& gpsm, const hecl::ProjectPath& outPath);
template bool WriteELSM<UniqueID64>(const ELSM<UniqueID64>& gpsm, const hecl::ProjectPath& outPath);
2018-12-07 21:30:43 -08:00
} // namespace DataSpec::DNAParticle