From 7d9b5a708461a1640d948ef3d8b5044b92a1cf01 Mon Sep 17 00:00:00 2001 From: emeric Date: Sun, 22 Oct 2023 00:19:03 +0200 Subject: [PATCH] More constness --- src/libs/subsonic/impl/SubsonicResource.cpp | 5 ++--- src/libs/subsonic/impl/SubsonicResponse.cpp | 7 +++---- src/libs/subsonic/impl/SubsonicResponse.hpp | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libs/subsonic/impl/SubsonicResource.cpp b/src/libs/subsonic/impl/SubsonicResource.cpp index c38bc0d0..4b62014c 100644 --- a/src/libs/subsonic/impl/SubsonicResource.cpp +++ b/src/libs/subsonic/impl/SubsonicResource.cpp @@ -288,12 +288,11 @@ namespace API::Subsonic 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); 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; } diff --git a/src/libs/subsonic/impl/SubsonicResponse.cpp b/src/libs/subsonic/impl/SubsonicResponse.cpp index 7450792e..ed28c49c 100644 --- a/src/libs/subsonic/impl/SubsonicResponse.cpp +++ b/src/libs/subsonic/impl/SubsonicResponse.cpp @@ -170,7 +170,7 @@ namespace API::Subsonic 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) { @@ -183,7 +183,7 @@ namespace API::Subsonic } } - void Response::writeXML(std::ostream& os) + void Response::writeXML(std::ostream& os) const { std::function nodeToPropertyTree = [&](const Node& node) { @@ -285,7 +285,6 @@ namespace API::Subsonic first = false; } - for (const auto& [key, childArrayNodes] : node._childrenArrays) { if (!first) @@ -370,7 +369,7 @@ namespace API::Subsonic os << '\"'; } - void Response::writeJSON(std::ostream& os) + void Response::writeJSON(std::ostream& os) const { JsonSerializer serializer; serializer.serializeNode(os, _root); diff --git a/src/libs/subsonic/impl/SubsonicResponse.hpp b/src/libs/subsonic/impl/SubsonicResponse.hpp index 9fe51a5b..4414d4d1 100644 --- a/src/libs/subsonic/impl/SubsonicResponse.hpp +++ b/src/libs/subsonic/impl/SubsonicResponse.hpp @@ -259,7 +259,7 @@ namespace API::Subsonic Node& createNode(Node::Key key); Node& createArrayNode(Node::Key key); - void write(std::ostream& os, ResponseFormat format); + void write(std::ostream& os, ResponseFormat format) const; private: 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 writeJSON(std::ostream& os); - void writeXML(std::ostream& os); + void writeJSON(std::ostream& os) const; + void writeXML(std::ostream& os) const; Response() = default; Node _root;