summaryrefslogtreecommitdiff
path: root/src/include/operators.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/operators.h')
-rw-r--r--src/include/operators.h154
1 files changed, 76 insertions, 78 deletions
diff --git a/src/include/operators.h b/src/include/operators.h
index 9cfd10a..bc03607 100644
--- a/src/include/operators.h
+++ b/src/include/operators.h
@@ -11,32 +11,30 @@
#include "depot.h"
#include "imapparser.h"
#include "message.h"
+#include "recursivedescent.h"
+#include "session.h"
#include <string>
#include <vector>
namespace Binc {
- class Operator {
- public:
- enum ProcessResult { OK, BAD, NO, NOTHING, ABORT };
-
- enum ParseResult { ACCEPT, REJECT, ERROR, TIMEOUT };
+ struct Operator {
+ enum class ProcessResult { OK, BAD, NO, NOTHING, ABORT };
virtual ProcessResult process(Depot &, Request &) = 0;
- virtual ParseResult parse(Request &) const = 0;
- virtual int getState() const = 0;
+ virtual Parser::ParseResult parse(Request &) = 0;
+ virtual Session::State getState() const = 0;
virtual const std::string getName() const = 0;
- virtual ~Operator(){};
+ virtual ~Operator() = default;
};
- class AppendOperator : public Operator {
- public:
- ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
- const std::string getName() const;
- int getState() const;
+ struct AppendOperator : public Operator {
+ ProcessResult process(Depot &, Request &) final;
+ Parser::ParseResult parse(Request &) final;
+ const std::string getName() const final;
+ Session::State getState() const final;
AppendOperator();
~AppendOperator();
@@ -44,11 +42,11 @@ namespace Binc {
class AuthenticateOperator : public Operator {
public:
- ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ ProcessResult process(Depot &, Request &) override;
+ virtual Parser::ParseResult parse(Request &) override;
- const std::string getName() const;
- int getState() const;
+ const std::string getName() const override;
+ Session::State getState() const override;
ProcessResult Login(std::string &username, std::string &password);
ProcessResult Plain(std::string &username, std::string &password);
@@ -63,10 +61,10 @@ namespace Binc {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
void addCapability(const std::string &cap);
@@ -77,10 +75,10 @@ namespace Binc {
class CheckOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
CheckOperator();
~CheckOperator();
@@ -89,10 +87,10 @@ namespace Binc {
class CreateOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
CreateOperator();
~CreateOperator();
@@ -101,10 +99,10 @@ namespace Binc {
class CloseOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
CloseOperator();
~CloseOperator();
@@ -113,10 +111,10 @@ namespace Binc {
class CopyOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
CopyOperator();
~CopyOperator();
@@ -125,10 +123,10 @@ namespace Binc {
class DeleteOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
DeleteOperator();
~DeleteOperator();
@@ -137,10 +135,10 @@ namespace Binc {
class ExpungeOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
ExpungeOperator();
~ExpungeOperator();
@@ -148,18 +146,18 @@ namespace Binc {
class FetchOperator : public Operator {
protected:
- ParseResult expectSectionText(BincImapParserFetchAtt &f_in) const;
- ParseResult expectSection(BincImapParserFetchAtt &f_in) const;
- ParseResult expectFetchAtt(BincImapParserFetchAtt &f_in) const;
- ParseResult expectOffset(BincImapParserFetchAtt &f_in) const;
- ParseResult expectHeaderList(BincImapParserFetchAtt &f_in) const;
+ Parser::ParseResult expectSectionText(BincImapParserFetchAtt &f_in) const;
+ Parser::ParseResult expectSection(BincImapParserFetchAtt &f_in) const;
+ Parser::ParseResult expectFetchAtt(BincImapParserFetchAtt &f_in) const;
+ Parser::ParseResult expectOffset(BincImapParserFetchAtt &f_in) const;
+ Parser::ParseResult expectHeaderList(BincImapParserFetchAtt &f_in) const;
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
FetchOperator();
~FetchOperator();
@@ -168,10 +166,10 @@ namespace Binc {
class IdOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
IdOperator();
~IdOperator();
@@ -179,18 +177,18 @@ namespace Binc {
class IdleOperator : public Operator {
protected:
- ParseResult expectSectionText(BincImapParserFetchAtt &f_in) const;
- ParseResult expectSection(BincImapParserFetchAtt &f_in) const;
- ParseResult expectFetchAtt(BincImapParserFetchAtt &f_in) const;
- ParseResult expectOffset(BincImapParserFetchAtt &f_in) const;
- ParseResult expectHeaderList(BincImapParserFetchAtt &f_in) const;
+ Parser::ParseResult expectSectionText(BincImapParserFetchAtt &f_in) const;
+ Parser::ParseResult expectSection(BincImapParserFetchAtt &f_in) const;
+ Parser::ParseResult expectFetchAtt(BincImapParserFetchAtt &f_in) const;
+ Parser::ParseResult expectOffset(BincImapParserFetchAtt &f_in) const;
+ Parser::ParseResult expectHeaderList(BincImapParserFetchAtt &f_in) const;
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
IdleOperator();
~IdleOperator();
@@ -210,10 +208,10 @@ namespace Binc {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
ListOperator();
~ListOperator();
@@ -222,10 +220,10 @@ namespace Binc {
class LoginOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
LoginOperator();
~LoginOperator();
@@ -234,10 +232,10 @@ namespace Binc {
class LogoutOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
LogoutOperator();
~LogoutOperator();
@@ -246,10 +244,10 @@ namespace Binc {
class LsubOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
LsubOperator();
~LsubOperator();
@@ -258,10 +256,10 @@ namespace Binc {
class NamespaceOperator : public Operator {
public:
virtual ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
NamespaceOperator();
~NamespaceOperator();
@@ -270,10 +268,10 @@ namespace Binc {
class NoopOperator : public Operator {
public:
virtual ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
NoopOperator();
~NoopOperator();
@@ -290,10 +288,10 @@ namespace Binc {
class RenameOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
RenameOperator();
~RenameOperator();
@@ -301,7 +299,7 @@ namespace Binc {
class SearchOperator : public Operator {
protected:
- ParseResult expectSearchKey(BincImapParserSearchKey &s_in) const;
+ Parser::ParseResult expectSearchKey(BincImapParserSearchKey &s_in) const;
class SearchNode {
std::string date;
@@ -386,10 +384,10 @@ namespace Binc {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
SearchOperator();
~SearchOperator();
@@ -398,10 +396,10 @@ namespace Binc {
class SelectOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
SelectOperator();
~SelectOperator();
@@ -417,11 +415,11 @@ namespace Binc {
class StarttlsOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
- int goStartTLS() const;
+ Session::State getState() const;
+ ProcessResult goStartTLS() const;
StarttlsOperator();
~StarttlsOperator();
@@ -432,10 +430,10 @@ namespace Binc {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
StatusOperator();
~StatusOperator();
@@ -444,10 +442,10 @@ namespace Binc {
class StoreOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
StoreOperator();
~StoreOperator();
@@ -456,10 +454,10 @@ namespace Binc {
class SubscribeOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
SubscribeOperator();
~SubscribeOperator();
@@ -468,10 +466,10 @@ namespace Binc {
class UnsubscribeOperator : public Operator {
public:
ProcessResult process(Depot &, Request &);
- virtual ParseResult parse(Request &) const;
+ virtual Parser::ParseResult parse(Request &);
const std::string getName() const;
- int getState() const;
+ Session::State getState() const;
UnsubscribeOperator();
~UnsubscribeOperator();