You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
991 B
C++
51 lines
991 B
C++
#ifndef NBTMODIFIER_ABSTRACTTAG_H
|
|
#define NBTMODIFIER_ABSTRACTTAG_H
|
|
|
|
#include <QtGlobal>
|
|
|
|
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
|