iceoryx_doc  1.0.1
Public Member Functions | List of all members
iox::runtime::IpcMessage Class Reference

#include <ipc_message.hpp>

Public Member Functions

 IpcMessage () noexcept=default
 Creates an empty and valid IPC channel message.
 
 IpcMessage (const std::initializer_list< std::string > &msg) noexcept
 Creates a separator separated string. If one element contains a separator symbol the IpcMessage becomes invalid and returns false on isValid(). More...
 
 IpcMessage (const std::string &msg) noexcept
 Takes a separator separated string and interprets it as a IpcMessage. In this case the IpcMessage can only become invalid if it is not empty and does not end with the separator. More...
 
template<typename T >
IpcMessageoperator<< (const T &entry) noexcept
 Adds a new entry to the IpcMessage, if the entry is invalid no entry is added and the IpcMessage becomes invalid. More...
 
uint32_t getNumberOfElements () const noexcept
 Returns the number of entries stored in IpcMessage. If the message is invalid the return value is undefined. More...
 
std::string getElementAtIndex (const uint32_t index) const noexcept
 Returns the entry at position f_index. If f_index is larger then the sum of the entries stored in IpcMessage it returns std::string() More...
 
bool isValidEntry (const std::string &entry) const noexcept
 returns if an entry is valid. Non valid entries are containing at least one separator More...
 
bool isValid () const noexcept
 check if the message is valid More...
 
std::string getMessage () const noexcept
 The message is casted to the actual separator separated string If the message is invalid the return value is undefined. More...
 
void setMessage (const std::string &msg) noexcept
 Takes a separator separated string and interprets it as a IpcMessage. In this case the IpcMessage can only become invalid if it is not empty and does not end with the separator. All the entries that were stored previously in the IpcMessage will be cleared after a call to setMessage. More...
 
void clearMessage () noexcept
 Clears the message. After a call to clearMessage() the.
 
template<typename T >
void addEntry (const T &entry) noexcept
 Adds a new entry to the IpcMessage, if the entry is invalid no entry is added and the IpcMessage becomes invalid. More...
 
bool operator== (const IpcMessage &rhs) const noexcept
 Compares two IpcMessages to be equal. More...
 

Detailed Description

The symbol , is per default the separator.

A valid entry is an arbitrary string which does not contain the separator symbol, otherwise, if it contains the separator symbol it is defined as a invalid entry. A valid entry can contain none or more characters.

A message is a concatination of valid entries separated by the separator. A message is defined as valid if all entries contained in that message are valid and it ends with the separator or it is empty, otherwise it is defined as invalid.

Constructor & Destructor Documentation

◆ IpcMessage() [1/2]

iox::runtime::IpcMessage::IpcMessage ( const std::initializer_list< std::string > &  msg)
noexcept

Creates a separator separated string. If one element contains a separator symbol the IpcMessage becomes invalid and returns false on isValid().

Parameters
[in]msgarray of strings to combine in a message

◆ IpcMessage() [2/2]

iox::runtime::IpcMessage::IpcMessage ( const std::string &  msg)
noexcept

Takes a separator separated string and interprets it as a IpcMessage. In this case the IpcMessage can only become invalid if it is not empty and does not end with the separator.

Parameters
[in]separatorseparated string for a message

Member Function Documentation

◆ addEntry()

template<typename T >
void iox::runtime::IpcMessage::addEntry ( const T &  entry)
noexcept

Adds a new entry to the IpcMessage, if the entry is invalid no entry is added and the IpcMessage becomes invalid.

Template Parameters
Datatypewhich is convertable to string via std::stringstream
Parameters
[in]entryto add to the message

◆ getElementAtIndex()

std::string iox::runtime::IpcMessage::getElementAtIndex ( const uint32_t  index) const
noexcept

Returns the entry at position f_index. If f_index is larger then the sum of the entries stored in IpcMessage it returns std::string()

Parameters
[in]indexdesired entry position
Returns
If the element exists it returns the element at f_index otherwise an empty string

◆ getMessage()

std::string iox::runtime::IpcMessage::getMessage ( ) const
noexcept

The message is casted to the actual separator separated string If the message is invalid the return value is undefined.

Returns
the current message as separator separated string

◆ getNumberOfElements()

uint32_t iox::runtime::IpcMessage::getNumberOfElements ( ) const
noexcept

Returns the number of entries stored in IpcMessage. If the message is invalid the return value is undefined.

Returns
number of entries in messaage

◆ isValid()

bool iox::runtime::IpcMessage::isValid ( ) const
noexcept

check if the message is valid

Returns
If one element in the CTor initializer_list was invalid it returns false, otherwise true.

◆ isValidEntry()

bool iox::runtime::IpcMessage::isValidEntry ( const std::string &  entry) const
noexcept

returns if an entry is valid. Non valid entries are containing at least one separator

Parameters
[in]entrysstring to check
Returns
true = if it is a valid entry otherwise false

◆ operator<<()

template<typename T >
IpcMessage & iox::runtime::IpcMessage::operator<< ( const T &  entry)
noexcept

Adds a new entry to the IpcMessage, if the entry is invalid no entry is added and the IpcMessage becomes invalid.

Parameters
[in]entryDatatype which is convertable to string via std::to_string

◆ operator==()

bool iox::runtime::IpcMessage::operator== ( const IpcMessage rhs) const
noexcept

Compares two IpcMessages to be equal.

Parameters
rhsIpcMessage to compare with

◆ setMessage()

void iox::runtime::IpcMessage::setMessage ( const std::string &  msg)
noexcept

Takes a separator separated string and interprets it as a IpcMessage. In this case the IpcMessage can only become invalid if it is not empty and does not end with the separator. All the entries that were stored previously in the IpcMessage will be cleared after a call to setMessage.

Parameters
[in]separatorseparated string for the message

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