Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/include/rti/apputils/http/common/StatusCode.hpp
T

91 lines
2.4 KiB
C++

/*
* (c) Copyright, Real-Time Innovations, 2022.
* All rights reserved.
*
* No duplications, whole or partial, manual or electronic, may be made
* without express written permission. Any such copies, or
* revisions thereof, must display this notice unaltered.
* This code contains trade secrets of Real-Time Innovations, Inc.
*/
#ifndef HTTP_STATUS_CODE_HPP
#define HTTP_STATUS_CODE_HPP
#include <string>
namespace rti { namespace apputils { namespace http {
/**
* @brief Enum class with HTTP status codes.
*/
enum class StatusCode {
ok = 200,
created = 201,
accepted = 202,
no_content = 204,
multiple_choices = 300,
moved_permanently = 301,
moved_temporarily = 302,
not_modified = 304,
bad_request = 400,
unauthorized = 401,
forbidden = 403,
not_found = 404,
not_allowed = 405,
internal_server_error = 500,
not_implemented = 501,
bad_gateway = 502,
service_unavailable = 503
};
/**
* @brief Convert a StatusCode enum to an std::string
*
* @param status_code StatusCode enum to convert
* @return std::string with the status code name
*/
inline std::string status_code_to_string(StatusCode status_code)
{
switch (status_code) {
case StatusCode::ok:
return "OK";
case StatusCode::created:
return "Created";
case StatusCode::accepted:
return "Accepted";
case StatusCode::no_content:
return "No Content";
case StatusCode::multiple_choices:
return "Multiple Choices";
case StatusCode::moved_permanently:
return "Moved Permanently";
case StatusCode::moved_temporarily:
return "Moved Temporarily";
case StatusCode::not_modified:
return "Not Modified";
case StatusCode::bad_request:
return "Bad Request";
case StatusCode::unauthorized:
return "Unauthorized";
case StatusCode::forbidden:
return "Forbidden";
case StatusCode::not_found:
return "Not Found";
case StatusCode::not_allowed:
return "Not Allowed";
case StatusCode::internal_server_error:
return "Internal Server Error";
case StatusCode::not_implemented:
return "Not Implemented";
case StatusCode::bad_gateway:
return "Bad Gateway";
case StatusCode::service_unavailable:
return "Service Unavailable";
default:
return "";
}
}
}}} // namespace rti::apputils::http
#endif // HTTP_STATUS_CODE_HPP