#ifndef COMPONENTS_ESM_ESMBRIDGE #define COMPONENTS_ESM_ESMBRIDGE #include #include #include #include #include namespace ESM4 { struct Cell; } namespace ESM { struct Cell; struct CellId; struct RefId; class CellVariant { protected: std::variant mVariant; public: explicit CellVariant(const ESM4::Cell& cell) : mVariant(&cell) { } explicit CellVariant(const ESM::Cell& cell) : mVariant(&cell) { } bool isEsm4() const { return std::holds_alternative(mVariant); } const ESM4::Cell& getEsm4() const; const ESM::Cell& getEsm3() const; template auto visit(F&& f) const { return std::visit(f, mVariant); } template auto visit(F&& f) { return std::visit(f, mVariant); } template auto visit(F&& f, const CellVariant& v2) const { return std::visit(f, mVariant, v2.mVariant); } }; struct ReferenceVariant { std::variant mVariant; explicit ReferenceVariant(const ESM4::Reference& ref) : mVariant(ref) { } explicit ReferenceVariant(const ESM::CellRef& ref) : mVariant(ref) { } bool isESM4() const { return std::holds_alternative(mVariant); } const ESM::CellRef& getEsm3() const { return std::get(mVariant); } const ESM4::Reference& getEsm4() const { return std::get(mVariant); } ESM::CellRef& getEsm3() { return std::get(mVariant); } ESM4::Reference& getEsm4() { return std::get(mVariant); } }; } namespace std { template auto visit(F&& f, const ESM::CellVariant& v) { return v.visit(f); } template auto visit(F&& f, ESM::CellVariant& v) { return v.visit(f); } template auto visit(F&& f, const ESM::CellVariant& v1, const ESM::CellVariant& v2) { return v1.visit(f, v2); } } #endif