Skip to content

Commit e6df987

Browse files
committed
Ensures enum types can hold values up to 1023
1 parent 4e75689 commit e6df987

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

HttpStatusCodes_C++.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ enum Code
107107
InsufficientStorage = 507, //!< Means the method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.
108108
LoopDetected = 508, //!< Indicates that the server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". [RFC 5842]
109109
NotExtended = 510, //!< The policy for accessing the resource has not been met in the request. [RFC 2774]
110-
NetworkAuthenticationRequired = 511 //!< Indicates that the client needs to authenticate to gain network access.
110+
NetworkAuthenticationRequired = 511, //!< Indicates that the client needs to authenticate to gain network access.
111+
112+
xxx_max = 1023
111113
};
112114

113115
inline bool isInformational(int code) { return (code >= 100 && code < 200); } //!< \returns \c true if the given \p code is an informational code.

HttpStatusCodes_C++11.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ enum class Code
108108
InsufficientStorage = 507, //!< Means the method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.
109109
LoopDetected = 508, //!< Indicates that the server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". [RFC 5842]
110110
NotExtended = 510, //!< The policy for accessing the resource has not been met in the request. [RFC 2774]
111-
NetworkAuthenticationRequired = 511 //!< Indicates that the client needs to authenticate to gain network access.
111+
NetworkAuthenticationRequired = 511, //!< Indicates that the client needs to authenticate to gain network access.
112112
};
113113

114114
/*! Converts a Code to its corresponding integer value.

HttpStatusCodes_C.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ enum HttpStatus_Code
101101
HttpStatus_InsufficientStorage = 507, /*!< Means the method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request. */
102102
HttpStatus_LoopDetected = 508, /*!< Indicates that the server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". [RFC 5842] */
103103
HttpStatus_NotExtended = 510, /*!< The policy for accessing the resource has not been met in the request. [RFC 2774] */
104-
HttpStatus_NetworkAuthenticationRequired = 511 /*!< Indicates that the client needs to authenticate to gain network access. */
104+
HttpStatus_NetworkAuthenticationRequired = 511, /*!< Indicates that the client needs to authenticate to gain network access. */
105+
106+
HttpStatus_xxx_max = 1023
105107
};
106108

107109
static char HttpStatus_isInformational(int code) { return (code >= 100 && code < 200); } /*!< \returns \c true if the given \p code is an informational code. */

HttpStatusCodes_Qt.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ enum Code
117117
InsufficientStorage = 507, //!< Means the method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.
118118
LoopDetected = 508, //!< Indicates that the server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". [RFC 5842]
119119
NotExtended = 510, //!< The policy for accessing the resource has not been met in the request. [RFC 2774]
120-
NetworkAuthenticationRequired = 511 //!< Indicates that the client needs to authenticate to gain network access.
120+
NetworkAuthenticationRequired = 511, //!< Indicates that the client needs to authenticate to gain network access.
121+
122+
xxx_max = 1023
121123
};
122124
#if (QT_VERSION >= QT_VERSION_CHECK(5,8,0))
123125
Q_ENUM_NS(Code)

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ Initially, the data was taken from [for-GET/know-your-http-well](https://github.
2727

2828
## Variants ##
2929

30-
| Variant | Scoping | Status Codes | Reason Phrases |
31-
|----------------------------------|------------------------|------------------------------------------------------------------------------------------------|----------------|
32-
| [C](HttpStatusCodes_C.h) | Prefix `HttpStatus_` | `enum HttpStatus_Code` | `const char*` |
33-
| [C++](HttpStatusCodes_C++.h) | Namespace `HttpStatus` | `enum Code` | `std::string` |
34-
| [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 |
31+
|----------------------------------|------------------------|------------------------------------------------------------------------------------------------|---------------------|
32+
| [C](HttpStatusCodes_C.h) | Prefix `HttpStatus_` | `enum HttpStatus_Code` | `const char*` |
33+
| [C++](HttpStatusCodes_C++.h) | Namespace `HttpStatus` | `enum Code` | `std::string` |
34+
| [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` |
3636

3737

3838
> 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.
@@ -65,6 +65,9 @@ void printReplyStatus(MyHttpReplyClass reply)
6565
6666
For the complete list of defined enums, see one of the header files.
6767
68+
> **Note:** The maximum supported value for the enums is `1023`. Trying to convert bigger values to the enum types
69+
might be undefined behavior.
70+
6871
##### C Variant #####
6972
```c
7073
enum HttpStatus_Code

0 commit comments

Comments
 (0)