13#include <zypp/base/LogTools.h>
14#include <zypp/base/String.h>
20#undef ZYPP_BASE_LOGGER_LOGGROUP
21#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::plugin"
63 if (
command_r.find(
'\n' ) != std::string::npos )
68 const std::string &
body()
const
79 typedef std::pair<HeaderList::iterator,HeaderList::iterator>
KeyRange;
90 if (
r.first ==
r.second )
92 const std::string &
ret(
r.first->second );
93 if ( ++
r.first !=
r.second )
101 if (
r.first ==
r.second )
103 const std::string &
ret(
r.first->second );
104 if ( ++
r.first !=
r.second )
117 if (
key_r.find_first_of(
":\n" ) != std::string::npos )
119 if (
value_r.find_first_of(
"\n" ) != std::string::npos )
165 {
return new Impl( *
this ); }
172 return str <<
"PluginFrame[" <<
obj.command() <<
"](" <<
obj.headerList().size() <<
"){" <<
obj.body().size() <<
"}";
202 std::string::size_type
sep( data.find(
':') );
203 if (
sep == std::string::npos )
206 _header.insert( HeaderList::value_type( data.substr(0,
sep), data.substr(
sep+1) ) );
224 for_(
it, _header.begin(), _header.end() )
243 static std::string _val(
"ACK" );
249 static std::string _val(
"ERROR" );
255 static std::string _val(
"_ENOMETHOD" );
284 {
return _pimpl->empty(); }
287 {
return _pimpl->command(); }
293 {
return _pimpl->body(); }
296 {
return _pimpl->bodyRef(); }
305 {
return _pimpl->headerList(); }
308 {
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.
const std::initializer_list< std::pair< std::string, std::string > > & HeaderInitializerList
static const std::string & ackCommand()
"ACK" command.
void setCommand(const std::string &command_r)
Set the frame command.
void setBody(const std::string &body_r)
Set the frame body.
const std::string & body() const
Return the frame body.
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.
HeaderList::const_iterator HeaderListIterator
Header list iterator.
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.
std::multimap< std::string, std::string > HeaderList
The header list.
const std::string & getHeader(const std::string &key_r) const
Return header value for key_r.
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 getline(std::istream &str, const Trim trim_r)
Return stream content up to (but not returning) the next newline.
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,...
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
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
const std::string & getHeader(const std::string &key_r, const std::string &default_r) const
void setBody(const std::string &body_r)
std::pair< HeaderListIterator, HeaderListIterator > constKeyRange
std::pair< HeaderList::iterator, HeaderList::iterator > KeyRange
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)
Impl(const std::string &command_r, const std::string &body_r, HeaderInitializerList contents_r)
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, const std::string &body_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.