-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.h
More file actions
47 lines (36 loc) · 958 Bytes
/
data.h
File metadata and controls
47 lines (36 loc) · 958 Bytes
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 DATA_H
#define DATA_H
#include <iostream>
#include <fstream>
#include <QDebug>
#include <string>
class Data
{
private:
char* contents;
size_t len;
public:
Data();
void init(size_t _len){
this->len = _len;
this->contents= new char[_len];
}
void setContents(std::ifstream &file, size_t len)
{
file.read(this->contents,len);
};
char* getContents(){
return this->contents;
}
size_t getLen(){
return this->len;
}
//erase '_len' number of characters in contents starting from position '_beg'
void erase(size_t _beg, size_t _len);
//insert '_str' of size '_len' starting from '_beg'
//this effectively increases size of contents by '_len'
void insert(size_t _beg, std::string _str, size_t _len);
//replace '_len' bytes starting at '_beg' with '_str' data
void replace(size_t _beg, std::string _str, size_t _len);
};
#endif // DATA_H