From: Arvin Schnell Date: Thu, 26 Jan 2023 12:44:01 +0000 (+0100) Subject: - added const X-Git-Tag: v0.10.5~60^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f3d6ff82c2f75ee8d3f3d07f00853e9c9d9d9ab6;p=thirdparty%2Fsnapper.git - added const --- diff --git a/zypp-plugin/zypp-plugin.cc b/zypp-plugin/zypp-plugin.cc index b7027cd6..26403376 100644 --- a/zypp-plugin/zypp-plugin.cc +++ b/zypp-plugin/zypp-plugin.cc @@ -48,21 +48,8 @@ ZyppPlugin::main() } -void -ZyppPlugin::write_message(ostream& os, const Message& msg) -{ - os << msg.command << endl; - for (auto it: msg.headers) { - os << it.first << ':' << it.second << endl; - } - os << endl; - os << msg.body << '\0'; - os.flush(); -} - - ZyppPlugin::Message -ZyppPlugin::read_message(istream& is) +ZyppPlugin::read_message(istream& is) const { enum class State { Start, Headers, Body } state = State::Start; @@ -127,13 +114,23 @@ ZyppPlugin::read_message(istream& is) } +void +ZyppPlugin::write_message(ostream& os, const Message& msg) const +{ + os << msg.command << endl; + for (auto it : msg.headers) + os << it.first << ':' << it.second << endl; + os << endl; + os << msg.body << '\0'; + os.flush(); +} + + ZyppPlugin::Message ZyppPlugin::dispatch(const Message& msg) { if (msg.command == "_DISCONNECT") - { return ack(); - } Message a; a.command = "_ENOMETHOD"; diff --git a/zypp-plugin/zypp-plugin.h b/zypp-plugin/zypp-plugin.h index bbe86860..cf51d05a 100644 --- a/zypp-plugin/zypp-plugin.h +++ b/zypp-plugin/zypp-plugin.h @@ -56,15 +56,15 @@ public: protected: + Message read_message(std::istream& is) const; + void write_message(std::ostream& os, const Message& msg) const; + /// Handle a message and return a reply. - // Derived classes should override it. + // Derived classes must override it. // The base acks a _DISCONNECT and replies _ENOMETHOD to everything else. - virtual Message dispatch(const Message& msg); - - Message read_message(std::istream& is); - void write_message(std::ostream& os, const Message& msg); + virtual Message dispatch(const Message& msg) = 0; - Message ack() + Message ack() const { Message a; a.command = "ACK";