mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 03:20:11 +01:00
use std::string literals in generated code
This commit is contained in:
@@ -68,7 +68,7 @@ void CodeWriter::writeImpl(std::ostream& ostr, const std::string& headerFileName
|
|||||||
ostr << "#include \"Poco/StreamCopier.h\"\n";
|
ostr << "#include \"Poco/StreamCopier.h\"\n";
|
||||||
ostr << "#include <sstream>\n";
|
ostr << "#include <sstream>\n";
|
||||||
}
|
}
|
||||||
ostr << "\n\n";
|
ostr << "\n\nusing namespace std::string_literals;\n\n";
|
||||||
|
|
||||||
std::string decls(_page.implDecls().str());
|
std::string decls(_page.implDecls().str());
|
||||||
if (!decls.empty())
|
if (!decls.empty())
|
||||||
@@ -328,24 +328,24 @@ void CodeWriter::writeResponse(std::ostream& ostr)
|
|||||||
ostr << "\tresponse.setChunkedTransferEncoding(true);\n";
|
ostr << "\tresponse.setChunkedTransferEncoding(true);\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
ostr << "\tresponse.setContentType(\"" << contentType << "\");\n";
|
ostr << "\tresponse.setContentType(\"" << contentType << "\"s);\n";
|
||||||
if (!contentLang.empty())
|
if (!contentLang.empty())
|
||||||
{
|
{
|
||||||
ostr << "\tif (request.has(\"Accept-Language\"))\n"
|
ostr << "\tif (request.has(\"Accept-Language\"s))\n"
|
||||||
<< "\t\tresponse.set(\"Content-Language\", \"" << contentLang << "\");\n";
|
<< "\t\tresponse.set(\"Content-Language\"s, \"" << contentLang << "\"s);\n";
|
||||||
}
|
}
|
||||||
if (!contentSecurityPolicy.empty())
|
if (!contentSecurityPolicy.empty())
|
||||||
{
|
{
|
||||||
ostr << "\tresponse.set(\"Content-Secure-Policy\", \"" << contentSecurityPolicy << "\");\n";
|
ostr << "\tresponse.set(\"Content-Secure-Policy\"s, \"" << contentSecurityPolicy << "\"s);\n";
|
||||||
}
|
}
|
||||||
if (compressed)
|
if (compressed)
|
||||||
{
|
{
|
||||||
ostr << "\tbool _compressResponse(request.hasToken(\"Accept-Encoding\", \"gzip\"));\n"
|
ostr << "\tbool _compressResponse(request.hasToken(\"Accept-Encoding\"s, \"gzip\"s));\n"
|
||||||
<< "\tif (_compressResponse) response.set(\"Content-Encoding\", \"gzip\");\n";
|
<< "\tif (_compressResponse) response.set(\"Content-Encoding\"s, \"gzip\"s);\n";
|
||||||
}
|
}
|
||||||
if (!cacheControl.empty())
|
if (!cacheControl.empty())
|
||||||
{
|
{
|
||||||
ostr << "\tresponse.set(\"Cache-Control\", \"" << cacheControl << "\");\n";
|
ostr << "\tresponse.set(\"Cache-Control\"s, \"" << cacheControl << "\"s);\n";
|
||||||
}
|
}
|
||||||
ostr << "\n";
|
ostr << "\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,14 +107,14 @@ void OSPCodeWriter::writeSession(std::ostream& ostr)
|
|||||||
std::string sessionCode;
|
std::string sessionCode;
|
||||||
if (session.empty()) return;
|
if (session.empty()) return;
|
||||||
if (session[0] == '@')
|
if (session[0] == '@')
|
||||||
sessionCode = "context()->thisBundle()->properties().getString(\"" + session.substr(1) + "\")";
|
sessionCode = "context()->thisBundle()->properties().getString(\"" + session.substr(1) + "\"s)";
|
||||||
else
|
else
|
||||||
sessionCode = "\"" + session + "\"";
|
sessionCode = "\"" + session + "\"s";
|
||||||
std::string sessionTimeoutCode = page().get("page.sessionTimeout", "30");
|
std::string sessionTimeoutCode = page().get("page.sessionTimeout", "30");
|
||||||
int sessionTimeout;
|
int sessionTimeout;
|
||||||
if (!Poco::NumberParser::tryParse(sessionTimeoutCode, sessionTimeout))
|
if (!Poco::NumberParser::tryParse(sessionTimeoutCode, sessionTimeout))
|
||||||
{
|
{
|
||||||
sessionTimeoutCode = "context()->thisBundle()->properties().getInt(\"" + sessionTimeoutCode + "\")";
|
sessionTimeoutCode = "context()->thisBundle()->properties().getInt(\"" + sessionTimeoutCode + "\"s)";
|
||||||
}
|
}
|
||||||
ostr << "\tPoco::OSP::Web::WebSession::Ptr session;\n";
|
ostr << "\tPoco::OSP::Web::WebSession::Ptr session;\n";
|
||||||
ostr << "\t{\n";
|
ostr << "\t{\n";
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public:
|
|||||||
~PageReader();
|
~PageReader();
|
||||||
/// Destroys the PageReader.
|
/// Destroys the PageReader.
|
||||||
|
|
||||||
void parse(std::istream& pageStream);
|
void parse(std::istream& pageStream);
|
||||||
/// Parses a HTML file containing server page directives,
|
/// Parses a HTML file containing server page directives,
|
||||||
/// converts the file into C++ code and adds the code
|
/// converts the file into C++ code and adds the code
|
||||||
/// to the reader's Page object. Also parses page
|
/// to the reader's Page object. Also parses page
|
||||||
@@ -74,7 +74,7 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void generateLineDirective(std::ostream& ostr);
|
void generateLineDirective(std::ostream& ostr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PageReader();
|
PageReader();
|
||||||
PageReader(const PageReader&);
|
PageReader(const PageReader&);
|
||||||
|
|||||||
Reference in New Issue
Block a user