blob: bf1fee44f57c9abe905dd7e0d13f3ed47a56352a (
plain)
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
75
|
/**
* @file recursivedescent.h
* @brief Declaration of a recursive descent IMAP command parser.
* @author Andreas Aardal Hanssen, Jannis M. Hoffmann
* @date 2002-2023
*/
#ifndef expectcommand_h_inluded
#define expectcommand_h_inluded
#include "imapparser.h"
#include "session.h"
#include <stack>
#include <string>
namespace Binc {
class Parser {
std::stack<int> inputBuffer;
int charnr;
Session &session;
public:
Parser(Session &session) : charnr(0), session(session){};
Parser(const Parser &) = delete;
int readChar();
void unReadChar(int c_in);
void unReadChar(const std::string &s_in);
enum class ParseResult { ACCEPT, REJECT, ERROR, TIMEOUT };
ParseResult expectTag(std::string &s_in);
ParseResult expectTagChar(int &c_in);
ParseResult expectSPACE();
ParseResult expectFlag(std::vector<std::string> &v_in);
ParseResult expectListMailbox(std::string &s_in);
ParseResult expectListWildcards(int &c_in);
ParseResult expectDateTime(std::string &s_in);
ParseResult expectTime(std::string &s_in);
ParseResult expectZone(std::string &s_in);
ParseResult expectMailbox(std::string &s_in);
ParseResult expectAstring(std::string &s_in);
ParseResult expectAtom(std::string &s_in);
ParseResult expectAtomChar(int &i_in);
ParseResult expectString(std::string &s_in);
ParseResult expectDate(std::string &s_in);
ParseResult expectNumber(unsigned int &i_in);
ParseResult expectDigit(unsigned int &i_in);
ParseResult expectDigitNZ(unsigned int &i_in);
ParseResult expectLiteral(std::string &s_in);
ParseResult expectQuoted(std::string &s_in);
ParseResult expectQuotedChar(int &c_in);
ParseResult expectSet(SequenceSet &s_in);
ParseResult expectSequenceNum(unsigned int &i_in);
ParseResult expectNZNumber(unsigned int &i_in);
ParseResult expectCRLF();
ParseResult expectCR();
ParseResult expectLF();
ParseResult expectThisString(const std::string &s_in);
};
}
#endif
|