DBus::MessageIterator Class Reference

Extraction iterator allowing values to be retrieved from a message. More...

#include <messageiterator.h>

Public Member Functions

 MessageIterator ()
 
 MessageIterator (const Message &message)
 
 MessageIterator (std::shared_ptr< Message > message)
 
const Messagemessage () const
 Returns a pointer to the message associated with this iterator or NULL if no message is associated. More...
 
void invalidate ()
 Invalidates the iterator. More...
 
bool is_valid () const
 True if this is a valid iterator. More...
 
bool has_next () const
 True if there are any more fields left to iterate over. More...
 
bool next ()
 Moves the iterator to the next field and invalidates it if it moves beyond the last field. More...
 
MessageIteratoroperator++ ()
 
MessageIterator operator++ (int)
 
bool operator== (const MessageIterator &other)
 
DataType arg_type () const
 Returns the argument type that the iterator points to. More...
 
DataType element_type () const
 Returns the element type of the array that the iterator points to. More...
 
bool is_fixed () const
 True if the element type is a fixed type. More...
 
bool is_container () const
 True if the iterator points to a container. More...
 
bool is_array () const
 True if the iterator points to an array. More...
 
bool is_dict () const
 True if the iterator points to a dictionary. More...
 
MessageIterator recurse ()
 If the iterator points to a container recurses into the container returning a sub-iterator. More...
 
std::string signature () const
 Returns the current signature of the iterator. More...
 
 operator bool ()
 
 operator uint8_t ()
 
 operator uint16_t ()
 
 operator int16_t ()
 
 operator uint32_t ()
 
 operator int32_t ()
 
 operator uint64_t ()
 
 operator int64_t ()
 
 operator double ()
 
 operator std::string ()
 
 operator std::shared_ptr< FileDescriptor > ()
 
 operator Variant ()
 
template<typename T >
 operator std::vector< T > ()
 
template<typename Key , typename Data >
 operator std::map< Key, Data > ()
 
template<typename... T>
 operator std::tuple< T... > ()
 
template<typename... T>
 operator DBus::MultipleReturn< T... > ()
 
bool get_bool ()
 
uint8_t get_uint8 ()
 
uint16_t get_uint16 ()
 
int16_t get_int16 ()
 
uint32_t get_uint32 ()
 
int32_t get_int32 ()
 
uint64_t get_uint64 ()
 
int64_t get_int64 ()
 
double get_double ()
 
std::string get_string ()
 
std::shared_ptr< FileDescriptorget_filedescriptor ()
 
Variant get_variant ()
 
Signature get_signature ()
 
template<typename T >
void get_array (std::vector< T > &array)
 Get values in an array, pushing them back one at a time. More...
 
template<typename... T>
void get_struct (std::tuple< T... > &tup)
 
template<typename Key , typename Data >
void get_dict (std::map< Key, Data > &dict)
 
template<typename... T>
void get_multiplereturn (MultipleReturn< T... > &v)
 
template<typename Key , typename Data >
std::map< Key, Data > get_dict ()
 
template<typename Key , typename Data >
MessageIteratoroperator>> (std::map< Key, Data > &m)
 
template<typename... T>
MessageIteratoroperator>> (std::tuple< T... > &v)
 
template<typename T >
MessageIteratoroperator>> (std::vector< T > &v)
 
MessageIteratoroperator>> (Variant &v)
 
template<typename ... T>
MessageIteratoroperator>> (MultipleReturn< T... > &v)
 
template<typename T >
MessageIteratoroperator>> (T &v)
 
template<typename T >
get ()
 

Private Member Functions

 MessageIterator (DataType d, SignatureIterator sig, const Message *message, std::shared_ptr< Demarshaling > demarshal)
 Create a new sub-iterator. More...
 
SignatureIterator signature_iterator ()
 
void align (int alignment)
 Align our memory to the specified location. More...
 

Private Attributes

std::shared_ptr< priv_data > m_priv
 

Friends

class Variant
 

Detailed Description

Extraction iterator allowing values to be retrieved from a message.

Author
Rick L Vinyard Jr rviny.nosp@m.ard@.nosp@m.cs.nm.nosp@m.su.e.nosp@m.du

Constructor & Destructor Documentation

◆ MessageIterator() [1/4]

DBus::MessageIterator::MessageIterator ( DataType  d,
SignatureIterator  sig,
const Message message,
std::shared_ptr< Demarshaling demarshal 
)
private

Create a new sub-iterator.

Parameters
dThe data type we are iterating over
sigThe signature within the data type
messageOur parent message
demarshalThe demarshaller

References DBus::ARRAY, DBus::DICT_ENTRY, LOGGER_NAME, m_priv, message(), and DBus::STRUCT.

◆ MessageIterator() [2/4]

DBus::MessageIterator::MessageIterator ( )

