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.
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
#ifndef NBTMODIFIER_ABSTRACTTAG_H
|
|
#define NBTMODIFIER_ABSTRACTTAG_H
|
|
|
|
#include <QtGlobal>
|
|
|
|
class QDataStream;
|
|
|
|
/**
|
|
* Interface for all NBT tags
|
|
*/
|
|
class AbstractTag {
|
|
public:
|
|
virtual inline ~AbstractTag () {};
|
|
|
|
const quint8 id () const;
|
|
|
|
static const quint8 extractId (const QByteArray &data);
|
|
static AbstractTag *extractEmptyTag (const QByteArray &data);
|
|
|
|
friend QDataStream &operator << (QDataStream &data, const AbstractTag &tag);
|
|
friend QDataStream &operator >> (QDataStream &data, AbstractTag &tag);
|
|
|
|
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 void 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 void writeToData (QDataStream &data) const = 0;
|
|
|
|
private:
|
|
/**
|
|
* The tag's ID
|
|
*/
|
|
const quint8 m_id;
|
|
};
|
|
|
|
#endif //NBTMODIFIER_ABSTRACTTAG_H
|