libzypp  15.28.6
zypp::PluginFrame Class Reference

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 (const std::string &command_r, HeaderInitializerList contents_r)
 Ctor taking the command and a HeaderInitializerList. More...
 
 PluginFrame (const std::string &command_r, const std::string &body_r, HeaderInitializerList contents_r)
 Ctor taking command, body and a HeaderInitializerList. 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 (not an 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...
 
bool isEnomethodCommand () const
 Convenience to identify an _ENOMETHOD 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 HeaderListheaderList () 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 entries 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 occurrences of key_r. More...
 
void setHeader (HeaderInitializerList contents_r)
 Set a new header list. 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 addHeader (HeaderInitializerList contents_r)
 
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 const std::string & enomethodCommand ()
 "_ENOMETHOD" 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 Types

typedef const
std::initializer_list
< std::pair< std::string,
std::string > > & 
HeaderInitializerList
 

Private Member Functions

HeaderListheaderList ()
 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)
 

Detailed Description

Command frame for communication with PluginScript.

COMMAND
key:value header lines
multiline body separated from header
by an empty line and terminated by NUL.
^@
See Also
PluginScript

Definition at line 40 of file PluginFrame.h.

Member Typedef Documentation

typedef const std::initializer_list<std::pair<std::string,std::string> >& zypp::PluginFrame::HeaderInitializerList
private

Definition at line 45 of file PluginFrame.h.

Default exception type.

Definition at line 57 of file PluginFrame.h.

typedef std::multimap<std::string, std::string> zypp::PluginFrame::HeaderList

The header list.

Definition at line 135 of file PluginFrame.h.

typedef HeaderList::const_iterator zypp::PluginFrame::HeaderListIterator

Header list iterator.

Definition at line 138 of file PluginFrame.h.

Constructor & Destructor Documentation

zypp::PluginFrame::PluginFrame ( )

Default ctor (empty frame)

Definition at line 259 of file PluginFrame.cc.

zypp::PluginFrame::PluginFrame ( const std::string &  command_r)

Ctor taking the command.

Exceptions
PluginFrameExceptionIf setCommand throws

Definition at line 263 of file PluginFrame.cc.

zypp::PluginFrame::PluginFrame ( const std::string &  command_r,
const std::string &  body_r 
)

Ctor taking command and body.

Exceptions
PluginFrameExceptionIf setCommand throws

Definition at line 267 of file PluginFrame.cc.

zypp::PluginFrame::PluginFrame ( const std::string &  command_r,
HeaderInitializerList  contents_r 
)

Ctor taking the command and a HeaderInitializerList.

Exceptions
PluginFrameExceptionIf setCommand throws

Definition at line 271 of file PluginFrame.cc.

zypp::PluginFrame::PluginFrame ( const std::string &  command_r,
const std::string &  body_r,
HeaderInitializerList  contents_r 
)

Ctor taking command, body and a HeaderInitializerList.

Exceptions
PluginFrameExceptionIf setCommand throws

Definition at line 275 of file PluginFrame.cc.

zypp::PluginFrame::PluginFrame ( std::istream &  stream_r)

Ctor reading frame data from a stream.

Exceptions
PluginFrameExceptionOn error reading from stream
PluginFrameExceptionOn error parsing the data

Definition at line 279 of file PluginFrame.cc.

Member Function Documentation

const std::string & zypp::PluginFrame::ackCommand ( )
static

"ACK" command.

Definition at line 241 of file PluginFrame.cc.

const std::string & zypp::PluginFrame::errorCommand ( )
static

"ERROR" command.

Definition at line 247 of file PluginFrame.cc.

const std::string & zypp::PluginFrame::enomethodCommand ( )
static

"_ENOMETHOD" command.

Definition at line 253 of file PluginFrame.cc.

bool zypp::PluginFrame::empty ( ) const

Whether this is an empty frame.

Definition at line 283 of file PluginFrame.cc.

zypp::PluginFrame::operator bool ( ) const
inlineexplicit

Evaluate in a boolean context (not an empty frame)

Definition at line 93 of file PluginFrame.h.

const std::string & zypp::PluginFrame::command ( ) const

Return the frame command.

Definition at line 286 of file PluginFrame.cc.

void zypp::PluginFrame::setCommand ( const std::string &  command_r)

Set the frame command.

Exceptions
PluginFrameExceptionIf illegal command string (e.g. multiline)

Definition at line 289 of file PluginFrame.cc.

bool zypp::PluginFrame::isAckCommand ( ) const
inline

Convenience to identify an ACK command.

Definition at line 106 of file PluginFrame.h.

bool zypp::PluginFrame::isErrorCommand ( ) const
inline

Convenience to identify an ERROR command.

Definition at line 110 of file PluginFrame.h.

bool zypp::PluginFrame::isEnomethodCommand ( ) const
inline

Convenience to identify an _ENOMETHOD command.

Definition at line 114 of file PluginFrame.h.

const std::string & zypp::PluginFrame::body ( ) const

Return the frame body.

Definition at line 292 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.

std::string tmp;
frame.bodyRef().swap( tmp );

Definition at line 295 of file PluginFrame.cc.

void zypp::PluginFrame::setBody ( const std::string &  body_r)

Set the frame body.

Definition at line 298 of file PluginFrame.cc.

PluginFrame::HeaderList & zypp::PluginFrame::headerList ( )
private

Modifyalble header list for internal use only.

