-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.h
64 lines (50 loc) · 1.92 KB
/
input.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
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef INPUT_H_
#define INPUT_H_
/*
+---------------------------------------+
| BETH YW? WELSH GOVERNMENT DATA PARSER |
+---------------------------------------+
AUTHOR: 956213
This file contains declarations for the input source handlers. There are
two classes: InputSource and InputFile. InputSource is abstract (i.e. it
contains a pure virtual function). InputFile is a concrete derivation of
InputSource, for input from files.
Although only one class derives from InputSource, we have implemented our
code this way to support future expansion of input from different sources
(e.g. the web).
TODO: Read the block comments with TODO in input.cpp to know which
functions and member variables you need to declare in these classes.
*/
#include <string>
#include <fstream>
/*
InputSource is an abstract/purely virtual base class for all input source
types. In future versions of our application, we may support multiple input
data sources such as files and web pages. Therefore, this virtual class
will allow us to mix/match sources as needed.
TODO: Based on your implementation of this class and of dervived classes,
there may be additional constructors or functions you implement here,
and perhaps additional operators you may wish to overload.
*/
class InputSource {
public:
explicit InputSource(const std::string& source);
std::string getSource();
private:
std::string source;
};
/*
Source data that is contained within a file. For now, our application will
only work with files (and in particular, the files in the datasets directory).
TODO: Based on your implementation, there may be additional constructors
or functions you implement here, and perhaps additional operators you may wish
to overload.
*/
class InputFile : public InputSource {
private:
std::ifstream is;
public:
explicit InputFile(const std::string& filePath);
std::istream& open();
};
#endif // INPUT_H_