References DBus::INVALID, and m_priv.

Referenced by recurse().

◆ MessageIterator() [3/4]

DBus::MessageIterator::MessageIterator ( const Message message)

References DBus::INVALID, m_priv, and message().

◆ MessageIterator() [4/4]

DBus::MessageIterator::MessageIterator ( std::shared_ptr< Message message)

References DBus::INVALID, m_priv, and message().

Member Function Documentation

◆ align()

void DBus::MessageIterator::align ( int  alignment)
private

Align our memory to the specified location.

This skips bytes. This is for internal use only; don't call it in client code!

Parameters
alignment

References m_priv.

◆ arg_type()

DataType DBus::MessageIterator::arg_type ( ) const

◆ element_type()

DataType DBus::MessageIterator::element_type ( ) const

Returns the element type of the array that the iterator points to.

If the iterator does not point to an array TYPE_INVALID is returned.

References arg_type(), DBus::ARRAY, DBus::INVALID, and m_priv.

Referenced by is_dict().

◆ get()

template<typename T >
T DBus::MessageIterator::get ( )
inline

References next().

◆ get_array()

template<typename T >
void DBus::MessageIterator::get_array ( std::vector< T > &  array)
inline

Get values in an array, pushing them back one at a time.

References is_array(), is_valid(), and recurse().

◆ get_bool()

bool DBus::MessageIterator::get_bool ( )

References arg_type(), DBus::BOOLEAN, and m_priv.

◆ get_dict() [1/2]

template<typename Key , typename Data >
std::map<Key, Data> DBus::MessageIterator::get_dict ( )
inline

◆ get_dict() [2/2]

template<typename Key , typename Data >
void DBus::MessageIterator::get_dict ( std::map< Key, Data > &  dict)
inline

References is_valid(), next(), and recurse().

◆ get_double()

double DBus::MessageIterator::get_double ( )

References arg_type(), DBus::DOUBLE, and m_priv.

◆ get_filedescriptor()

std::shared_ptr< FileDescriptor > DBus::MessageIterator::get_filedescriptor ( )

◆ get_int16()

int16_t DBus::MessageIterator::get_int16 ( )

References arg_type(), DBus::INT16, and m_priv.

◆ get_int32()

int32_t DBus::MessageIterator::get_int32 ( )

References arg_type(), DBus::INT32, and m_priv.

◆ get_int64()

int64_t DBus::MessageIterator::get_int64 ( )

References arg_type(), DBus::INT64, and m_priv.

◆ get_multiplereturn()

template<typename... T>
void DBus::MessageIterator::get_multiplereturn ( MultipleReturn< T... > &  v)
inline

◆ get_signature()

Signature DBus::MessageIterator::get_signature ( )

References m_priv.

Referenced by get_variant().

◆ get_string()

std::string DBus::MessageIterator::get_string ( )

◆ get_struct()

template<typename... T>
void DBus::MessageIterator::get_struct ( std::tuple< T... > &  tup)
inline

References recurse().

Referenced by operator std::tuple< T... >(), and operator>>().

◆ get_uint16()

uint16_t DBus::MessageIterator::get_uint16 ( )

References arg_type(), m_priv, and DBus::UINT16.

◆ get_uint32()

uint32_t DBus::MessageIterator::get_uint32 ( )

References arg_type(), m_priv, and DBus::UINT32.

◆ get_uint64()

uint64_t DBus::MessageIterator::get_uint64 ( )

References arg_type(), m_priv, and DBus::UINT64.

◆ get_uint8()

uint8_t DBus::MessageIterator::get_uint8 ( )

References arg_type(), DBus::BYTE, and m_priv.

◆ get_variant()

Variant DBus::MessageIterator::get_variant ( )

◆ has_next()

bool DBus::MessageIterator::has_next ( ) const

True if there are any more fields left to iterate over.

References is_valid(), and m_priv.

◆ invalidate()

void DBus::MessageIterator::invalidate ( )

Invalidates the iterator.

References m_priv.

Referenced by next().

◆ is_array()

bool DBus::MessageIterator::is_array ( ) const

True if the iterator points to an array.

References arg_type(), and DBus::ARRAY.

Referenced by get_array(), is_dict(), operator std::vector< T >(), and operator>>().

◆ is_container()

bool DBus::MessageIterator::is_container ( ) const

True if the iterator points to a container.

References arg_type(), and DBus::TypeInfo::is_container().

Referenced by recurse().

◆ is_dict()

bool DBus::MessageIterator::is_dict ( ) const

True if the iterator points to a dictionary.

References DBus::DICT_ENTRY, element_type(), and is_array().

Referenced by operator std::map< Key, Data >(), and operator>>().

◆ is_fixed()

bool DBus::MessageIterator::is_fixed ( ) const

True if the element type is a fixed type.

