-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathCustomHeader.cpp
51 lines (39 loc) · 984 Bytes
/
CustomHeader.cpp
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
#include <string>
#include <boost/algorithm/string.hpp>
#include "CustomHeader.h"
CustomHeader::CustomHeader(char* header) {
// Set modulus first
char* bytes = new char[4];
for (int i = 0; i < 4; i++)
bytes[i] = header[i];
mModulus = *reinterpret_cast<int*>(bytes);
// Set extension
char* ext = new char[4];
for (int y = 0, i = 4; i < 8; i++, y++)
ext[y] = header[i];
mExtension = std::string(ext);
boost::algorithm::trim(mExtension);
// Set type
mType = header[8];
delete[] bytes;
delete[] ext;
}
CustomHeader::CustomHeader() {
// Initialize the variables
return;
}
int CustomHeader::GetModulus() {
return this->mModulus;
}
std::string CustomHeader::GetExtension() {
return this->mExtension;
}
char CustomHeader::GetType() {
return this->mType;
}
int CustomHeader::GetLastPosition() {
return this->mLastPos;
}
void CustomHeader::SetLastPosition(int n) {
this->mLastPos = n;
}