Hexes/blockvalue.h

72 lines
2.1 KiB
C
Raw Permalink Normal View History

2024-10-28 19:16:00 -04:00
#ifndef BLOCKVALUE_H
#define BLOCKVALUE_H
#include <QObject>
#include <QVariant>
2024-11-02 19:19:53 -04:00
/*
* BLOCK_TYPE enum
*
* Value types that the BlockVlaue class can
* ingest and convert to/from.
*/
2024-10-28 19:16:00 -04:00
enum BLOCK_TYPE {
BLOCK_TYPE_NONE = 0,
BLOCK_TYPE_INT8 = 1,
BLOCK_TYPE_UINT8 = 2,
BLOCK_TYPE_INT16 = 3,
BLOCK_TYPE_UINT16 = 4,
BLOCK_TYPE_INT32 = 5,
BLOCK_TYPE_UINT32 = 6,
BLOCK_TYPE_INT64 = 7,
BLOCK_TYPE_UINT64 = 8,
};
2024-11-02 19:19:53 -04:00
/*
* BlockValue class
*
* Represents a variable value resulting from
* parsing a block of data from the input.
*
* Constructed preferrably with a name and value.
*/
2024-10-28 19:16:00 -04:00
2024-11-02 19:19:53 -04:00
class BlockValue
{
2024-10-28 19:16:00 -04:00
2024-11-02 19:19:53 -04:00
public: /*** PUBLIC MEMBERS ***/
/* Block Value Constructors */
BlockValue(); // Default
BlockValue(const BlockValue &aBlockVal); // Copy
BlockValue(const QString aName); // Name
BlockValue(const QString aName, qint8 aVal); // Name + int8
BlockValue(const QString aName, quint8 aVal); // Name + uint8
BlockValue(const QString aName, qint16 aVal); // Name + int16
BlockValue(const QString aName, quint16 aVal); // Name + uint16
BlockValue(const QString aName, qint32 aVal); // Name + int32
BlockValue(const QString aName, quint32 aVal); // Name + uint32
BlockValue(const QString aName, qint64 aVal); // Name + int64
BlockValue(const QString aName, quint64 aVal); // Name + uint64
2024-10-28 19:16:00 -04:00
2024-11-02 19:19:53 -04:00
/* Block Value Operators */
BlockValue &operator=(const BlockValue &aBlockVal); // = operator
2024-10-28 19:16:00 -04:00
2024-11-02 19:19:53 -04:00
/* Setters and Getters */
void SetName(const QString aName); // Set Name
QString Name() const; // Get Name
void SetBlockType(BLOCK_TYPE aBlockType); // Set Block Value Type
BLOCK_TYPE BlockType() const; // Get Block Value Type
2024-10-28 19:16:00 -04:00
2024-11-02 19:19:53 -04:00
/* Data Access Methods */
int ToInt() const; // Convert to integer
QString ToString() const; // Convert to string
QVariant ToVariant() const; // Return as raw data
2024-10-28 19:16:00 -04:00
2024-11-02 19:19:53 -04:00
private: /*** PRIVATE MEMBERS ***/
2024-10-28 19:16:00 -04:00
QString pName;
BLOCK_TYPE pBlockType;
QVariant pData;
};
#endif // BLOCKVALUE_H