-
Notifications
You must be signed in to change notification settings - Fork 0
/
binman.hpp
76 lines (59 loc) · 2.22 KB
/
binman.hpp
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
/*******************************************************************************
* This file is pat of binman - Binary Managment library for C++
*
* If this file is in use in another, unrelated project, please see the github
* for binman for more information: https://github.com/ADBeta/binman
*
* This project is under GNU Public Licence.
* (c) 2023 ADBeta
*
* Notes:
*
* 2 March 2023
* v0.3.6
*******************************************************************************/
#include <string>
#include <fstream>
#ifndef H_BINMAN
#define H_BINMAN
/*** binman class methods *****************************************************/
class binman {
public:
//Constructor (char + string overload)
binman(const char *filename);
binman(const std::string filename);
//Desctructor
~binman();
/*** File Management ******************************************************/
//Reads input file into the RAM array
int read();
//Print a section or all of the binary file, pass offset and bytes to print
//Default call prints the whole file to the terminal
void print(size_t offset = 0, size_t n = 0);
/*** Private class variables **********************************************/
//private: TODO
/*** Config Variables *****************************************************/
bool confVerbose = true;
/*** File Variables *******************************************************/
//File object
std::fstream file;
//Filename of the input/output file
char *filename;
//Bytes in the memory array
size_t memBytes;
//Pointer to array pointer
unsigned char *memPtr;
/*** RAM Manager **********************************************************/
//Allocate the RAM array, deletes the data previously pointed to
int allocMem(const size_t bytes);
//Resize the RAM array directly
int resizeMem(const size_t newBytes);
//Resizes the RAM array via incrememnt or decrement
int incMem(const size_t incBytes);
int decMem(const size_t decBytes);
/*** Util functions *******************************************************/
//Converts an int to HEX Uppercase value and pads it with 0's
std::string toHexString(const size_t val, unsigned int pad);
}; //class binman
/*** Helper functions *********************************************************/
#endif