libzypp: zypp::PluginFrame Class Reference

libzypp 17.38.10

zypp::PluginFrame Class Reference

Command frame for communication with PluginScript. More...

`#include <zypp-core/rpc/PluginFrame.h>`

## Classes
struct | Impl
| PluginFrame implementation. More...

## Public Types
using | Exception = PluginFrameException
| Default exception type.
using | HeaderList = std::multimap<std::string, std::string>
| The header list.
using | HeaderListIterator = HeaderList::const_iterator
| Header list iterator.

## Public Member Functions
| PluginFrame ()
| Default ctor (empty frame).
| PluginFrame (const std::string &command_r)
| Ctor taking the command.
| PluginFrame (const std::string &command_r, std::string body_r)
| Ctor taking command and body.
| PluginFrame (const std::string &command_r, ByteArray body_r)
| Ctor taking command and body.
| PluginFrame (const std::string &command_r, HeaderInitializerList contents_r)
| Ctor taking the command and a HeaderInitializerList.
| PluginFrame (const std::string &command_r, ByteArray body_r, HeaderInitializerList contents_r)
| Ctor taking command, body and a HeaderInitializerList.
| PluginFrame (std::istream &stream_r)
| Ctor reading frame data from a stream.
bool | empty () const
| Whether this is an empty frame.
| operator bool () const
| Evaluate in a boolean context (not an empty frame).
const std::string & | command () const
| Return the frame command.
void | setCommand (const std::string &command_r)
| Set the frame command.
bool | isAckCommand () const
| Convenience to identify an ACK command.
bool | isErrorCommand () const
| Convenience to identify an ERROR command.
bool | isEnomethodCommand () const
| Convenience to identify an _ENOMETHOD command.
const ByteArray & | body () const
| Return the frame body.
ByteArray & | bodyRef ()
| Return a reference to the frame body.
void | setBody (const std::string &body_r)
| Set the frame body.
void | setBody (const ByteArray &body_r)
| Set the frame body.
void | setBody (ByteArray &&body_r)
| Set the frame body.
const HeaderList & | headerList () const
| The header list.
bool | headerEmpty () const
| Whether header list is empty.
unsigned | headerSize () const
| Return size of the header list.
HeaderListIterator | headerBegin () const
| Return iterator pointing to the 1st header (or headerEnd).
HeaderListIterator | headerEnd () const
| Return iterator pointing behind the last header.
void | headerClear ()
| Clear the list of headers.
bool | hasKey (const std::string &key_r) const
| Whether the header list contains at least one entry for `key_r`.
bool | keyEmpty (const std::string &key_r) const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool | keySize (const std::string &key_r) const
| Return number of header entries for `key_r`.
HeaderListIterator | keyBegin (const std::string &key_r) const
| Return iterator pointing to the 1st header for `key_r` (or keyEnd(key_r)).
HeaderListIterator | keyEnd (const std::string &key_r) const
| Return iterator pointing behind the last header for `key_r`.
const std::string & | getHeader (const std::string &key_r) const
| Return header value for `key_r`.
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.
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.
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`.
void | setHeader (HeaderInitializerList contents_r)
| Set a new header list.
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.
void | addHeader (HeaderInitializerList contents_r)
void | addRawHeader (const ByteArray &header)
void | clearHeader (const std::string &key_r)
| Remove all headers for `key_r`.
std::ostream & | writeTo (std::ostream &stream_r) const
| Write frame to stream.
std::istream & | readFrom (std::istream &stream_r)
| Read frame from stream.

## Static Public Member Functions
static const std::string & | ackCommand ()
| "ACK" command.
static const std::string & | errorCommand ()
| "ERROR" command.
static const std::string & | enomethodCommand ()
| "_ENOMETHOD" command.
static const std::string & | contentLengthHeader ()
| "content-lenght" header name
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
using | HeaderInitializerList = const std::initializer_list<std::pair<std::string, std::string>> &

## Private Member Functions
HeaderList & | headerList ()
| Modifyalble header list for internal use only.

## Private Attributes
RWCOW_pointer< Impl > | _pimpl
| Pointer to implementation.

## Friends
std::ostream & | operator<< (std::ostream &str, const PluginFrame &obj)
| relates: PluginFrame Stream output for logging
bool | operator== (const PluginFrame &lhs, const PluginFrame &rhs)
| relates: PluginFrame Comparison based on content.

## 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.
^@
zypp::PluginFrame::empty
bool empty() const
Whether this is an empty frame.
Definition PluginFrame.cc:436
zypp::PluginFrame::body
const ByteArray & body() const
Return the frame body.
Definition PluginFrame.cc:445

See also
  PluginScript

Definition at line 41 of file PluginFrame.h.

## Member Typedef Documentation

## ◆ HeaderInitializerList

using zypp::PluginFrame::HeaderInitializerList = const std::initializer_list<std::pair<std::string, std::string>> &
| private

Definition at line 46 of file PluginFrame.h.

## ◆ Exception

using zypp::PluginFrame::Exception = PluginFrameException

Default exception type.

Definition at line 60 of file PluginFrame.h.

## ◆ HeaderList

using zypp::PluginFrame::HeaderList = std::multimap<std::string, std::string>

The header list.

Definition at line 149 of file PluginFrame.h.

## ◆ HeaderListIterator

using zypp::PluginFrame::HeaderListIterator = HeaderList::const_iterator

Header list iterator.

Definition at line 152 of file PluginFrame.h.

## Constructor & Destructor Documentation

## ◆ PluginFrame() [1/7]

zypp::PluginFrame::PluginFrame | ( |  | ) |

Default ctor (empty frame).

Definition at line 408 of file PluginFrame.cc.

## ◆ PluginFrame() [2/7]

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

Ctor taking the command.

Exceptions

  PluginFrameException | If setCommand throws

Definition at line 412 of file PluginFrame.cc.

## ◆ PluginFrame() [3/7]

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

Ctor taking command and body.

Exceptions

  PluginFrameException | If setCommand throws

Definition at line 416 of file PluginFrame.cc.

## ◆ PluginFrame() [4/7]

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

Ctor taking command and body.

Exceptions

  PluginFrameException | If setCommand throws

Definition at line 420 of file PluginFrame.cc.

## ◆ PluginFrame() [5/7]

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

Ctor taking the command and a HeaderInitializerList.

Exceptions

  PluginFrameException | If setCommand throws

Definition at line 424 of file PluginFrame.cc.

## ◆ PluginFrame() [6/7]

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

Ctor taking command, body and a HeaderInitializerList.

Exceptions

  PluginFrameException | If setCommand throws

Definition at line 428 of file PluginFrame.cc.

## ◆ PluginFrame() [7/7]

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

Ctor reading frame data from a stream.

Exceptions

  PluginFrameException | On error reading from stream
  PluginFrameException | On error parsing the data

Definition at line 432 of file PluginFrame.cc.

## Member Function Documentation

## ◆ ackCommand()

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

"ACK" command.

Definition at line 384 of file PluginFrame.cc.

## ◆ errorCommand()

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

"ERROR" command.

Definition at line 390 of file PluginFrame.cc.

## ◆ enomethodCommand()

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

"_ENOMETHOD" command.

Definition at line 396 of file PluginFrame.cc.

## ◆ contentLengthHeader()

const std::string & zypp::PluginFrame::contentLengthHeader | ( |  | ) |
| static

"content-lenght" header name

Definition at line 402 of file PluginFrame.cc.

## ◆ empty()

bool zypp::PluginFrame::empty | ( |  | ) | const

Whether this is an empty frame.

Definition at line 436 of file PluginFrame.cc.

## ◆ operator bool()

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

Evaluate in a boolean context (not an empty frame).

Definition at line 101 of file PluginFrame.h.

## ◆ command()

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

Return the frame command.

Definition at line 439 of file PluginFrame.cc.

## ◆ setCommand()

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

Set the frame command.

Exceptions

  PluginFrameException | If illegal command string (e.g. multiline)

Definition at line 442 of file PluginFrame.cc.

## ◆ isAckCommand()

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

Convenience to identify an ACK command.

Definition at line 114 of file PluginFrame.h.

## ◆ isErrorCommand()

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

Convenience to identify an ERROR command.

Definition at line 118 of file PluginFrame.h.

## ◆ isEnomethodCommand()

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

Convenience to identify an _ENOMETHOD command.

Definition at line 122 of file PluginFrame.h.

## ◆ body()

const ByteArray & zypp::PluginFrame::body | ( |  | ) | const

Return the frame body.

Definition at line 445 of file PluginFrame.cc.

## ◆ bodyRef()

ByteArray & zypp::PluginFrame::bodyRef | ( |  | ) |

Return a reference to the frame body.

This may avoid creating unnecessary copies if you want to manipulate large body data.

ByteArray tmp;
frame.bodyRef().swap( tmp );
zypp::ByteArray
Definition ByteArray.h:20

Definition at line 448 of file PluginFrame.cc.

## ◆ setBody() [1/3]

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

Set the frame body.

Definition at line 451 of file PluginFrame.cc.

## ◆ setBody() [2/3]

void zypp::PluginFrame::setBody | ( | const ByteArray & | body_r | ) |

Set the frame body.

Definition at line 454 of file PluginFrame.cc.

## ◆ setBody() [3/3]

void zypp::PluginFrame::setBody | ( | ByteArray && | body_r | ) |

Set the frame body.

Definition at line 457 of file PluginFrame.cc.

## ◆ headerList() [1/2]

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

Modifyalble header list for internal use only.

Definition at line 463 of file PluginFrame.cc.

## ◆ headerList() [2/2]

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

The header list.

Definition at line 466 of file PluginFrame.cc.

## ◆ headerEmpty()

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

Whether header list is empty.

Definition at line 163 of file PluginFrame.h.

## ◆ headerSize()

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

Return size of the header list.

Definition at line 167 of file PluginFrame.h.

## ◆ headerBegin()

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

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

Definition at line 171 of file PluginFrame.h.

## ◆ headerEnd()

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

Return iterator pointing behind the last header.

Definition at line 175 of file PluginFrame.h.

## ◆ headerClear()

void zypp::PluginFrame::headerClear | ( |  | ) |
| inline

Clear the list of headers.

Definition at line 179 of file PluginFrame.h.

## ◆ hasKey()

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 184 of file PluginFrame.h.

## ◆ keyEmpty()

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 188 of file PluginFrame.h.

## ◆ keySize()

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

Return number of header entries for `key_r`.

Definition at line 192 of file PluginFrame.h.

## ◆ keyBegin()

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 196 of file PluginFrame.h.

## ◆ keyEnd()

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

Return iterator pointing behind the last header for `key_r`.

Definition at line 200 of file PluginFrame.h.

## ◆ getHeader() [1/2]

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

Return header value for `key_r`.

Exceptions

  PluginFrameException | If no header for key_r exists.
  PluginFrameException | If multiple header for key_r exist.

Definition at line 469 of file PluginFrame.cc.

## ◆ getHeader() [2/2]

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

  PluginFrameException | If multiple header for key_r exist.

Definition at line 472 of file PluginFrame.cc.

## ◆ getHeaderNT()

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

## ◆ setHeader() [1/2]

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

  PluginFrameException | If key contains illegal chars (`NL` or ``:)
  PluginFrameException | If value contains illegal chars (`NL`)

Definition at line 478 of file PluginFrame.cc.

## ◆ setHeader() [2/2]

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

Set a new header list.

Exceptions

  PluginFrameException | If key contains illegal chars (`NL` or ``:)
  PluginFrameException | If value contains illegal chars (`NL`)

Definition at line 228 of file PluginFrame.h.

## ◆ addHeader() [1/2]

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

  PluginFrameException | If key contains illegal chars (`NL` or ``:)
  PluginFrameException | If value contains illegal chars (`NL`)

Definition at line 481 of file PluginFrame.cc.

## ◆ addHeader() [2/2]

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

Definition at line 484 of file PluginFrame.cc.

## ◆ addRawHeader()

void zypp::PluginFrame::addRawHeader | ( | const ByteArray & | header | ) |

Parses the header line in header and if it is valid adds it to the internal header list.

Definition at line 487 of file PluginFrame.cc.

## ◆ clearHeader()

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

Remove all headers for `key_r`.

Definition at line 492 of file PluginFrame.cc.

## ◆ writeTo() [1/2]

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

Write frame to stream.

Exceptions

  PluginFrameException | On error writing to stream

Definition at line 460 of file PluginFrame.cc.

## ◆ writeTo() [2/2]

std::ostream & zypp::PluginFrame::writeTo | ( | std::ostream & | stream_r,
|  | const PluginFrame & | frame_r )
| inlinestatic

Definition at line 255 of file PluginFrame.h.

## ◆ readFrom() [1/2]

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

Read frame from stream.

Exceptions

  PluginFrameException | If PluginFrame(std::istream&) throws

Definition at line 261 of file PluginFrame.h.

## ◆ readFrom() [2/2]

std::istream & zypp::PluginFrame::readFrom | ( | std::istream & | stream_r,
|  | PluginFrame & | frame_r )
| inlinestatic

Definition at line 265 of file PluginFrame.h.

## Friends And Related Symbol Documentation

## ◆ operator<<

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

relates: PluginFrame Stream output for logging

Definition at line 497 of file PluginFrame.cc.

## ◆ operator==

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

relates: PluginFrame Comparison based on content.

Definition at line 500 of file PluginFrame.cc.

## Member Data Documentation

## ◆ _pimpl

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

Pointer to implementation.

Definition at line 273 of file PluginFrame.h.

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

- zypp-core/rpc/PluginFrame.h
- zypp-core/rpc/PluginFrame.cc