reSIProcate/stack  9694
Classes | Public Types | Public Member Functions | Static Private Member Functions | Friends
resip::ParserContainer< T > Class Template Reference

Container class for ParserCategory, used by SipMessage to represent multi-valued headers (Contact, Via, etc). More...

#include <ParserContainer.hxx>

Inheritance diagram for resip::ParserContainer< T >:
Inheritance graph
[legend]
Collaboration diagram for resip::ParserContainer< T >:
Collaboration graph
[legend]

List of all members.

Classes

class  const_iterator
 A const_iterator class, derived from std::iterator (bidirectional) More...
class  iterator
 An iterator class, derived from std::iterator (bidirectional) More...

Public Types

typedef T value_type
typedef value_typepointer
typedef const value_typeconst_pointer
typedef value_typereference
typedef const value_typeconst_reference
typedef ptrdiff_t difference_type
typedef
ParserContainerBase::Parsers 
Parsers

Public Member Functions

 ParserContainer ()
 Default c'tor.
 ParserContainer (PoolBase &pool)
 ParserContainer (HeaderFieldValueList *hfvs, Headers::Type type=Headers::UNKNOWN)
 Used by SipMessage (using this carries a high risk of blowing your feet off).
 ParserContainer (HeaderFieldValueList *hfvs, Headers::Type type, PoolBase &pool)
 ParserContainer (const ParserContainer &other)
 Copy c'tor.
 ParserContainer (const ParserContainer &other, PoolBase &pool)
 Copy c'tor.
ParserContaineroperator= (const ParserContainer &other)
 Assignment operator.
T & front ()
 Returns the first header field value in this container.
T & back ()
 Returns the last header field value in this container.
const T & front () const
 Returns the first header field value in this container.
const T & back () const
 Returns the last header field value in this container.
void push_front (const T &t)
 Inserts a header field value at the front of this container.
void push_back (const T &t)
 Inserts a header field value at the back of this container.
ParserContainer reverse () const
 Returns a copy of this ParserContainer, in reverse order.
iterator begin ()
 Returns an iterator pointing to the first header field value.
iterator end ()
 Returns an iterator pointing to the last header field value.
iterator erase (iterator i)
 Erases the header field value pointed to by i.
bool find (const T &rhs) const
 Finds the first header field value that matches rhs.
virtual void parseAll ()
 Triggers a parse of all contained header field values.
const_iterator begin () const
 Returns a const_iterator pointing to the first header field value.
const_iterator end () const
 Returns a const_iterator pointing to the first header field value.
virtual ParserContainerBaseclone () const
 Clones this container, and all contained header field values.

Static Private Member Functions

static T & ensureInitialized (HeaderKit &kit, ParserContainer *ref)
static const T & ensureInitialized (const HeaderKit &kit, const ParserContainer *ref)

Friends

class ParserContainer< T >::iterator
class ParserContainer< T >::const_iterator

Detailed Description

template<class T>
class resip::ParserContainer< T >

Container class for ParserCategory, used by SipMessage to represent multi-valued headers (Contact, Via, etc).

This has an interface that is similar to stl containers, but not as complete.

Definition at line 22 of file ParserContainer.hxx.


Member Typedef Documentation

template<class T>
typedef const value_type* resip::ParserContainer< T >::const_pointer

Definition at line 27 of file ParserContainer.hxx.

template<class T>
typedef const value_type& resip::ParserContainer< T >::const_reference

Definition at line 29 of file ParserContainer.hxx.

template<class T>
typedef ptrdiff_t resip::ParserContainer< T >::difference_type

Definition at line 30 of file ParserContainer.hxx.

Reimplemented from resip::ParserContainerBase.

Definition at line 162 of file ParserContainer.hxx.

template<class T>
typedef value_type* resip::ParserContainer< T >::pointer

Definition at line 26 of file ParserContainer.hxx.

template<class T>
typedef value_type& resip::ParserContainer< T >::reference

Definition at line 28 of file ParserContainer.hxx.

template<class T>
typedef T resip::ParserContainer< T >::value_type

Definition at line 25 of file ParserContainer.hxx.


Constructor & Destructor Documentation

template<class T>
resip::ParserContainer< T >::ParserContainer ( ) [inline]

Default c'tor.

Definition at line 35 of file ParserContainer.hxx.

Referenced by resip::ParserContainer< NameAddr >::clone().

