debug formatting for c++20

This commit is contained in:
Benedek László 2024-07-07 21:56:03 +02:00
parent 3fc5402b69
commit bcc5e2d9e5
2 changed files with 26 additions and 2 deletions

View File

@ -2,6 +2,8 @@
#include <rum/http/request.h>
#if __cplusplus >= 202302L
#include <format>
#else
#include <sstream>
#endif
#include <iostream>
#include <string>
@ -19,7 +21,15 @@ Request::operator std::string() const {
cookie_string += "\t\t'" + cookie.first + "': '" + cookie.second + "'\n";
}
#if __cplusplus < 202302L
return "";
std::stringstream text;
text << "Request{{\n"
<< "\tmethod: " << method << "\n"
<< "\t" << (std::string)uri << "\n"
<< "\theaders: \n"
<< headers_string << "\tcookies: \n"
<< cookie_string << "\tbody: '" << body << "'\n}}";
return text.str();
#else
return std::vformat(
"Request{{\n"

View File

@ -2,8 +2,11 @@
#include <exception>
#include <iostream>
#include <regex>
#include <sstream>
#if __cplusplus >= 202302L
#include <format>
#else
#include <sstream>
#endif
#include <string>
@ -15,7 +18,18 @@ URI::operator std::string() const {
query += "\t\t'" + param.first + "': '" + param.second + "'\n";
}
#if __cplusplus < 202302L
return "";
std::stringstream text;
text << "URI{{"
<< "\n\tscheme: '" << scheme << "'"
<< "\n\tuser: '" << user << "'"
<< "\n\tpassword: '" << password << "'"
<< "\n\thost: '" << host << "'"
<< "\n\tport: '" << port << "'"
<< "\n\tpath: '" << path << "'"
<< "\n\tquery: \n"
<< query << "\n\tfragment: '" << fragment << "'\n}}";
return text.str();
#else
return std::vformat(
"URI{{"