-
Notifications
You must be signed in to change notification settings - Fork 0
/
block.h
executable file
·51 lines (40 loc) · 1.25 KB
/
block.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
48
49
50
51
#ifndef BLOCK_H
#define BLOCK_H
#include <string>
#include <vector>
#include <iostream>
class Block
{
private:
char *block;
int nrOfElements;
bool used;
std::string args;
public:
/* Constructor */
Block(int nrOfElements = 512); // overloaded (default) constructor
Block(const Block &other); // copy-constructor
/* Destructor */
~Block();
/* Operators */
Block& operator = (const Block &other); // Assignment operator
char operator[] (int index) const; // []-operator
friend std::ostream& operator<<(std::ostream &os, const Block& blck)
{
for (int i = 0; i < blck.nrOfElements; ++i)
os << blck.block[i];
return os;
}
void reset(char c = 0); // Sets every element in char-array to 0
int size() const; // returns the size
Block readBlock() const; // Returns a copy of block
/* Write a block */
int writeBlock(const std::string &strBlock);
int writeBlock(const std::vector<char> &vec);
void writeBlock(const char cArr[]); // Use with caution! Make sure that cArr is at least as large as private member block.
bool getUsed() const;
void setUsed(bool used);
char* getBlock() const;
std::string toString() const;
};
#endif // BLOCK_H