template<class T>
resip::ParserContainer< T >::ParserContainer ( PoolBase pool) [inline]

Definition at line 39 of file ParserContainer.hxx.

template<class T>
resip::ParserContainer< T >::ParserContainer ( HeaderFieldValueList hfvs,
Headers::Type  type = Headers::UNKNOWN 
) [inline]

Used by SipMessage (using this carries a high risk of blowing your feet off).

Definition at line 48 of file ParserContainer.hxx.

         : ParserContainerBase(type)
      {
         mParsers.reserve(hfvs->size());
         for (HeaderFieldValueList::iterator i = hfvs->begin();
              i != hfvs->end(); i++)
         {
            // create, store without copying -- 
            // keeps the HeaderFieldValue from reallocating its buffer
            mParsers.push_back(HeaderKit::Empty);
            mParsers.back().hfv.init(i->getBuffer(),i->getLength(),false);
         }
      }
template<class T>
resip::ParserContainer< T >::ParserContainer ( HeaderFieldValueList hfvs,
Headers::Type  type,
PoolBase pool 
) [inline]

Definition at line 63 of file ParserContainer.hxx.

         : ParserContainerBase(type,pool)
      {
         mParsers.reserve(hfvs->size());
         for (HeaderFieldValueList::iterator i = hfvs->begin();
              i != hfvs->end(); i++)
         {
            // create, store without copying -- 
            // keeps the HeaderFieldValue from reallocating its buffer
            mParsers.push_back(HeaderKit::Empty);
            mParsers.back().hfv.init(i->getBuffer(),i->getLength(),false);
         }
      }
template<class T>
resip::ParserContainer< T >::ParserContainer ( const ParserContainer< T > &  other) [inline]

Copy c'tor.

Definition at line 82 of file ParserContainer.hxx.

         : ParserContainerBase(other)
      {}
template<class T>
resip::ParserContainer< T >::ParserContainer ( const ParserContainer< T > &  other,
PoolBase pool 
) [inline]

Copy c'tor.

Definition at line 89 of file ParserContainer.hxx.

         : ParserContainerBase(other, pool)
      {}

Member Function Documentation

template<class T>
T& resip::ParserContainer< T >::back ( ) [inline]

Returns the last header field value in this container.

Definition at line 112 of file ParserContainer.hxx.

      { 
         return ensureInitialized(mParsers.back(),this);
      }
template<class T>
const T& resip::ParserContainer< T >::back ( ) const [inline]

Returns the last header field value in this container.

Definition at line 128 of file ParserContainer.hxx.

      { 
         return ensureInitialized(mParsers.back(),this);
      }
template<class T>
iterator resip::ParserContainer< T >::begin ( ) [inline]

Returns an iterator pointing to the first header field value.

Definition at line 242 of file ParserContainer.hxx.

Referenced by resip::Helper::addAuthorization(), resip::Helper::advancedAuthenticateRequest(), resip::Helper::authenticateRequest(), resip::Helper::authenticateRequestWithA1(), and main().

{ return iterator(mParsers.begin(),this); }
template<class T>
const_iterator resip::ParserContainer< T >::begin ( ) const [inline]

Returns a const_iterator pointing to the first header field value.

Definition at line 294 of file ParserContainer.hxx.

{ return const_iterator(mParsers.begin(),this); }
template<class T>
virtual ParserContainerBase* resip::ParserContainer< T >::clone ( ) const [inline, virtual]

Clones this container, and all contained header field values.

Implements resip::ParserContainerBase.

Definition at line 305 of file ParserContainer.hxx.

      {
         return new ParserContainer(*this);
      }
template<class T>
iterator resip::ParserContainer< T >::end ( ) [inline]

Returns an iterator pointing to the last header field value.

Definition at line 247 of file ParserContainer.hxx.

Referenced by resip::Helper::addAuthorization(), resip::Helper::advancedAuthenticateRequest(), resip::Helper::authenticateRequest(), and resip::Helper::authenticateRequestWithA1().

{ return iterator(mParsers.end(),this); }
template<class T>
const_iterator resip::ParserContainer< T >::end ( ) const [inline]

Returns a const_iterator pointing to the first header field value.

Definition at line 300 of file ParserContainer.hxx.

{ return const_iterator(mParsers.end(),this); }
template<class T>
static T& resip::ParserContainer< T >::ensureInitialized ( HeaderKit kit,
ParserContainer< T > *  ref 
) [inline, static, private]
template<class T>
static const T& resip::ParserContainer< T >::ensureInitialized ( const HeaderKit kit,
const ParserContainer< T > *  ref 
) [inline, static, private]

