#ifndef NBTMODIFIER_ABSTRACTTAG_H #define NBTMODIFIER_ABSTRACTTAG_H #include class QDataStream; /** * Interface for all NBT tags */ class AbstractTag { public: const quint8 id() const; static AbstractTag *fromData(QDataStream &data, bool *ok = nullptr); QByteArray toData(bool *ok = nullptr); protected: /** * Create a new tag * * @param id */ explicit AbstractTag(const quint8 id); /** * Read a tag from a data stream * * @param data The data stream * * @return True if read is success, otherwise false */ virtual const bool readFromData(QDataStream &data) = 0; /** * Write a tag to a data stream * * @param data The data stream * * @return True if write is success, otherwise false */ virtual const bool writeToData(QDataStream &data) const = 0; private: /** * The tag's ID */ const quint8 m_id; }; #endif //NBTMODIFIER_ABSTRACTTAG_H