21#undef ZYPP_BASE_LOGGER_LOGGROUP
22#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::plugin"
64 if (
command_r.find(
'\n' ) != std::string::npos )
69 const std::string &
body()
const
79 using constKeyRange = std::pair<HeaderListIterator, HeaderListIterator>;
80 using KeyRange = std::pair<HeaderList::iterator, HeaderList::iterator>;
91 if (
r.first ==
r.second )
93 const std::string &
ret(
r.first->second );
94 if ( ++
r.first !=
r.second )
102 if (
r.first ==
r.second )
104 const std::string &
ret(
r.first->second );
105 if ( ++
r.first !=
r.second )
118 if (
key_r.find_first_of(
":\n" ) != std::string::npos )
120 if (
value_r.find_first_of(
'\n' ) != std::string::npos )
166 {
return new Impl( *
this ); }
173 return str <<
"PluginFrame[" <<
obj.command() <<
"](" <<
obj.headerList().size() <<
"){" <<
obj.body().size() <<
"}";
203 std::string::size_type
sep( data.find(
':') );
204 if (
sep == std::string::npos )
207 _header.insert( HeaderList::value_type( data.substr(0,
sep), data.substr(
sep+1) ) );
225 for_(
it, _header.begin(), _header.end() )
244 static std::string _val(
"ACK" );
250 static std::string _val(
"ERROR" );
256 static std::string _val(
"_ENOMETHOD" );
285 {
return _pimpl->empty(); }
288 {
return _pimpl->command(); }
294 {
return _pimpl->body(); }
297 {
return _pimpl->bodyRef(); }
306 {
return _pimpl->headerList(); }
309 {
return _pimpl->headerList(); }
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
shared_ptr< Impl > _pimpl
Base class for PluginFrame Exception.
Command frame for communication with PluginScript.
static const std::string & ackCommand()
"ACK" command.
void setCommand(const std::string &command_r)
Set the frame command.
HeaderList::const_iterator HeaderListIterator
Header list iterator.
void setBody(const std::string &body_r)
Set the frame body.
const std::string & body() const
Return the frame body.
const std::initializer_list< std::pair< std::string, std::string > > & HeaderInitializerList
PluginFrame()
Default ctor (empty frame)
std::string & bodyRef()
Return a reference to the frame body.
void clearHeader(const std::string &key_r)
Remove all headers for key_r.
bool empty() const
Whether this is an empty frame.
static const std::string & enomethodCommand()
"_ENOMETHOD" command.
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.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
static const std::string & errorCommand()
"ERROR" command.
const std::string & getHeader(const std::string &key_r) const
Return header value for key_r.
std::multimap< std::string, std::string > HeaderList
The header list.
HeaderList & headerList()
Modifyalble header list for internal use only.
void setHeader(const std::string &key_r, const std::string &value_r=std::string())
Set header for key_r removing all other occurrences of key_r.
const std::string & getHeaderNT(const std::string &key_r, const std::string &default_r=std::string()) const
Not throwing version returing one of the matching header values or default_r string.
std::ostream & writeTo(std::ostream &stream_r) const
Write frame to stream.
String related utilities and Regular expression matching.
std::string receiveUpTo(std::istream &str, const char delim_r, bool returnDelim_r)
Return stream content up to the next ocurrence of delim_r or EOF delim_r, if found,...
std::string getline(std::istream &str, const Trim trim_r)
Return stream content up to (but not returning) the next newline.
Easy-to use interface to the ZYPP dependency resolver.
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
PluginFrame implementation.
std::ostream & writeTo(std::ostream &stream_r) const
const std::string & body() const
void setCommand(const std::string &command_r)
Impl(const std::string &command_r, HeaderInitializerList contents_r)
const std::string & getHeader(const std::string &key_r) const
Impl(const std::string &command_r, std::string &&body_r)
static shared_ptr< Impl > nullimpl()
Offer default Impl.
const std::string & command() const
const std::string & getHeaderNT(const std::string &key_r, const std::string &default_r) const
HeaderList & headerList()
Impl(const std::string &command_r)
const HeaderList & headerList() const
std::pair< HeaderListIterator, HeaderListIterator > constKeyRange
const std::string & getHeader(const std::string &key_r, const std::string &default_r) const
void setBody(const std::string &body_r)
void setHeader(const std::string &key_r, const std::string &value_r)
void clearHeader(const std::string &key_r)
void addHeader(const std::string &key_r, const std::string &value_r)
std::pair< HeaderList::iterator, HeaderList::iterator > KeyRange
Impl * clone() const
clone for RWCOW_pointer
void addHeader(HeaderInitializerList contents_r)
HeaderList::value_type mkHeaderPair(const std::string &key_r, const std::string &value_r)
Impl(const std::string &command_r, std::string &&body_r, HeaderInitializerList contents_r)
std::ostream & operator<<(std::ostream &str, const PluginFrame::Impl &obj)
Stream output.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.