12 #ifndef ZYPP_PLUGINFRAME_H
13 #define ZYPP_PLUGINFRAME_H
66 PluginFrame(
const std::string & command_r,
const std::string body_r );
79 explicit operator bool()
const
84 const std::string &
command()
const;
89 void setCommand(
const std::string & command_r );
100 const std::string &
body()
const;
113 void setBody(
const std::string & body_r );
152 bool hasKey(
const std::string & key_r )
const
160 bool keySize(
const std::string & key_r )
const
176 const std::string &
getHeader(
const std::string & key_r )
const;
181 const std::string &
getHeader(
const std::string & key_r,
const std::string & default_r )
const;
184 const std::string &
getHeaderNT(
const std::string & key_r,
const std::string & default_r = std::string() )
const;
190 void setHeader(
const std::string & key_r,
const std::string & value_r = std::string() );
196 void addHeader(
const std::string & key_r,
const std::string & value_r = std::string() );
205 std::ostream &
writeTo( std::ostream & stream_r )
const;
209 {
return frame_r.
writeTo( stream_r ); }
215 { *
this =
PluginFrame( stream_r );
return stream_r; }
219 { frame_r =
PluginFrame( stream_r );
return stream_r; }
245 {
return( !
operator==( lhs, rhs ) ); }
250 #endif // ZYPP_PLUGINFRAME_H
bool keySize(const std::string &key_r) const
Return number of header entires for key_r.
friend bool operator==(const PluginFrame &lhs, const PluginFrame &rhs)
PluginFrame()
Default ctor (empty frame)
Command frame for communication with PluginScript.
void setCommand(const std::string &command_r)
Set the frame command.
const std::string & command() const
Return the frame command.
std::istream & operator>>(std::istream &str, PluginFrame &obj)
HeaderListIterator keyEnd(const std::string &key_r) const
Return iterator pointing behind the last header for key_r.
std::ostream & dumpOn(std::ostream &str, const PluginFrame &obj)
bool operator!=(const PluginFrame &lhs, const PluginFrame &rhs)
HeaderListIterator keyBegin(const std::string &key_r) const
Return iterator pointing to the 1st header for key_r (or keyEnd(key_r))
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.
bool isErrorCommand() const
Convenience to identify an ERROR command.
static std::istream & readFrom(std::istream &stream_r, PluginFrame &frame_r)
static const std::string & errorCommand()
"ERROR" command.
void headerClear()
Clear the list of headers.
std::ostream & operator<<(std::ostream &str, const Exception &obj)
bool keyEmpty(const std::string &key_r) const
unsigned headerSize() const
Return size of the header list.
Base class for PluginFrame Exception.
bool isAckCommand() const
Convenience to identify an ACK command.
friend std::ostream & operator<<(std::ostream &str, const PluginFrame &obj)
bool headerEmpty() const
Whether header list is empty.
static const std::string & ackCommand()
"ACK" command.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
bool operator==(const StrMatcher &lhs, const StrMatcher &rhs)
void setBody(const std::string &body_r)
Set the frame body.
HeaderListIterator headerEnd() const
Return iterator pointing behind the last header.
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.
bool hasKey(const std::string &key_r) const
Whether the header list contains at least one entry for key_r.
HeaderList::const_iterator HeaderListIterator
Header list iterator.
HeaderListIterator headerBegin() const
Return iterator pointing to the 1st header (or headerEnd)
void setHeader(const std::string &key_r, const std::string &value_r=std::string())
Set header for key_r removing all other occurences of key_r.
HeaderList & headerList()
Modifyalble header list for internal use only.
PluginFrame implementation.
std::ostream & writeTo(std::ostream &stream_r) const
Write frame to stream.
std::istream & readFrom(std::istream &stream_r)
Read frame from stream.
std::string & bodyRef()
Return a reference to the frame body.
bool empty() const
Whether this is an empty frame.
void clearHeader(const std::string &key_r)
Remove all headers for key_r.
static std::ostream & writeTo(std::ostream &stream_r, const PluginFrame &frame_r)
PluginFrameException Exception
Default exception type.
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.
RW_pointer supporting 'copy on write' functionality.
const std::string & body() const
Return the frame body.