Definition at line 304 of file PluginFrame.cc.

const PluginFrame::HeaderList & zypp::PluginFrame::headerList ( ) const

The header list.

Definition at line 307 of file PluginFrame.cc.

bool zypp::PluginFrame::headerEmpty ( ) const
inline

Whether header list is empty.

Definition at line 149 of file PluginFrame.h.

unsigned zypp::PluginFrame::headerSize ( ) const
inline

Return size of the header list.

Definition at line 153 of file PluginFrame.h.

HeaderListIterator zypp::PluginFrame::headerBegin ( ) const
inline

Return iterator pointing to the 1st header (or headerEnd)

Definition at line 157 of file PluginFrame.h.

HeaderListIterator zypp::PluginFrame::headerEnd ( ) const
inline

Return iterator pointing behind the last header.

Definition at line 161 of file PluginFrame.h.

void zypp::PluginFrame::headerClear ( )
inline

Clear the list of headers.

Definition at line 165 of file PluginFrame.h.

bool zypp::PluginFrame::hasKey ( const std::string &  key_r) const
inline

Whether the header list contains at least one entry for key_r.

Definition at line 170 of file PluginFrame.h.

bool zypp::PluginFrame::keyEmpty ( const std::string &  key_r) const
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 174 of file PluginFrame.h.

bool zypp::PluginFrame::keySize ( const std::string &  key_r) const
inline

Return number of header entries for key_r.

Definition at line 178 of file PluginFrame.h.

HeaderListIterator zypp::PluginFrame::keyBegin ( const std::string &  key_r) const
inline

Return iterator pointing to the 1st header for key_r (or keyEnd(key_r))

Definition at line 182 of file PluginFrame.h.

HeaderListIterator zypp::PluginFrame::keyEnd ( const std::string &  key_r) const
inline

Return iterator pointing behind the last header for key_r.

Definition at line 186 of file PluginFrame.h.

const std::string & zypp::PluginFrame::getHeader ( const std::string &  key_r) const

Return header value for key_r.

Exceptions
PluginFrameExceptionIf no header for key_r exists.
PluginFrameExceptionIf multiple header for key_r exist.

Definition at line 310 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.

Exceptions
PluginFrameExceptionIf multiple header for key_r exist.

Definition at line 313 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 316 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 occurrences of key_r.

Exceptions
PluginFrameExceptionIf key contains illegal chars (NL or :)
PluginFrameExceptionIf value contains illegal chars (NL)

Definition at line 319 of file PluginFrame.cc.

void zypp::PluginFrame::setHeader ( HeaderInitializerList  contents_r)
inline

Set a new header list.

Exceptions
PluginFrameExceptionIf key contains illegal chars (NL or :)
PluginFrameExceptionIf value contains illegal chars (NL)

Definition at line 214 of file PluginFrame.h.

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.

Exceptions
PluginFrameExceptionIf key contains illegal chars (NL or :)
PluginFrameExceptionIf value contains illegal chars (NL)

Definition at line 322 of file PluginFrame.cc.

void zypp::PluginFrame::addHeader ( HeaderInitializerList  contents_r)

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 325 of file PluginFrame.cc.

void zypp::PluginFrame::clearHeader ( const std::string &  key_r)

Remove all headers for key_r.

Definition at line 328 of file PluginFrame.cc.

std::ostream & zypp::PluginFrame::writeTo ( std::ostream &  stream_r) const

Write frame to stream.

Exceptions
PluginFrameExceptionOn error writing to stream

Definition at line 301 of file PluginFrame.cc.

static std::ostream& zypp::PluginFrame::writeTo ( std::ostream &  stream_r,
const PluginFrame frame_r 
)
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 235 of file PluginFrame.h.

std::istream& zypp::PluginFrame::readFrom ( std::istream &  stream_r)
inline

Read frame from stream.

Exceptions
PluginFrameExceptionIf PluginFrame(std::istream&) throws

Definition at line 241 of file PluginFrame.h.

static std::istream& zypp::PluginFrame::readFrom ( std::istream &  stream_r,
PluginFrame frame_r 
)
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 245 of file PluginFrame.h.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  str,
const PluginFrame obj 
)
friend

Definition at line 333 of file PluginFrame.cc.

bool operator== ( const PluginFrame lhs,
const PluginFrame rhs 
)
friend

Definition at line 336 of file PluginFrame.cc.

std::ostream & operator<< ( std::ostream &  str,
const PluginFrame obj 
)
related

Stream output for logging

Definition at line 333 of file PluginFrame.cc.

std::ostream & dumpOn ( std::ostream &  str,
const PluginFrame obj 
)
related

Stream output writing all data for logging (no throw)

Definition at line 260 of file PluginFrame.h.

std::istream & operator>> ( std::istream &  str,
PluginFrame obj 
)
related

Construct from stream.

Definition at line 264 of file PluginFrame.h.

bool operator== ( const PluginFrame lhs,
const PluginFrame rhs 
)
related

Comparison based on content.

Definition at line 336 of file PluginFrame.cc.

bool operator!= ( const PluginFrame lhs,
const PluginFrame rhs 
)
related

Comparison based on content.

Definition at line 271 of file PluginFrame.h.

Member Data Documentation

RWCOW_pointer<Impl> zypp::PluginFrame::_pimpl
private

Pointer to implementation.

Definition at line 250 of file PluginFrame.h.


The documentation for this class was generated from the following files: