astxx::manager::message::basic_message< message_traits > Class Template Reference

#include <astxx/manager/message.h>

Collaboration diagram for astxx::manager::message::basic_message< message_traits >:

Collaboration graph
[legend]

List of all members.


Detailed Description

template<typename message_traits>
class astxx::manager::message::basic_message< message_traits >

An Asterisk Manager message.

The main method for accessing headers in a manager::basic_message is through the [] operator. In the case where multiple headers have the same key, the message should be accessed in the same manner as an std::multimap (i.e. using the equal_range() function).

Note:
Headers and values for manager::basic_message objects are stored exactly as they are recieved from Asterisk. As a result, the exact case Asterisk for headers must be used to look up values.

Definition at line 68 of file message.h.


Public Types

typedef std::pair< std::string,
std::string > 
header_pair_t
typedef std::multimap
< std::string, std::string > 
header_t

Public Member Functions

 basic_message (const header_t::iterator begin, const header_t::iterator end)
 Construct a message from a set of iterators.
 basic_message (const std::map< std::string, std::string > &headers)
 Construct a message from an existing std::map of headers.
 basic_message (const header_t &headers)
 Construct a message from an existing std::multimap of headers.
 basic_message (const std::string &value)
 Construct a message initilizing the value of the main header.
header_t::iterator begin ()
 Get an iterator to the first header.
header_t::iterator end ()
 Get an iterator to one past the last header.
std::pair< header_t::iterator,
header_t::iterator > 
equal_range (const std::string &key)
 Get a pair of iterators pointing to the beginning and one past the end of a group of headers matching the given key.
std::string format ()
 Format this message as a string.
void insert (header_t::iterator begin, header_t::iterator end)
 Insert key value pairs into the message.
header_t::iterator insert (const header_pair_t &pair)
 Add a key value pair to the header.
std::string main_header () const
 Get the value of the main header for this message.
bool operator!= (const std::string &s) const
 Compare the main header for this message to a string.
bool operator== (const std::string &s) const
 Compare the main header for this message to a string.
std::string & operator[] (const std::string &key)
 Get the header that matches the given key.

Public Attributes

std::string data
 Addition data from the 'Command' action.
message_traits traits

Constructor & Destructor Documentation

template<typename message_traits>
astxx::manager::message::basic_message< message_traits >::basic_message ( const std::string &  value  )  [inline]

Construct a message initilizing the value of the main header.

Parameters:
value the initial value of the main header

Definition at line 85 of file message.h.

References astxx::manager::message::basic_message< message_traits >::operator[]().

template<typename message_traits>
astxx::manager::message::basic_message< message_traits >::basic_message ( const header_t &  headers  )  [inline, explicit]

Construct a message from an existing std::multimap of headers.

Parameters:
headers an std::multimap of headers

Definition at line 92 of file message.h.

template<typename message_traits>
astxx::manager::message::basic_message< message_traits >::basic_message ( const std::map< std::string, std::string > &  headers  )  [inline, explicit]

Construct a message from an existing std::map of headers.

Parameters:
headers an std::map of headers

Definition at line 97 of file message.h.

template<typename message_traits>
astxx::manager::message::basic_message< message_traits >::basic_message ( const header_t::iterator  begin,
const header_t::iterator  end 
) [inline, explicit]

Construct a message from a set of iterators.

Parameters:
begin the start iterator
end the end iterator

Definition at line 103 of file message.h.


Member Function Documentation

template<typename message_traits>
header_t::iterator astxx::manager::message::basic_message< message_traits >::begin (  )  [inline]

Get an iterator to the first header.

Returns:
an iterator to the first header

Definition at line 171 of file message.h.

template<typename message_traits>
header_t::iterator astxx::manager::message::basic_message< message_traits >::end (  )  [inline]

Get an iterator to one past the last header.

Returns:
an iterator to one past the last header

Definition at line 178 of file message.h.

template<typename message_traits>
std::pair<header_t::iterator, header_t::iterator> astxx::manager::message::basic_message< message_traits >::equal_range ( const std::string &  key  )  [inline]

Get a pair of iterators pointing to the beginning and one past the end of a group of headers matching the given key.

Parameters:
key the key to use for lookup
Returns:
an std::pair of iterators

Definition at line 164 of file message.h.

template<typename message_traits>
std::string astxx::manager::message::basic_message< message_traits >::format (  )  [inline]

Format this message as a string.

Returns:
this message formatted as a string
Exceptions:
manager::message::header_missing if the main header is missing

Definition at line 187 of file message.h.

References astxx::manager::message::basic_message< message_traits >::operator[]().

Referenced by astxx::manager::connection::send_action_async().

template<typename message_traits>
void astxx::manager::message::basic_message< message_traits >::insert ( header_t::iterator  begin,
header_t::iterator  end 
) [inline]

Insert key value pairs into the message.

Parameters:
begin the start of the pairs
end the end of the pairs

Definition at line 155 of file message.h.

template<typename message_traits>
header_t::iterator astxx::manager::message::basic_message< message_traits >::insert ( const header_pair_t &  pair  )  [inline]

Add a key value pair to the header.

Parameters:
pair the pair
Returns:
an iterator to the inserted pair

Definition at line 147 of file message.h.

Referenced by astxx::manager::action::user_event::action(), and astxx::manager::action::originate::action().

template<typename message_traits>
std::string astxx::manager::message::basic_message< message_traits >::main_header (  )  const [inline]

Get the value of the main header for this message.

Note:
this will be the value of the Action, Event, or Response header.
Returns:
the value of the main header
Exceptions:
manager::message::header_missing if the main header is missing

Definition at line 217 of file message.h.

Referenced by astxx::manager::message::basic_message< message_traits >::operator==(), and astxx::manager::connection::process_events().

template<typename message_traits>
bool astxx::manager::message::basic_message< message_traits >::operator!= ( const std::string &  s  )  const [inline]

Compare the main header for this message to a string.

Parameters:
s the string
Returns:
the result of the compairson
Exceptions:
manager::message::header_missing if the main header is missing

Definition at line 139 of file message.h.

template<typename message_traits>
bool astxx::manager::message::basic_message< message_traits >::operator== ( const std::string &  s  )  const [inline]

Compare the main header for this message to a string.

Parameters:
s the string
Returns:
the result of the compairson
Exceptions:
manager::message::header_missing if the main header is missing

Definition at line 129 of file message.h.

References astxx::manager::message::basic_message< message_traits >::main_header().

template<typename message_traits>
std::string& astxx::manager::message::basic_message< message_traits >::operator[] ( const std::string &  key  )  [inline]

Get the header that matches the given key.

Parameters:
key the key to use for lookup
This function looks up the given key in the message's internal multimap and returns the first matching value if there are multiple matches. It will also create an entry with the given key if no entry could be found (just like std::map).

Returns:
a reference to the value matching the given key

Definition at line 115 of file message.h.

Referenced by astxx::manager::message::basic_message< message_traits >::basic_message(), and astxx::manager::message::basic_message< message_traits >::format().


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

Generated on Thu Jul 3 01:32:51 2008 for Astxx by  doxygen 1.5.6