fhq-server  v0.2.33
Documentation for fhq-server. FreeHackQuest is an open source platform for competitions of computer security.
wsjcpp_validators.h
Go to the documentation of this file.
1 #ifndef WSJCPP_VALIDATOR_H
2 #define WSJCPP_VALIDATOR_H
3 
4 #include <string>
5 #include <vector>
6 #include <regex>
7 
11 };
12 
13 // ----------------------------------------------------------------------
14 
16  public:
17  static bool isValidDate(const std::string &sValue, std::string &sError);
18  static bool isValidTimeH24(const std::string &sValue, std::string &sError);
19  static bool isValidURLProtocol(const std::string &sValue, std::string &sError);
20  static bool isValidDomainName(const std::string &sValue, std::string &sError);
21  static bool isValidPort(const std::string &sValue, std::string &sError);
22  static bool isValidPort(int nValue, std::string &sError);
23  static bool isValidBase64(const std::string &sValue, std::string &sError);
24  static bool isValidIPv4(const std::string &sValue, std::string &sError);
25  static bool isValidIPv6(const std::string &sValue, std::string &sError);
26 };
27 
28 /*
29 // ----------------------------------------------------------------------
30 
31 class WsjcppValidatorBase {
32  public:
33  WsjcppValidatorBase(const std::string &sTypeName, WsjcppValidatorType nValidatorType);
34  virtual WsjcppValidatorType getBaseType();
35  virtual std::string getTypeName();
36  virtual bool isValid(const std::string &sValue, std::string &sError) = 0;
37  protected:
38  std::string TAG;
39  private:
40  std::string m_sTypeName;
41 };
42 
43 */
44 
45 // ----------------------------------------------------------------------
46 
48  public:
49  WsjcppValidatorStringBase(const std::string &typeName);
50  virtual WsjcppValidatorType getBaseType();
51  virtual std::string getTypeName();
52  virtual bool isValid(const std::string &sValue, std::string &sError) = 0;
53  protected:
54  std::string TAG;
55  private:
56  std::string m_sTypeName;
57 };
58 
59 // ----------------------------------------------------------------------
60 
62  public:
63  WsjcppValidatorStringRegexpBase(const std::string &typeName, const std::string &sValidator);
64  virtual bool isValid(const std::string &sValue, std::string &sError) override;
65  private:
66  std::string m_sValidator;
67  std::regex m_rxValidator;
68 };
69 
70 // ----------------------------------------------------------------------
71 
73  public:
74  WsjcppValidatorStringListBase(const std::string &typeName, const std::vector<std::string> &vListValues);
75  virtual bool isValid(const std::string &sValue, std::string &sError) override;
76  private:
77  std::vector<std::string> m_vListValues;
78 };
79 
80 // ----------------------------------------------------------------------
81 
83  public:
85 };
86 
87 // ----------------------------------------------------------------------
88 
90  public:
92 };
93 
94 // ----------------------------------------------------------------------
95 
97  public:
98  WsjcppValidatorStringLength(int nMinLength, int nMaxLength);
99  virtual bool isValid(const std::string &sValue, std::string &sError);
100 
101  private:
102  std::string TAG;
105 };
106 
107 // ----------------------------------------------------------------------
108 
110  public:
112 };
113 
114 // ----------------------------------------------------------------------
115 
117  public:
119  virtual bool isValid(const std::string &sValue, std::string &sError);
120  private:
121  std::string TAG;
122 };
123 
124 // ----------------------------------------------------------------------
125 
127  public:
129  virtual bool isValid(const std::string &sValue, std::string &sError);
130  private:
131  std::string TAG;
132 };
133 
134 // ----------------------------------------------------------------------
135 
137  public:
139  virtual bool isValid(const std::string &sValue, std::string &sError);
140  private:
141  std::string TAG;
142 };
143 
144 // ----------------------------------------------------------------------
145 
147  public:
149  virtual bool isValid(const std::string &sValue, std::string &sError);
150 
151  private:
152  std::string TAG;
153  std::regex m_rxLikeIPv4Format;
154 };
155 
156 // ----------------------------------------------------------------------
157 
159  public:
161  virtual bool isValid(const std::string &sValue, std::string &sError);
162 
163  private:
164  std::string TAG;
165 };
166 
167 // ----------------------------------------------------------------------
168 
170  public:
172  virtual bool isValid(const std::string &sValue, std::string &sError);
173 
174  private:
175  std::string TAG;
176 };
177 
178 // ----------------------------------------------------------------------
179 
181  public:
183  virtual bool isValid(const std::string &sValue, std::string &sError);
184 
185  private:
186  std::string TAG;
187 };
188 
189 // ----------------------------------------------------------------------
190 
191 #endif // WSJCPP_VALIDATOR_H
std::regex m_rxValidator
Definition: wsjcpp_validators.h:67
WsjcppValidatorType
Definition: wsjcpp_validators.h:8
std::string TAG
Definition: wsjcpp_validators.h:54
Definition: wsjcpp_validators.h:61
static bool isValidPort(const std::string &sValue, std::string &sError)
Definition: wsjcpp_validators.cpp:218
Definition: wsjcpp_validators.h:146
Definition: wsjcpp_validators.h:180
Definition: wsjcpp_validators.h:10
int m_nMinLength
Definition: wsjcpp_validators.h:103
std::vector< std::string > m_vListValues
Definition: wsjcpp_validators.h:77
std::string TAG
Definition: wsjcpp_validators.h:141
std::string TAG
Definition: wsjcpp_validators.h:175
static bool isValidDate(const std::string &sValue, std::string &sError)
Definition: wsjcpp_validators.cpp:5
static bool isValidTimeH24(const std::string &sValue, std::string &sError)
Definition: wsjcpp_validators.cpp:64
static bool isValidIPv4(const std::string &sValue, std::string &sError)
Definition: wsjcpp_validators.cpp:294
Definition: wsjcpp_validators.h:96
Definition: wsjcpp_validators.h:109
Definition: wsjcpp_validators.h:89
std::string m_sValidator
Definition: wsjcpp_validators.h:66
Definition: wsjcpp_validators.h:72
std::string TAG
Definition: wsjcpp_validators.h:152
std::string TAG
Definition: wsjcpp_validators.h:102
Definition: wsjcpp_validators.h:126
std::string TAG
Definition: wsjcpp_validators.h:121
static bool isValidBase64(const std::string &sValue, std::string &sError)
Definition: wsjcpp_validators.cpp:252
std::string TAG
Definition: wsjcpp_validators.h:131
Definition: wsjcpp_validators.h:136
std::regex m_rxLikeIPv4Format
Definition: wsjcpp_validators.h:153
Definition: wsjcpp_validators.h:47
std::string TAG
Definition: wsjcpp_validators.h:164
std::string m_sTypeName
Definition: wsjcpp_validators.h:56
Definition: wsjcpp_validators.h:169
Definition: wsjcpp_validators.h:158
static bool isValidDomainName(const std::string &sValue, std::string &sError)
Definition: wsjcpp_validators.cpp:115
static bool isValidURLProtocol(const std::string &sValue, std::string &sError)
Definition: wsjcpp_validators.cpp:235
Definition: wsjcpp_validators.h:116
int m_nMaxLength
Definition: wsjcpp_validators.h:104
static bool isValidIPv6(const std::string &sValue, std::string &sError)
Definition: wsjcpp_validators.cpp:330
Definition: wsjcpp_validators.h:9
std::string TAG
Definition: wsjcpp_validators.h:186
Definition: wsjcpp_validators.h:15
Definition: wsjcpp_validators.h:82