-
Notifications
You must be signed in to change notification settings - Fork 5
/
CustomHeader.cpp
52 lines (41 loc) · 1009 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
52
#include <string>
#include <boost/algorithm/string.hpp>
#include "headers/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() {
// Initializing 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;
}