-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileText.h
41 lines (31 loc) · 973 Bytes
/
fileText.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
#pragma once
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
//========================
// for capturing file text
//========================
class fileText
{
protected:
std::string fileName;
std::vector<std::string> lines;
public:
fileText(){}; // default
fileText(const fileText &other){*this = other;}; // copy constructor: uses default assignment
fileText(const std::string &name){copyFile(name);}; // construct with name of file
bool openFile(std::fstream &inFile, const std::string &name);
// copy file to lines std::vector
bool copyFile(const std::string &name);
// fileName methods
std::string getFileName(){return fileName;};
// get lines
std::vector<std::string> getLines(){return lines;};
// print lines
void printLines(){ for(auto l : lines) std::cout << l << std::endl;};
// overloaded operators
//=====================
// +=
fileText &operator+=(const fileText &rhs);
};