mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use std::string_view for passing NetworkError strings
parent
8aa2f6b8a6
commit
31433882a4
|
@ -29,7 +29,7 @@
|
|||
* @param error The error code.
|
||||
* @param message The error message. Leave empty to determine this automatically based on the error number.
|
||||
*/
|
||||
NetworkError::NetworkError(int error, const std::string &message) : error(error), message(message)
|
||||
NetworkError::NetworkError(int error, std::string_view message) : error(error), message(message)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ bool NetworkError::IsConnectInProgress() const
|
|||
* Get the string representation of the error message.
|
||||
* @return The string representation that will get overwritten by next calls.
|
||||
*/
|
||||
const std::string &NetworkError::AsString() const
|
||||
std::string_view NetworkError::AsString() const
|
||||
{
|
||||
if (this->message.empty()) {
|
||||
#if defined(_WIN32)
|
||||
|
|
|
@ -23,13 +23,13 @@ private:
|
|||
int error; ///< The underlying error number from errno or WSAGetLastError.
|
||||
mutable std::string message; ///< The string representation of the error (set on first call to #AsString).
|
||||
public:
|
||||
NetworkError(int error, const std::string &message = {});
|
||||
NetworkError(int error, std::string_view message = {});
|
||||
|
||||
bool HasError() const;
|
||||
bool WouldBlock() const;
|
||||
bool IsConnectionReset() const;
|
||||
bool IsConnectInProgress() const;
|
||||
const std::string &AsString() const;
|
||||
std::string_view AsString() const;
|
||||
|
||||
static NetworkError GetLast();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue