libzypp
13.10.6
|
Command frame for communication with PluginScript. More...
#include <PluginFrame.h>
Classes | |
struct | Impl |
PluginFrame implementation. More... | |
Public Types | |
typedef PluginFrameException | Exception |
Default exception type. More... | |
typedef std::multimap < std::string, std::string > | HeaderList |
The header list. More... | |
typedef HeaderList::const_iterator | HeaderListIterator |
Header list iterator. More... | |
Public Member Functions | |
PluginFrame () | |
Default ctor (empty frame) More... | |
PluginFrame (const std::string &command_r) | |
Ctor taking the command. More... | |
PluginFrame (const std::string &command_r, const std::string body_r) | |
Ctor taking command and body. More... | |
PluginFrame (std::istream &stream_r) | |
Ctor reading frame data from a stream. More... | |
bool | empty () const |
Whether this is an empty frame. More... | |
operator bool () const | |
Evaluate in a boolean context (empty frame) More... | |
const std::string & | command () const |
Return the frame command. More... | |
void | setCommand (const std::string &command_r) |
Set the frame command. More... | |
bool | isAckCommand () const |
Convenience to identify an ACK command. More... | |
bool | isErrorCommand () const |
Convenience to identify an ERROR command. More... | |
const std::string & | body () const |
Return the frame body. More... | |
std::string & | bodyRef () |
Return a reference to the frame body. More... | |
void | setBody (const std::string &body_r) |
Set the frame body. More... | |
const HeaderList & | headerList () const |
The header list. More... | |
bool | headerEmpty () const |
Whether header list is empty. More... | |
unsigned | headerSize () const |
Return size of the header list. More... | |
HeaderListIterator | headerBegin () const |
Return iterator pointing to the 1st header (or headerEnd) More... | |
HeaderListIterator | headerEnd () const |
Return iterator pointing behind the last header. More... | |
void | headerClear () |
Clear the list of headers. More... | |
bool | hasKey (const std::string &key_r) const |
Whether the header list contains at least one entry for key_r . More... | |
bool | keyEmpty (const std::string &key_r) const |
bool | keySize (const std::string &key_r) const |
Return number of header entires for key_r . More... | |
HeaderListIterator | keyBegin (const std::string &key_r) const |
Return iterator pointing to the 1st header for key_r (or keyEnd(key_r)) More... | |
HeaderListIterator | keyEnd (const std::string &key_r) const |
Return iterator pointing behind the last header for key_r . More... | |
const std::string & | getHeader (const std::string &key_r) const |
Return header value for key_r . More... | |
const std::string & | getHeader (const std::string &key_r, const std::string &default_r) const |
Return header value for key_r or default_r if it does not exist. More... | |
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. More... | |
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 . More... | |
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. More... | |
void | clearHeader (const std::string &key_r) |
Remove all headers for key_r . More... | |
std::ostream & | writeTo (std::ostream &stream_r) const |
Write frame to stream. More... | |
std::istream & | readFrom (std::istream &stream_r) |
Read frame from stream. More... | |
Static Public Member Functions | |
static const std::string & | ackCommand () |
"ACK" command. More... | |
static const std::string & | errorCommand () |
"ERROR" command. More... | |
static std::ostream & | writeTo (std::ostream &stream_r, const PluginFrame &frame_r) |
static std::istream & | readFrom (std::istream &stream_r, PluginFrame &frame_r) |
Private Member Functions | |
HeaderList & | headerList () |
Modifyalble header list for internal use only. More... | |
Private Attributes | |
RWCOW_pointer< Impl > | _pimpl |
Pointer to implementation. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &str, const PluginFrame &obj) |
bool | operator== (const PluginFrame &lhs, const PluginFrame &rhs) |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &str, const PluginFrame &obj) |
std::ostream & | dumpOn (std::ostream &str, const PluginFrame &obj) |
std::istream & | operator>> (std::istream &str, PluginFrame &obj) |
bool | operator== (const PluginFrame &lhs, const PluginFrame &rhs) |
bool | operator!= (const PluginFrame &lhs, const PluginFrame &rhs) |
Command frame for communication with PluginScript.
Definition at line 40 of file PluginFrame.h.
Default exception type.
Definition at line 53 of file PluginFrame.h.
typedef std::multimap<std::string, std::string> zypp::PluginFrame::HeaderList |
The header list.
Definition at line 117 of file PluginFrame.h.
typedef HeaderList::const_iterator zypp::PluginFrame::HeaderListIterator |
Header list iterator.
Definition at line 120 of file PluginFrame.h.
zypp::PluginFrame::PluginFrame | ( | ) |
Default ctor (empty frame)
Definition at line 237 of file PluginFrame.cc.
zypp::PluginFrame::PluginFrame | ( | const std::string & | command_r | ) |
Ctor taking the command.
PluginFrameException | If setCommand throws |
Definition at line 241 of file PluginFrame.cc.
zypp::PluginFrame::PluginFrame | ( | const std::string & | command_r, |
const std::string | body_r | ||
) |
Ctor taking command and body.
PluginFrameException | If setCommand throws |
Definition at line 245 of file PluginFrame.cc.
zypp::PluginFrame::PluginFrame | ( | std::istream & | stream_r | ) |
Ctor reading frame data from a stream.
PluginFrameException | On error reading from stream |
PluginFrameException | On error parsing the data |
Definition at line 249 of file PluginFrame.cc.
|
static |
"ACK" command.
Definition at line 225 of file PluginFrame.cc.
|
static |
"ERROR" command.
Definition at line 231 of file PluginFrame.cc.
bool zypp::PluginFrame::empty | ( | ) | const |
Whether this is an empty frame.
Definition at line 253 of file PluginFrame.cc.
|
inlineexplicit |
Evaluate in a boolean context (empty frame)
Definition at line 79 of file PluginFrame.h.
const std::string & zypp::PluginFrame::command | ( | ) | const |
Return the frame command.
Definition at line 256 of file PluginFrame.cc.
void zypp::PluginFrame::setCommand | ( | const std::string & | command_r | ) |
Set the frame command.
PluginFrameException | If illegal command string (e.g. multiline) |
Definition at line 259 of file PluginFrame.cc.
|
inline |
Convenience to identify an ACK command.
Definition at line 92 of file PluginFrame.h.
|
inline |
Convenience to identify an ERROR command.
Definition at line 96 of file PluginFrame.h.
const std::string & zypp::PluginFrame::body | ( | ) | const |
Return the frame body.
Definition at line 262 of file PluginFrame.cc.
std::string & zypp::PluginFrame::bodyRef | ( | ) |
Return a reference to the frame body.
This may avoid creating unnecessary copies if you want to manipulate large body data.
Definition at line 265 of file PluginFrame.cc.
void zypp::PluginFrame::setBody | ( | const std::string & | body_r | ) |
Set the frame body.
Definition at line 268 of file PluginFrame.cc.
|
private |
Modifyalble header list for internal use only.
Definition at line 274 of file PluginFrame.cc.
const PluginFrame::HeaderList & zypp::PluginFrame::headerList | ( | ) | const |
The header list.
Definition at line 277 of file PluginFrame.cc.
|
inline |
Whether header list is empty.
Definition at line 131 of file PluginFrame.h.
|
inline |
Return size of the header list.
Definition at line 135 of file PluginFrame.h.
|
inline |
Return iterator pointing to the 1st header (or headerEnd)
Definition at line 139 of file PluginFrame.h.
|
inline |
Return iterator pointing behind the last header.
Definition at line 143 of file PluginFrame.h.
|
inline |
Clear the list of headers.
Definition at line 147 of file PluginFrame.h.
|
inline |
Whether the header list contains at least one entry for key_r
.
Definition at line 152 of file PluginFrame.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 156 of file PluginFrame.h.
|
inline |
Return number of header entires for key_r
.
Definition at line 160 of file PluginFrame.h.
|
inline |
Return iterator pointing to the 1st header for key_r
(or keyEnd(key_r))
Definition at line 164 of file PluginFrame.h.
|
inline |
Return iterator pointing behind the last header for key_r
.
Definition at line 168 of file PluginFrame.h.
const std::string & zypp::PluginFrame::getHeader | ( | const std::string & | key_r | ) | const |
Return header value for key_r
.
PluginFrameException | If no header for key_r exists. |
PluginFrameException | If multiple header for key_r exist. |
Definition at line 280 of file PluginFrame.cc.
const std::string & zypp::PluginFrame::getHeader | ( | const std::string & | key_r, |
const std::string & | default_r | ||
) | const |
Return header value for key_r
or default_r
if it does not exist.
PluginFrameException | If multiple header for key_r exist. |
Definition at line 283 of file PluginFrame.cc.
const std::string & zypp::PluginFrame::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.
Definition at line 286 of file PluginFrame.cc.
void zypp::PluginFrame::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
.
PluginFrameException | If key contains illegal chars (NL or :) |
PluginFrameException | If value contains illegal chars (NL ) |
Definition at line 289 of file PluginFrame.cc.
void zypp::PluginFrame::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.
PluginFrameException | If key contains illegal chars (NL or :) |
PluginFrameException | If value contains illegal chars (NL ) |
Definition at line 292 of file PluginFrame.cc.
void zypp::PluginFrame::clearHeader | ( | const std::string & | key_r | ) |
Remove all headers for key_r
.
Definition at line 295 of file PluginFrame.cc.
std::ostream & zypp::PluginFrame::writeTo | ( | std::ostream & | stream_r | ) | const |
Write frame to stream.
PluginFrameException | On error writing to stream |
Definition at line 271 of file PluginFrame.cc.
|
inlinestatic |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 208 of file PluginFrame.h.
|
inline |
Read frame from stream.
PluginFrameException | If PluginFrame(std::istream&) throws |
Definition at line 214 of file PluginFrame.h.
|
inlinestatic |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 218 of file PluginFrame.h.
|
friend |
Definition at line 300 of file PluginFrame.cc.
|
friend |
Definition at line 303 of file PluginFrame.cc.
|
related |
Stream output for logging
Definition at line 300 of file PluginFrame.cc.
|
related |
Stream output sending all data
Definition at line 233 of file PluginFrame.h.
|
related |
Construct from stream.
Definition at line 237 of file PluginFrame.h.
|
related |
Comparison based on content.
Definition at line 303 of file PluginFrame.cc.
|
related |
Comparison based on content.
Definition at line 244 of file PluginFrame.h.
|
private |
Pointer to implementation.
Definition at line 223 of file PluginFrame.h.