References arg_type(), and DBus::TypeInfo::is_fixed().

◆ is_valid()

bool DBus::MessageIterator::is_valid ( ) const

True if this is a valid iterator.

References arg_type(), DBus::ARRAY, DBus::INVALID, LOGGER_NAME, and m_priv.

Referenced by get_array(), get_dict(), has_next(), and next().

◆ message()

const Message * DBus::MessageIterator::message ( ) const

Returns a pointer to the message associated with this iterator or NULL if no message is associated.

References m_priv.

Referenced by MessageIterator().

◆ next()

bool DBus::MessageIterator::next ( )

Moves the iterator to the next field and invalidates it if it moves beyond the last field.

It is an error to call this function more than once in a row without a corresponding call to get_XXX/operator XXX.

Returns
true if the iterator moves forward, false if there is no next field and the iterator has been invalidated

References arg_type(), DBus::ARRAY, DBus::INVALID, invalidate(), is_valid(), and m_priv.

Referenced by get(), get_dict(), operator++(), and operator>>().

◆ operator bool()

DBus::MessageIterator::operator bool ( )

◆ operator DBus::MultipleReturn< T... >()

template<typename... T>
DBus::MessageIterator::operator DBus::MultipleReturn< T... > ( )
inline

References get_multiplereturn().

◆ operator double()

DBus::MessageIterator::operator double ( )

◆ operator int16_t()

DBus::MessageIterator::operator int16_t ( )

◆ operator int32_t()

DBus::MessageIterator::operator int32_t ( )

◆ operator int64_t()

DBus::MessageIterator::operator int64_t ( )

◆ operator std::map< Key, Data >()

template<typename Key , typename Data >
DBus::MessageIterator::operator std::map< Key, Data > ( )
inline

References is_dict().

◆ operator std::shared_ptr< FileDescriptor >()

DBus::MessageIterator::operator std::shared_ptr< FileDescriptor > ( )

References DBus::UNIX_FD.

◆ operator std::string()

DBus::MessageIterator::operator std::string ( )

◆ operator std::tuple< T... >()

template<typename... T>
DBus::MessageIterator::operator std::tuple< T... > ( )
inline

References get_struct().

◆ operator std::vector< T >()

template<typename T >
DBus::MessageIterator::operator std::vector< T > ( )
inline

References is_array().

◆ operator uint16_t()

DBus::MessageIterator::operator uint16_t ( )

◆ operator uint32_t()

DBus::MessageIterator::operator uint32_t ( )

◆ operator uint64_t()

DBus::MessageIterator::operator uint64_t ( )

◆ operator uint8_t()

DBus::MessageIterator::operator uint8_t ( )

◆ operator Variant()

DBus::MessageIterator::operator Variant ( )

References DBus::VARIANT.

◆ operator++() [1/2]

MessageIterator & DBus::MessageIterator::operator++ ( )

References next().

◆ operator++() [2/2]

MessageIterator DBus::MessageIterator::operator++ ( int  )

◆ operator==()

bool DBus::MessageIterator::operator== ( const MessageIterator other)

References m_priv.

◆ operator>>() [1/6]

template<typename ... T>
MessageIterator& DBus::MessageIterator::operator>> ( MultipleReturn< T... > &  v)
inline

References get_multiplereturn(), and next().

◆ operator>>() [2/6]

template<typename Key , typename Data >
MessageIterator& DBus::MessageIterator::operator>> ( std::map< Key, Data > &  m)
inline

References is_dict(), and next().

◆ operator>>() [3/6]

template<typename... T>
MessageIterator& DBus::MessageIterator::operator>> ( std::tuple< T... > &  v)
inline

References get_struct(), and next().

◆ operator>>() [4/6]

template<typename T >
MessageIterator& DBus::MessageIterator::operator>> ( std::vector< T > &  v)
inline

References is_array(), and next().

◆ operator>>() [5/6]

template<typename T >
MessageIterator& DBus::MessageIterator::operator>> ( T &  v)
inline

References next().

◆ operator>>() [6/6]

MessageIterator& DBus::MessageIterator::operator>> ( Variant v)
inline

References get_variant(), and next().

◆ recurse()

MessageIterator DBus::MessageIterator::recurse ( )

If the iterator points to a container recurses into the container returning a sub-iterator.

If the iterator does not point to a container returns an empty (invalid) iterator.

References is_container(), m_priv, and MessageIterator().

Referenced by get_array(), get_dict(), and get_struct().

◆ signature()

std::string DBus::MessageIterator::signature ( ) const

Returns the current signature of the iterator.

References m_priv.

◆ signature_iterator()

SignatureIterator DBus::MessageIterator::signature_iterator ( )
private

References m_priv.

Friends And Related Function Documentation

◆ Variant

friend class Variant
friend

Member Data Documentation

◆ m_priv


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