|
| static std::string | simpleString (const std::string &str) |
| | Converts a simple string to RESP format.
|
| static std::string | error (const std::string &message) |
| | Converts an error message to RESP format.
|
| static std::string | integer (int value) |
| | Used to encode an integer to RESP format.
|
| static std::string | bulkString (const std::string &str, const bool isNull) |
| | Converts a bulk string to RESP format.
|
| static std::string | simpleString (const std::string &str) |
| | Converts a simple string to RESP format.
|
| static std::string | error (const std::string &message) |
| | Converts an error message to RESP format.
|
| static std::string | integer (int value) |
| | Used to encode an integer to RESP format.
|
| static std::string | bulkString (const std::string &str, const bool isNull) |
| | Converts a bulk string to RESP format.
|
◆ bulkString() [1/2]
| std::string RespEncoder::bulkString |
( |
const std::string & | str, |
|
|
const bool | isNull ) |
|
inlinestatic |
Converts a bulk string to RESP format.
- Parameters
-
| str | the string to be sent |
| isNull | true if the string is null |
- Returns
- std::string
The string is prefixed with a '$' character, followed by the length of the string, and suffixed with a CRLF sequence. If the string is null, it is represented as "$-1\r\n". If the string is empty, it is represented as "$0\r\n\r\n". This is the standard format for bulk strings in RESP. For example, the string "Hello" would be converted to "$5\r\nHello\r\n", and a null string would be converted to "$-1\r\n".
- Note
- The function handles both null and empty strings appropriately.
-
The function uses CRLF (Carriage Return Line Feed) as the line
◆ bulkString() [2/2]
| std::string RespEncoder::bulkString |
( |
const std::string & | str, |
|
|
const bool | isNull ) |
|
inlinestatic |
Converts a bulk string to RESP format.
- Parameters
-
| str | the string to be sent |
| isNull | true if the string is null |
- Returns
- std::string
The string is prefixed with a '$' character, followed by the length of the string, and suffixed with a CRLF sequence. If the string is null, it is represented as "$-1\r\n". If the string is empty, it is represented as "$0\r\n\r\n". This is the standard format for bulk strings in RESP. For example, the string "Hello" would be converted to "$5\r\nHello\r\n", and a null string would be converted to "$-1\r\n".
- Note
- The function handles both null and empty strings appropriately.
-
The function uses CRLF (Carriage Return Line Feed) as the line
◆ error() [1/2]
| std::string RespEncoder::error |
( |
const std::string & | message | ) |
|
|
inlinestatic |
Converts an error message to RESP format.
- Parameters
-
| message | the message to be sent |
- Returns
- std::string respresentation of the error message
The message is prefixed with a '-' character and suffixed with a CRLF sequence. This is the standard format for error messages in RESP. For example, the message "Error occurred" would be converted to "-Error occurred\r\n".
◆ error() [2/2]
| std::string RespEncoder::error |
( |
const std::string & | message | ) |
|
|
inlinestatic |
Converts an error message to RESP format.
- Parameters
-
| message | the message to be sent |
- Returns
- std::string respresentation of the error message
The message is prefixed with a '-' character and suffixed with a CRLF sequence. This is the standard format for error messages in RESP. For example, the message "Error occurred" would be converted to "-Error occurred\r\n".
◆ integer() [1/2]
| std::string RespEncoder::integer |
( |
int | value | ) |
|
|
inlinestatic |
Used to encode an integer to RESP format.
- Parameters
-
| value | the integer to be sent |
- Returns
- std::string respresentation of the integer
The integer is prefixed with a ':' character and suffixed with a CRLF sequence. This is the standard format for integers in RESP. For example, the integer 42 would be converted to ":42\r\n".
◆ integer() [2/2]
| std::string RespEncoder::integer |
( |
int | value | ) |
|
|
inlinestatic |
Used to encode an integer to RESP format.
- Parameters
-
| value | the integer to be sent |
- Returns
- std::string respresentation of the integer
The integer is prefixed with a ':' character and suffixed with a CRLF sequence. This is the standard format for integers in RESP. For example, the integer 42 would be converted to ":42\r\n".
◆ simpleString() [1/2]
| std::string RespEncoder::simpleString |
( |
const std::string & | str | ) |
|
|
inlinestatic |
Converts a simple string to RESP format.
- Parameters
-
- Returns
- std::string respresentation of the string
The string is prefixed with a '+' character and suffixed with a CRLF sequence. This is the standard format for simple strings in RESP. For example, the string "Hello" would be converted to "+Hello\r\n".
◆ simpleString() [2/2]
| std::string RespEncoder::simpleString |
( |
const std::string & | str | ) |
|
|
inlinestatic |
Converts a simple string to RESP format.
- Parameters
-
- Returns
- std::string respresentation of the string
The string is prefixed with a '+' character and suffixed with a CRLF sequence. This is the standard format for simple strings in RESP. For example, the string "Hello" would be converted to "+Hello\r\n".
The documentation for this class was generated from the following files: