12#include <zypp-core/ng/core/String>
22 void serializeStepField (
ByteArray &data,
const T&field ) {
23 if constexpr ( std::is_same_v<bool, T> ) {
26 data.push_back (
'\0');
29 data.push_back (
'\0');
31 }
else if constexpr ( std::is_same_v<std::string, T> ) {
32 data.insert(data.end(), field.begin(), field.end() );
33 data.push_back (
'\0');
41 std::string fetchTerminatedField ( ByteArray::const_iterator &i, ByteArray::const_iterator end,
const char term =
'\0' ){
51 fData.push_back( *i );
55 fData.shrink_to_fit();
60 using has_stepid =
decltype(std::declval<T>().stepId);
75 if ( msg.
command() != T::typeName )
91#define IMPL_TRIVIAL_MESSAGE( Type ) \
92 zyppng::expected<PluginFrame> Type::toStompMessage() const \
94 return makeTrivialMessage( #Type, *this ); \
97 zyppng::expected<Type> Type::fromStompMessage(const PluginFrame &msg) \
99 return parseTrivialMessage<Type>( msg ); \
114 if ( std::holds_alternative<InstallStep>(step) ) {
115 const InstallStep &value = std::get<InstallStep>(step);
117 serializeStepField( body, value.
stepId );
118 serializeStepField( body, value.
pathname );
121 }
else if ( std::holds_alternative<RemoveStep>(step) ) {
122 const RemoveStep &value = std::get<RemoveStep>(step);
124 serializeStepField( body, value.
stepId );
125 serializeStepField( body, value.
name );
126 serializeStepField( body, value.
version );
127 serializeStepField( body, value.
release );
128 serializeStepField( body, value.
arch );
133 body.shrink_to_fit();
160 const auto &data = msg.
body ();
161 for (
auto i = data.begin(); i != data.end(); ) {
162 uint8_t stepType = *i;
165 if ( i == data.end() )
168 switch ( stepType ) {
204 for (
const auto &err :
problems ) {
205 serializeStepField ( body, err );
217 const auto &data = msg.
body ();
218 for (
auto i = data.begin(); i != data.end(); ) {
219 c.
problems.push_back( fetchTerminatedField( i, data.end() ) );
#define IMPL_TRIVIAL_MESSAGE(Type)
std::string asString() const
Base class for Exception.
Base class for PluginFrame Exception.
Command frame for communication with PluginScript.
ByteArray & bodyRef()
Return a reference to the frame body.
void setBody(const std::string &body_r)
Set the frame body.
const ByteArray & body() const
Return the frame body.
const std::string & command() const
Return the frame command.
void addHeader(const std::string &key_r, const std::string &value_r=std::string())
Add header for key_r leaving already existing headers for key_r unchanged.
static expected success(ConsParams &&...params)
constexpr bool is_detected_v
std::string numstring(char n, int w=0)
std::string asString(const Patch::Category &obj)
void parseHeaderIntoField(const zypp::PluginFrame &msg, const std::string &name, T &target)
void parseDataIntoField(const std::string &headerVal, T &target)
zypp::PluginFrame prepareFrame()
static zyppng::expected< CleanupBegin > fromStompMessage(const zypp::PluginFrame &msg)
static constexpr std::string_view typeName
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static constexpr std::string_view typeName
static zyppng::expected< CleanupFinished > fromStompMessage(const zypp::PluginFrame &msg)
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static constexpr std::string_view typeName
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static zyppng::expected< CleanupProgress > fromStompMessage(const zypp::PluginFrame &msg)
std::vector< TransactionStep > transactionSteps
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static constexpr std::string_view typeName
static zyppng::expected< Commit > fromStompMessage(const zypp::PluginFrame &msg)
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static zyppng::expected< PackageProgress > fromStompMessage(const zypp::PluginFrame &msg)
static constexpr std::string_view typeName
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static constexpr std::string_view typeName
static zyppng::expected< RpmLog > fromStompMessage(const zypp::PluginFrame &msg)
static constexpr std::string_view typeName
std::string scriptPackage
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static zyppng::expected< ScriptBegin > fromStompMessage(const zypp::PluginFrame &msg)
static zyppng::expected< ScriptError > fromStompMessage(const zypp::PluginFrame &msg)
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static constexpr std::string_view typeName
static constexpr std::string_view typeName
static zyppng::expected< TransBegin > fromStompMessage(const zypp::PluginFrame &msg)
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static zyppng::expected< TransProgress > fromStompMessage(const zypp::PluginFrame &msg)
static constexpr std::string_view typeName
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static constexpr std::string_view typeName
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static zyppng::expected< TransactionError > fromStompMessage(const zypp::PluginFrame &msg)
std::vector< std::string > problems
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.