15#ifndef ZYPP_CORE_ZYPPNG_RPC_STOMPFRAMESTREAM_H_INCLUDED
16#define ZYPP_CORE_ZYPPNG_RPC_STOMPFRAMESTREAM_H_INCLUDED
19#include <zypp-core/zyppng/base/Base>
20#include <zypp-core/zyppng/core/String>
21#include <zypp-core/zyppng/base/Signals>
22#include <zypp-core/zyppng/base/Timer>
23#include <zypp-core/zyppng/io/IODevice>
45 return msg.toStompMessage();
50 return T::fromStompMessage( message );
58 if constexpr ( std::is_same_v<bool, T> ) {
60 if ( indeterminate(triBool) ) {
64 }
else if constexpr ( std::is_same_v<std::string, T> ) {
84 return zypp::PluginFrame ( std::string( T::typeName.data(), T::typeName.length() ) );
98 using Ptr = StompFrameStreamRef;
114 std::optional<zypp::PluginFrame> nextMessage (
const std::string &msgName =
"" );
124 std::optional<zypp::PluginFrame> nextMessageWait (
const std::string &msgName =
"" );
132 template <
typename T>
135 if constexpr ( std::is_same_v<T, zypp::PluginFrame> ) {
140 ERR <<
"Failed to serialize message" << std::endl;
156 void readAllMessages ();
171 bool readNextMessage ();
179 } _parserState = ReceiveCommand;
Base class for Exception.
const std::string & msg() const
Return the message string provided to the ctor.
Base class for PluginFrame Exception.
Command frame for communication with PluginScript.
const std::string & getHeader(const std::string &key_r) const
Return header value for key_r.
std::shared_ptr< IODevice > Ptr
InvalidMessageReceivedException(const std::string &msg={})
std::optional< int64_t > _pendingBodyLen
Signal< void()> _sigNextMessage
std::deque< zypp::PluginFrame > _messages
StompFrameStream(IODevice::Ptr iostr)
std::optional< zypp::PluginFrame > _pendingMessage
static Ptr create(IODevice::Ptr iostr)
Signal< void()> _sigInvalidMessageReceived
Timer::Ptr _nextMessageTimer
static expected< T > parseMessage(const zypp::PluginFrame &m)
bool sendFrame(const zypp::PluginFrame &message)
bool sendMessage(const T &message)
The Timer class provides repetitive and single-shot timers.
static std::shared_ptr< Timer > create()
Creates a new Timer object, the timer is not started at this point.
std::shared_ptr< Timer > Ptr
Iostream related utilities.
TriBool strToTriBool(const C_Str &str)
Parse str into a bool if it's a legal true or false string; else indeterminate.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
void parseHeaderIntoField(const zypp::PluginFrame &msg, const std::string &name, T &target)
expected< zypp::PluginFrame > toStompMessage(const T &msg)
expected< T > fromStompMessage(const zypp::PluginFrame &message)
void parseDataIntoField(const std::string &headerVal, T &target)
zypp::PluginFrame prepareFrame()
std::optional< T > safe_strtonum(const std::string_view &val)
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)