-
Notifications
You must be signed in to change notification settings - Fork 0
/
text_shredder.h
56 lines (42 loc) · 1.82 KB
/
text_shredder.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
#ifndef __SHREDDER__
#define __SHREDDER__
#include <vector>
#include <string>
class TextShredder
{
#ifdef UTFLAG
public:
#else
private:
#endif
// The width of shredded text strips.
const int n_strip_width_;
// Input file name - contains a page for shredding
const std::string str_in_filename_;
// Output file name - contains shredded text strips.
const std::string str_out_filename_;
// The following variable will contain all texts in a page, each line will be stored in
// a vector component. Minimum number of blanks will be added to the end of some lines by
// TextFileOperation::ReadText() to ensure each lines have the same number of charactors
// for further process by programme.
std::vector<std::string> vec_str_source_data_;
// Appropriate number of blanks will be added to last shredded colomn if the size of last column
// less than n_strip_width_ . This is to ensure every column has the same size as n_strip_width_
// defined.
std::vector<std::vector<std::string>> vec_str_shredded_text_;
// Transpose of vec_str_shredded_text_
std::vector<std::vector<std::string>> vec_str_trans_shredded_text_;
public:
TextShredder(const int n_width=2, const std::string str_in_file="full_text0.ascii", const std::string str_out_file="shredded_text0.ascii");
// Populate vec_str_source_data_ from input file
void GetInput();
// Print vec_str_shredded_text_ to output file by delimiter "|"
void CreateOutput();
// Shred text lines stored vec_str_source_data_ and save shredded result into vec_str_shredded_text_
void DoTextShredder();
};
#ifdef UTFLAG
// To change main() to UTmain() so as to be tested by Unit Testing
extern int UTmain(const int n_width, const std::string str_infile, const std::string str_outfile);
#endif
#endif