-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamClasses.h
More file actions
79 lines (65 loc) · 1.68 KB
/
StreamClasses.h
File metadata and controls
79 lines (65 loc) · 1.68 KB
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
77
78
#pragma once
#include <iostream>
class Stream
{
private:
char* array = nullptr;
int size;
int capacity;
public:
Stream();
Stream(int capacity);
Stream(const char* str);
Stream(const Stream& other);
Stream& operator=(const Stream& other);
~Stream();
void setData(const char* str);
char* readInput();
char* getArray();
char* getArray() const;
int sizeOfArray() const;
int capacityOfArray();
void incrementSize();
void addElement(const char value);
void expandArray();
void printElements();
char operator[] (int index) const;
};
class EmptyStream : public Stream
{
public:
EmptyStream() : Stream() {}
EmptyStream(const EmptyStream& other) = delete;
EmptyStream& operator=(const EmptyStream& other) = delete;
void setData(const char* str) = delete;
void readInput() = delete;
char operator[](int pos) const { return '\0'; }
};
class ConstStream : public Stream {
public:
ConstStream(const char* str = "\0") : Stream(str) {}
void setData(const char* str) = delete;
void readInput() = delete;
};
class RandomStream : public Stream
{
private:
inline static char* symbols;
inline static int size;
inline static int capacity;
public:
RandomStream(int numChars);
RandomStream(const RandomStream& other);
RandomStream& operator=(const RandomStream& other);
~RandomStream();
static void addElement(const char value);
static void expandArray();
static void changeSymbols(const char* newSymbols);
static void setSymbols();
};
class FileStream : public Stream
{
public:
FileStream(const char* fileName);
char* readFile(const char* fileName);
};