-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileParser.hpp
46 lines (36 loc) · 1.13 KB
/
FileParser.hpp
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
//(C) 2020, [email protected]
#ifndef FILE_PARSER_H_
#define FILE_PARSER_H_
#include "Dictionary.hpp"
#include "SpellChecker.hpp"
class FileParser final{
public:
/*
* params:
* filename - full path to filename containing dictionary
* dict - dictionary for emplacing
* returns:
* beging text position position into file
* throws:
* std::exception in the case i/o error
*/
off_t parseDict(const char* filename, Dictionary& dict)const;
/*
* params:
* filename - full path to filename containing dictionary
* pos - beging text position position into file
* dict - dictionary for checking
* checker - checker instance
* no returns:
* throws:
* std::exception in the case i/o error
*
*/
void parseText(const char* filename, off_t pos, Dictionary& dict, SpellChecker& checker)const;
private:
off_t parseDictBuf(char* buf, size_t len, Dictionary& dict)const;
size_t parseTextBuf(char* buf, size_t len, Dictionary& dict, SpellChecker& checker, FILE* out)const;
void outResult(const char* word, bool correct, const Result&, FILE* out)const;
void outDelim(char& delim, FILE* out)const;
};
#endif //FILE_PARSER_H_