You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[C++11](HttpStatusCodes_C++11.h)| Namespace `HttpStatus`|`enum class Code`|`std::string`|
35
-
|[Qt](HttpStatusCodes_Qt.h)| Namespace `HttpStatus`|`enum Code`<br>When using Qt 5.8 or later: registered in meta type system using `Q_ENUM_NS()`|`QString`|
30
+
| Variant | Name Scoping | Status Codes Type | Reason Phrases Type |
|[C++11](HttpStatusCodes_C++11.h)| Namespace `HttpStatus`|`enum class Code`|`std::string`|
35
+
|[Qt](HttpStatusCodes_Qt.h)| Namespace `HttpStatus`|`enum Code`<br>When using Qt 5.8 or later: registered in meta type system using `Q_ENUM_NS()`|`QString`|
36
+
|[Qt C++11](HttpStatusCodes_Qt_C++11.h)| Namespace `HttpStatus`|`enum class Code`<br>When using Qt 5.8 or later: registered in meta type system using `Q_ENUM_NS()`|`QString`|
36
37
37
38
38
39
> Note regarding Qt variant: Oldest tested Qt version was Qt 5.2.0 with MinGW 4.8. However, should be working with any Qt 5.x version.
@@ -72,6 +73,7 @@ might be undefined behavior.
72
73
```c
73
74
enum HttpStatus_Code
74
75
{
76
+
HttpStatus_Invalid = -1,
75
77
HttpStatus_OK = 200,
76
78
HttpStatus_NotFound = 404
77
79
// ...
@@ -83,6 +85,7 @@ enum HttpStatus_Code
83
85
namespaceHttpStatus {
84
86
enum class Code
85
87
{
88
+
Invalid = -1,
86
89
OK = 200,
87
90
NotFound = 404
88
91
// ...
@@ -95,6 +98,7 @@ enum class Code
95
98
namespaceHttpStatus {
96
99
enum Code
97
100
{
101
+
Invalid = -1,
98
102
OK = 200,
99
103
NotFound = 404
100
104
// ...
@@ -124,14 +128,18 @@ Non-standard error codes are status codes with a value of 600 or higher.
124
128
Returns `0` otherwise.
125
129
126
130
##### Other Variants #####
127
-
> **Note:** The C++11 variant also provides overloads for `HttpStatus::Code`. So there is no need to cast.
128
-
129
131
```c++
130
132
boolHttpStatus::isInformational( int code );
131
133
bool HttpStatus::isSuccessful( int code );
132
134
bool HttpStatus::isRedirection( int code );
133
135
bool HttpStatus::isClientError( int code );
134
136
bool HttpStatus::isServerError( int code );
137
+
138
+
bool HttpStatus::isInformational( Code code ); // C++11 variants only
139
+
bool HttpStatus::isSuccessful( Code code ); // C++11 variants only
140
+
bool HttpStatus::isRedirection( Code code ); // C++11 variants only
141
+
bool HttpStatus::isClientError( Code code ); // C++11 variants only
142
+
bool HttpStatus::isServerError( Code code ); // C++11 variants only
135
143
```
136
144
Return `true` if the given _code_ belongs to the corresponding class of status codes (see [RFC7231](https://tools.ietf.org/html/rfc7231#section-6)).
137
145
Return `false` otherwise.
@@ -140,6 +148,7 @@ Return `false` otherwise.
140
148
141
149
```c++
142
150
bool HttpStatus::isError( int code );
151
+
bool HttpStatus::isError( Code code ); // C++11 variants only
143
152
```
144
153
Returns `true` if the given _code_ is either a client error, a server error or any non-standard error code.
145
154
Non-standard error codes are status codes with a value of 600 or higher.
@@ -155,37 +164,39 @@ const char* HttpStatus_reasonPhrase( int code );
155
164
Returns the HTTP reason phrase string corresponding to the given _code_.
156
165
157
166
##### C++/C++11 Variants #####
158
-
> **Note:** The C++11 variant also provides an overload for `HttpStatus::Code`. So there is no need to cast.
159
167
```c++
160
168
std::string HttpStatus::reasonPhrase( int code );
169
+
std::string HttpStatus::reasonPhrase( Code code ); // C++11 variants only
161
170
```
162
171
Returns the HTTP reason phrase string corresponding to the given _code_.
163
172
164
-
##### Qt Variant #####
173
+
##### Qt Variants #####
165
174
```c++
166
175
QString HttpStatus::reasonPhrase( int code );
176
+
QString HttpStatus::reasonPhrase( Code code ); // C++11 variant only
167
177
```
168
178
Returns the HTTP reason phrase string corresponding to the given _code_.
169
179
170
180
171
181
### Conversion Functions ###
172
182
173
-
##### C++11 Variant #####
183
+
##### C++11 Variants #####
174
184
```c++
175
185
int HttpStatus::toInt( HttpStatus::Code code );
176
186
```
177
187
Returns the integer value corresponding to a given a _code_.
178
188
This is a convenience function as replacement for a `static_cast<int>()`.
0 commit comments