More constness

This commit is contained in:
emeric
2023-10-22 00:19:03 +02:00
parent 61e0931a82
commit 7d9b5a7084
3 changed files with 8 additions and 10 deletions
+2 -3
View File
@@ -288,12 +288,11 @@ namespace API::Subsonic
checkUserTypeIsAllowed(requestContext, itEntryPoint->second.allowedUserTypes); checkUserTypeIsAllowed(requestContext, itEntryPoint->second.allowedUserTypes);
Response resp{ (itEntryPoint->second.func)(requestContext) }; const Response resp{ (itEntryPoint->second.func)(requestContext) };
LMS_LOG(API_SUBSONIC, DEBUG) << "Request " << requestId << " '" << requestPath << "' handled!";
resp.write(response.out(), format); resp.write(response.out(), format);
response.setMimeType(std::string{ ResponseFormatToMimeType(format) }); response.setMimeType(std::string{ ResponseFormatToMimeType(format) });
LMS_LOG(API_SUBSONIC, DEBUG) << "Request " << requestId << " '" << requestPath << "' written!"; LMS_LOG(API_SUBSONIC, DEBUG) << "Request " << requestId << " '" << requestPath << "' handled!";
return; return;
} }
+3 -4
View File
@@ -170,7 +170,7 @@ namespace API::Subsonic
return _root._children["subsonic-response"].createArrayChild(key); return _root._children["subsonic-response"].createArrayChild(key);
} }
void Response::write(std::ostream& os, ResponseFormat format) void Response::write(std::ostream& os, ResponseFormat format) const
{ {
switch (format) switch (format)
{ {
@@ -183,7 +183,7 @@ namespace API::Subsonic
} }
} }
void Response::writeXML(std::ostream& os) void Response::writeXML(std::ostream& os) const
{ {
std::function<boost::property_tree::ptree(const Node&)> nodeToPropertyTree = [&](const Node& node) std::function<boost::property_tree::ptree(const Node&)> nodeToPropertyTree = [&](const Node& node)
{ {
@@ -285,7 +285,6 @@ namespace API::Subsonic
first = false; first = false;
} }
for (const auto& [key, childArrayNodes] : node._childrenArrays) for (const auto& [key, childArrayNodes] : node._childrenArrays)
{ {
if (!first) if (!first)
@@ -370,7 +369,7 @@ namespace API::Subsonic
os << '\"'; os << '\"';
} }
void Response::writeJSON(std::ostream& os) void Response::writeJSON(std::ostream& os) const
{ {
JsonSerializer serializer; JsonSerializer serializer;
serializer.serializeNode(os, _root); serializer.serializeNode(os, _root);
+3 -3
View File
@@ -259,7 +259,7 @@ namespace API::Subsonic
Node& createNode(Node::Key key); Node& createNode(Node::Key key);
Node& createArrayNode(Node::Key key); Node& createArrayNode(Node::Key key);
void write(std::ostream& os, ResponseFormat format); void write(std::ostream& os, ResponseFormat format) const;
private: private:
static Response createResponseCommon(ProtocolVersion protocolVersion, const Error* error = nullptr); static Response createResponseCommon(ProtocolVersion protocolVersion, const Error* error = nullptr);
@@ -272,8 +272,8 @@ namespace API::Subsonic
void serializeEscapedString(std::ostream&, std::string_view str); void serializeEscapedString(std::ostream&, std::string_view str);
}; };
void writeJSON(std::ostream& os); void writeJSON(std::ostream& os) const;
void writeXML(std::ostream& os); void writeXML(std::ostream& os) const;
Response() = default; Response() = default;
Node _root; Node _root;