libzypp 17.31.23
providemessage.cc File Reference
#include "private/providemessage_p.h"
#include <zypp-core/Url.h>
#include <string_view>
#include <string>
Include dependency graph for providemessage.cc:

Go to the source code of this file.

Namespaces

namespace  zyppng
 

Macros

#define DEF_REQ_FIELD(fname)   bool has_##fname = false
 
#define REQ_FIELD_CHECK(msgtype, fname, ftype)
 
#define OR_REQ_FIELD_CHECK(msgtype, fname, ftype)   else REQ_FIELD_CHECK( msgtype, fname, ftype )
 
#define OPT_FIELD_CHECK(msgtype, fname, ftype)
 
#define OR_OPT_FIELD_CHECK(msgtype, fname, ftype)   else OPT_FIELD_CHECK( msgtype, fname, ftype )
 
#define FAIL_IF_NOT_SEEN_REQ_FIELD(msgtype, fname)
 
#define FAIL_IF_ERROR()    if ( error ) return expected<void>::error( error )
 

Functions

static ProvideMessage::FieldVal zyppng::fieldValFromProto (const zypp::proto::DataField &field)
 
static void zyppng::fieldValToProto (const ProvideMessage::FieldVal &val, zypp::proto::DataField &field)
 
static expected< void > zyppng::validateMessage (const ProvideMessage &msg)
 

Macro Definition Documentation

◆ DEF_REQ_FIELD

#define DEF_REQ_FIELD (   fname)    bool has_##fname = false

◆ REQ_FIELD_CHECK

#define REQ_FIELD_CHECK (   msgtype,
  fname,
  ftype 
)
Value:
if ( name == #fname ) { \
if ( !std::holds_alternative<ftype>(val.asVariant()) ) { \
error = ZYPP_EXCPT_PTR( InvalidMessageReceivedException( zypp::str::Str() << "Parse error " << #msgtype << ", Field " << #fname << " has invalid type" ) ); \
return false; \
} \
has_##fname = true; \
}
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition: String.h:212
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
Definition: Exception.h:432

◆ OR_REQ_FIELD_CHECK

#define OR_REQ_FIELD_CHECK (   msgtype,
  fname,
  ftype 
)    else REQ_FIELD_CHECK( msgtype, fname, ftype )

◆ OPT_FIELD_CHECK

#define OPT_FIELD_CHECK (   msgtype,
  fname,
  ftype 
)
Value:
if ( name == #fname ) { \
if ( !std::holds_alternative<ftype>(val.asVariant() ) ) { \
error = ZYPP_EXCPT_PTR( InvalidMessageReceivedException( zypp::str::Str() << "Parse error " << #msgtype << ", Field " << #fname << " has invalid type" ) ); \
return false; \
} \
}

◆ OR_OPT_FIELD_CHECK

#define OR_OPT_FIELD_CHECK (   msgtype,
  fname,
  ftype 
)    else OPT_FIELD_CHECK( msgtype, fname, ftype )

◆ FAIL_IF_NOT_SEEN_REQ_FIELD

#define FAIL_IF_NOT_SEEN_REQ_FIELD (   msgtype,
  fname 
)
Value:
if ( !has_##fname ) \
return expected<void>::error( ZYPP_EXCPT_PTR( InvalidMessageReceivedException( zypp::str::Str() << #msgtype <<" message does not contain required " << #fname << " field" ) ) )

◆ FAIL_IF_ERROR

#define FAIL_IF_ERROR ( )     if ( error ) return expected<void>::error( error )