-
Notifications
You must be signed in to change notification settings - Fork 0
/
chunk.h
101 lines (69 loc) · 2.06 KB
/
chunk.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef CHUNK_H
#define CHUNK_H
#include <QtCore>
#define ERROR_MACRO(message,retVal) { \
errorsList->append(message); \
qDebug() << message; \
return retVal; \
}
namespace RiffChunk {
class Chunk;
typedef QVector<Chunk*> ChunkList;
typedef int FOURCC; // 32-bit number
typedef unsigned long myDWORD;
typedef char Byte;
typedef QVector<char> ByteBuffer;
// typedef ByteBuffer::iterator BBIterator;
class Chunk
{
private:
QFile* file;
QStringList* errorsList;
FOURCC ckID;
myDWORD ckSize; // myDWORD has my definition
myDWORD offset;
ChunkList* children;
myDWORD typeID;
myDWORD headerSize;
ByteBuffer* data;
public:
Chunk(QFile* file);
Chunk(QString name, QFile* file);
~Chunk(void);
bool isList();
ChunkList* getChildren();
QString getName();
void setName(QString);
bool write();
void addChild(Chunk* );
bool read(void);
int readData(Byte* data , myDWORD size=-1);
myDWORD getHeaderOffset(void);
myDWORD getDataOffset(void);
QStringList getErrors(void);
myDWORD getHeaderSize(void);
myDWORD getDataSize(void);
FOURCC getID(void);
myDWORD getOffset(void);
void setOffset(myDWORD);
int getSize();
QString toString(void);
Chunk* copy(void);
bool isOpenedForReading();
bool addToData(Byte* bytes, myDWORD size);
ByteBuffer* readWholeData();
Chunk* findChunkByName(QString name, uint pos=0);
myDWORD readDWORD(myDWORD pos=0);
QString getType();
protected:
bool readHeader();
bool readEmbeddedList();
bool checkFilePosition(myDWORD pos);
private:
void init();
};
QString FOURCC2QString(FOURCC d);
QString DWORD2QString(myDWORD d);
ByteBuffer* Bytes2ByteBuffer(Byte* b , uint size);
}
#endif // CHUNK_H