-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverAnswerValidator.h
43 lines (36 loc) · 1.18 KB
/
serverAnswerValidator.h
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
#pragma once
#include <string>
#include <map>
#include <cpprest/http_client.h>
class serverAnswerValidator
{
public:
serverAnswerValidator();
serverAnswerValidator(web::json::value json);
serverAnswerValidator(int code);
~serverAnswerValidator(){};
bool checkResponse(web::http::http_response* response);
static serverAnswerValidator* getDefault() { return serverAnswerValidator::m_defaut;}
private:
static serverAnswerValidator* m_defaut;
int m_code;
std::string m_body;
bool m_validAny;
void initToEmpty();
bool checkAll(web::http::http_response* response);
bool checkAny(web::http::http_response* response);
bool checkBody(web::http::http_response* response);
bool checkHeaders(web::http::http_response* response);
std::map<std::string,std::string> m_headers;
};
class validatorFactory
{
public:
~validatorFactory();
static serverAnswerValidator* getValidator(web::json::value json);
private:
validatorFactory();
serverAnswerValidator* internal_getValidator(web::json::value json);
std::list<serverAnswerValidator*> m_list;
static validatorFactory* mysingleton;
};