#ifndef OPENMW_ESMTOOL_RECORD_H #define OPENMW_ESMTOOL_RECORD_H #include #include #include #include #include namespace ESM { class ESMReader; class ESMWriter; } namespace EsmTool { template class Record; class RecordBase { protected: std::string mId; uint32_t mFlags; ESM::NAME mType; bool mPrintPlain; public: RecordBase() : mFlags(0) , mPrintPlain(false) { } virtual ~RecordBase() = default; virtual std::string getId() const = 0; uint32_t getFlags() const { return mFlags; } void setFlags(uint32_t flags) { mFlags = flags; } ESM::NAME getType() const { return mType; } void setPrintPlain(bool plain) { mPrintPlain = plain; } virtual void load(ESM::ESMReader& esm) = 0; virtual void save(ESM::ESMWriter& esm) = 0; virtual void print() = 0; static std::unique_ptr create(ESM::NAME type); // just make it a bit shorter template Record* cast() { return static_cast*>(this); } }; struct CellState { ESM::CellState mCellState; ESM::FogState mFogState; void load(ESM::ESMReader& reader, bool& deleted); void save(ESM::ESMWriter& /*writer*/, bool /*deleted*/) {} }; template class Record : public RecordBase { T mData; bool mIsDeleted; public: Record() : mIsDeleted(false) { } std::string getId() const override { return mData.mId.toDebugString(); } T& get() { return mData; } void save(ESM::ESMWriter& esm) override { mData.save(esm, mIsDeleted); } void load(ESM::ESMReader& esm) override { mData.load(esm, mIsDeleted); } void print() override; }; template <> std::string Record::getId() const; template <> std::string Record::getId() const; template <> std::string Record::getId() const; template <> std::string Record::getId() const; template <> std::string Record::getId() const; template <> std::string Record::getId() const; template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); template <> void Record::print(); } #endif