Definition at line 334 of file ParserContainer.hxx.

      {
         if(!kit.pc)
         {
            HeaderKit& nc_kit(const_cast<HeaderKit&>(kit));
            if(ref)
            {
               ParserContainer* nc_ref(const_cast<ParserContainer*>(ref));
               PoolBase* pool(nc_ref->mPool);
               nc_kit.pc=new (pool) T(kit.hfv, ref->mType, pool);
            }
            else
            {
               nc_kit.pc=new T(kit.hfv, Headers::NONE);
            }
         }
         return *static_cast<T*>(kit.pc);
      }
template<class T>
iterator resip::ParserContainer< T >::erase ( iterator  i) [inline]

Erases the header field value pointed to by i.

Invalidates all existing iterators.

Definition at line 253 of file ParserContainer.hxx.

Referenced by main().

      {
         freeParser(*i.mIt);
         return iterator(mParsers.erase(i.mIt),this);
      }
template<class T>
bool resip::ParserContainer< T >::find ( const T &  rhs) const [inline]

Finds the first header field value that matches rhs.

Definition at line 262 of file ParserContainer.hxx.

Referenced by main().

      {
         for (typename Parsers::const_iterator i = mParsers.begin();
              i != mParsers.end(); ++i)
         {
            // operator== defined by default, but often not usefully
            if (rhs.isEqual(ensureInitialized(*i,this)))
            {
               return true;
            }
         }

         return false;
      }
template<class T>
T& resip::ParserContainer< T >::front ( ) [inline]

Returns the first header field value in this container.

Definition at line 104 of file ParserContainer.hxx.

      {
         return ensureInitialized(mParsers.front(),this);
      }
template<class T>
const T& resip::ParserContainer< T >::front ( ) const [inline]

Returns the first header field value in this container.

Definition at line 120 of file ParserContainer.hxx.

      { 
         return ensureInitialized(mParsers.front(),this);
      }
template<class T>
ParserContainer& resip::ParserContainer< T >::operator= ( const ParserContainer< T > &  other) [inline]

Assignment operator.

Definition at line 96 of file ParserContainer.hxx.

Referenced by resip::ParserContainer< NameAddr >::operator=().

      {
         return static_cast<ParserContainer&>(ParserContainerBase::operator=(other));
      }
template<class T>
virtual void resip::ParserContainer< T >::parseAll ( ) [inline, virtual]

Triggers a parse of all contained header field values.

Exceptions:
ParseExceptionif any header field value is malformed.

Implements resip::ParserContainerBase.

Definition at line 281 of file ParserContainer.hxx.

      {
         for (typename Parsers::const_iterator i = mParsers.begin();
              i != mParsers.end(); ++i)
         {
            ensureInitialized(*i,this).checkParsed();
         }
      }
template<class T>
void resip::ParserContainer< T >::push_back ( const T &  t) [inline]

Inserts a header field value at the back of this container.

Definition at line 145 of file ParserContainer.hxx.

Referenced by main().

      { 
         mParsers.push_back(HeaderKit::Empty);
         mParsers.back().pc=makeParser(t);
      }
template<class T>
void resip::ParserContainer< T >::push_front ( const T &  t) [inline]

Inserts a header field value at the front of this container.

Definition at line 136 of file ParserContainer.hxx.

      { 
         mParsers.insert(mParsers.begin(), HeaderKit::Empty);
         mParsers.front().pc=makeParser(t);
      }
template<class T>
ParserContainer resip::ParserContainer< T >::reverse ( ) const [inline]

Returns a copy of this ParserContainer, in reverse order.

Todo:
!bwc! optimize this (we are copying each ParserContainer twice)

Definition at line 155 of file ParserContainer.hxx.

Referenced by resip::ParserContainer< NameAddr >::reverse().

      {
         ParserContainer tmp(*this);
         std::reverse(tmp.mParsers.begin(), tmp.mParsers.end());
         return tmp;
      }

Friends And Related Function Documentation

template<class T>
friend class ParserContainer< T >::const_iterator [friend]

Definition at line 312 of file ParserContainer.hxx.

template<class T>
friend class ParserContainer< T >::iterator [friend]

Definition at line 311 of file ParserContainer.hxx.


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