-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRiffFileDefs.h
41 lines (32 loc) · 978 Bytes
/
RiffFileDefs.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
#ifndef RIFFFILEDEFS_H
#define RIFFFILEDEFS_H
#include <QString>
#include <QVector>
#include <QFile>
namespace RiffFileDefs{
typedef int FOURCC; // 32-bit number
typedef unsigned long DWORD;
typedef QVector<char> ByteBuffer;
QString FOURCC2QString(RiffFileDefs::FOURCC d);
FOURCC QString2FOURCC(QString str);
DWORD QString2DWORD(QString str);
ByteBuffer* getByteBuffer(char* bytes, DWORD size);
int readInt(QFile* file, int sizeOfInt = 4){
char* data = new char [sizeOfInt];
int out = -1;
if (file->read(data, sizeOfInt) == sizeOfInt){
memcpy(&out, data, sizeOfInt);
}
return out;
}
QString readString(QFile* file, int sizeOfString = 4){
char* data = new char [sizeOfString+1];
if (file->read(data, 4) == 4){
*(data+sizeOfString) = '\0';
return QString(data);
}
return "";
}
}
typedef RiffFileDefs::DWORD myDWORD;
#endif // RIFFFILEDEFS_H