00 /*
01  * textprocessor.h
02  *
03  *      Author: Simonas Saltenis
04  */
05 
06 #ifndef TEXTPROCESSOR_H_
07 #define TEXTPROCESSOR_H_
08 
09 #include<istream>
10 #include<ostream>
11 #include<vector>
12 #include<string>
13 
14 namespace Textprocessor
15 {
16 
17 // Note some of the design decisions regarding the interface of this class (TSortSearch):
18 // - It gets a reference to a an arbitrary stream (instead of something less general, such as a file name)
19 // - search method does not change the instance of TSortSearch, it outputs the results into the output stream,
20 //   while sort actually sorts the internal buffer of lines.
21 //
22 class TSortSearch
23 {
24 public:
25 	TSortSearch(std::istream& is);
26 
27 	void sortlines   (unsigned n);
28 	void searchlines (unsigned n, const std::string& s, std::ostream& output) const;
29 
30 private:
31 	std::vector<std::string>  lines;
32 
33 	friend std::istream& operator>>(std::istream&, TSortSearch&);         // input
34 	friend std::ostream& operator<<(std::ostream&, const TSortSearch&);   // output
35 };
36 
37 std::istream& operator>>(std::istream&, TSortSearch&);
38 std::ostream& operator<<(std::ostream&, const TSortSearch&);
39 
40 }
41 
42 
43 #endif /* TEXTPROCESSOR_H_ */
44