forked from ponchio/untrunc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.h
47 lines (36 loc) · 1.02 KB
/
atom.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
#ifndef ATOM_H
#define ATOM_H
#include <vector>
#include <string>
class File;
class Atom {
public:
int start; //including 8 header bytes
int length; //including 8 header bytes
char name[5];
char head[4];
char version[4];
std::vector<unsigned char> content;
std::vector<Atom *> children;
Atom(): start(0), length(-1) {
name[0] = name[1] = name[2] = name[3] = name[4] = 0;
length = 0;
start = 0;
}
~Atom();
void parseHeader(File &file); //read just name and length
void parse(File &file);
void write(File &file);
void print(int offset);
std::vector<Atom *> atomsByName(std::string name);
Atom *atomByName(std::string name);
void prune(std::string name);
void updateLength();
static bool isParent(char *id);
static bool isDual(char *id);
static bool isVersioned(char *id);
int readInt(int offset);
void writeInt(int value, int offset);
void readChar(char *str, int offset, int length);
};
#endif // ATOM_H