Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
74 lines (63 loc) · 2.43 KB

File metadata and controls

74 lines (63 loc) · 2.43 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <exception>
#include <cstring>
#include <cassert>
#include "StreamClasses.h"
#include "SinkClasses.h"
#include "FilterClasses.h"
int main()
{
try
{
//test for Stream class
//Stream stream;
//std::cout << "Input text data and terminate by Control + D:\n";
//char* input = stream.readInput();
Stream stream("ag kar jf kar");
//test for Sink class
Sink sinkStream(&stream);
sinkStream.printEverything();
//test for ConstStream class
ConstStream constantStream("helloworld123");
//test for FileStream class
FileStream streamFromFile("WriteFromFile.txt");
//test for FileSink class
FileSink streamToFile(&stream, "Text.txt");
streamToFile.saveTextDataToFile();
//test for WordFilter class
WordFilter wordFilt(&stream, "kar");
std::cout << wordFilt.applyFilter(&stream) << std::endl;
//sinkStream.printEverything();
//test for SequenceReplaceFilter
Stream secondStream("i weight hey no more weight key weight");
SequenceReplaceFilter replaceFilter(&secondStream, "weight", "haha");
char* result = replaceFilter.applyFilter(&secondStream);
std::cout << result << std::endl;
free(result);
std::cout << "work" << std::endl;
//test for PairFilter
Stream thirdStream("i weight hey no more weight key weight");
SequenceReplaceFilter replaceFilterSecond(&thirdStream, "weight", "haha");
WordFilter wordFilterSecond(&stream, "haha");
PairFilter pairFilter(&stream, &replaceFilterSecond, &wordFilterSecond);
char* resultSecond = pairFilter.applyFilter(&thirdStream);
std::cout << resultSecond << std::endl;
//test for operators
Stream fourthStream("caradf truck");
WordFilter wordFilterThird(&fourthStream, "truck");
std::cout << wordFilterThird.applyFilter(&fourthStream) << std::endl;
std::cout << wordFilterThird.operator*() << std::endl;
wordFilterThird.operator++();
wordFilterThird.operator++();
std::cout << wordFilterThird.operator[](-1) << std::endl;
char* res = wordFilterThird.operator()(1, 3);
std::cout << res << std::endl;
free(res);
}
catch(const std::exception& ex)
{
std::cout << ex.what() << std::endl;
}
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.