reSIProcate/stack  9694
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
resip::ParserContainerBase Class Reference

Abstract Base class implemented in derived class ParserContainer. More...

#include <ParserContainerBase.hxx>

Inheritance diagram for resip::ParserContainerBase:
Inheritance graph
[legend]
Collaboration diagram for resip::ParserContainerBase:
Collaboration graph
[legend]

List of all members.

Classes

class  HeaderKit

Public Types

typedef size_t size_type

Public Member Functions

 ParserContainerBase (Headers::Type type=Headers::UNKNOWN)
 constructor; sets the type only
 ParserContainerBase (Headers::Type type, PoolBase &pool)
 constructor; sets the type only
 ParserContainerBase (const ParserContainerBase &rhs)
 copy constructor copies the mType and the mParsers from the rhs
 ParserContainerBase (const ParserContainerBase &rhs, PoolBase &pool)
ParserContainerBaseoperator= (const ParserContainerBase &rhs)
 assignment operator copies the mParsers from the rhs
virtual ~ParserContainerBase ()
 virtual destructor - empty in this class
void clear ()
 clear the mParsers vector
virtual ParserContainerBaseclone () const =0
 pure virtual function to be implemented in derived classes with the intention of cloning this object
size_t size () const
 return the size of the mParsers vector
bool empty () const
 return true or false indicating whether the mParsers vector is empty or not
EncodeStreamencode (const Data &headerName, EncodeStream &str) const
 the actual mechanics of parsing
std::ostream & encode (Headers::Type type, std::ostream &str) const
 the actual mechanics of parsing
EncodeStreamencodeEmbedded (const Data &headerName, EncodeStream &str) const
 the actual mechanics of parsing
void pop_front ()
 if mParsers vector is not empty, erase the first element
void pop_back ()
 if mParsers vector is not empty, erase the first element
void append (const ParserContainerBase &rhs)
 append the vector to the mParsers vector held locally
virtual void parseAll ()=0
 pure virtual function to be implemented in derived classes The intention is to provide an ability to parse all elements in the mParsers vector.

Protected Types

typedef std::vector< HeaderKit,
StlPoolAllocator< HeaderKit,
PoolBase > > 
Parsers

Protected Member Functions

void copyParsers (const Parsers &parsers)
 copy header kits
void freeParsers ()
 free parser containers
void freeParser (HeaderKit &kit)
ParserCategorymakeParser (const ParserCategory &orig)

Protected Attributes

const Headers::Type mType
Parsers mParsers
 the actual list (vector) of parsers on which encoding is done
PoolBasemPool

Detailed Description

Abstract Base class implemented in derived class ParserContainer.

Definition at line 22 of file ParserContainerBase.hxx.


Member Typedef Documentation

Definition at line 25 of file ParserContainerBase.hxx.


Constructor & Destructor Documentation

ParserContainerBase::ParserContainerBase ( Headers::Type  type = Headers::UNKNOWN)

constructor; sets the type only

Definition at line 11 of file ParserContainerBase.cxx.

   : mType(type),
     mPool(0)
{}
ParserContainerBase::ParserContainerBase ( Headers::Type  type,
PoolBase pool 
)

constructor; sets the type only

Definition at line 24 of file ParserContainerBase.cxx.

ParserContainerBase::ParserContainerBase ( const ParserContainerBase rhs)

copy constructor copies the mType and the mParsers from the rhs

Note:
this is a shallow copy

Definition at line 16 of file ParserContainerBase.cxx.

References copyParsers(), and mParsers.

   : mType(rhs.mType),
     mParsers(),
     mPool(0)
{
   copyParsers(rhs.mParsers);
}

Here is the call graph for this function:

ParserContainerBase::ParserContainerBase ( const ParserContainerBase rhs,
PoolBase pool 
)

Definition at line 31 of file ParserContainerBase.cxx.

References copyParsers(), and mParsers.

Here is the call graph for this function:

ParserContainerBase::~ParserContainerBase ( ) [virtual]

virtual destructor - empty in this class

Definition at line 40 of file ParserContainerBase.cxx.

References freeParsers().

Referenced by resip::HeaderFieldValueList::freeParserContainer().

{
   freeParsers();
}

Here is the call graph for this function:


Member Function Documentation

void ParserContainerBase::append ( const ParserContainerBase rhs)

append the vector to the mParsers vector held locally

Parameters:
rhsis the vector whose elements will be added to the local mParsers vector

Definition at line 74 of file ParserContainerBase.cxx.

References copyParsers(), and mParsers.

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

{
   copyParsers(source.mParsers);
}

Here is the call graph for this function:

void resip::ParserContainerBase::clear ( void  ) [inline]

clear the mParsers vector

Definition at line 61 of file ParserContainerBase.hxx.

References mParsers.

Referenced by resip::DeprecatedDialog::clear().

{mParsers.clear();}
virtual ParserContainerBase* resip::ParserContainerBase::clone ( ) const [pure virtual]

pure virtual function to be implemented in derived classes with the intention of cloning this object

Implemented in resip::ParserContainer< T >, and resip::ParserContainer< NameAddr >.

Referenced by resip::HeaderFieldValueList::HeaderFieldValueList(), and resip::HeaderFieldValueList::operator=().

void ParserContainerBase::copyParsers ( const Parsers parsers) [protected]

copy header kits

Definition at line 152 of file ParserContainerBase.cxx.

References makeParser(), mParsers, and resip::ParserContainerBase::HeaderKit::pc.

Referenced by append(), operator=(), and ParserContainerBase().

{
   mParsers.reserve(mParsers.size() + parsers.size());
   for(Parsers::const_iterator p=parsers.begin(); p!=parsers.end(); ++p)
   {
      mParsers.push_back(*p);
      HeaderKit& kit(mParsers.back());
      if(kit.pc)
      {
         kit.pc = makeParser(*kit.pc);
      }
   }
}

Here is the call graph for this function:

bool resip::ParserContainerBase::empty ( ) const [inline]

return true or false indicating whether the mParsers vector is empty or not

Definition at line 78 of file ParserContainerBase.hxx.

References mParsers.

Referenced by resip::Helper::authenticateRequest(), resip::Helper::authenticateRequestWithA1(), and resip::HeaderFieldValueList::parsedEmpty().

{return mParsers.empty();}
EncodeStream & ParserContainerBase::encode ( const Data headerName,
EncodeStream str 
) const

the actual mechanics of parsing

Todo:
add support for headers that are allowed to be empty like Supported, Accept-Encoding, Allow-Events, Allow, Accept, Accept-Language

Definition at line 80 of file ParserContainerBase.cxx.

References resip::Symbols::COLON, resip::Symbols::COMMA, resip::Symbols::CRLF, CRLF, resip::Data::empty(), resip::Headers::isCommaEncoding(), mParsers, mType, and resip::Symbols::SPACE.

Referenced by resip::HeaderFieldValueList::encode(), and encodeEmbedded().

{
   // !jf! this is not strictly correct since some headers are allowed to
   // be empty: Supported, Accept-Encoding, Allow-Events, Allow,
   // Accept,Accept-Language 
   if (!mParsers.empty())
   {
      if (!headerName.empty())
      {
         str << headerName << Symbols::COLON[0] << Symbols::SPACE[0];
      }
         
      for (Parsers::const_iterator i = mParsers.begin(); 
           i != mParsers.end(); ++i)
      {
         if (i != mParsers.begin())
         {
            if (Headers::isCommaEncoding(mType))
            {
               str << Symbols::COMMA[0] << Symbols::SPACE[0];
            }
            else
            {
               str << Symbols::CRLF << headerName << Symbols::COLON[0] << Symbols::SPACE[0];
            }
         }

         i->encode(str);
      }

      str << Symbols::CRLF;
   }
         
   return str;
}

Here is the call graph for this function:

std::ostream& resip::ParserContainerBase::encode ( Headers::Type  type,
std::ostream &  str 
) const

the actual mechanics of parsing

EncodeStream & ParserContainerBase::encodeEmbedded ( const Data headerName,
EncodeStream str 
) const

the actual mechanics of parsing

Definition at line 118 of file ParserContainerBase.cxx.

References resip::Symbols::AMPERSAND, resip::Data::empty(), encode(), resip::Symbols::EQUALS, and mParsers.

Referenced by resip::HeaderFieldValueList::encodeEmbedded().

{
   assert(!headerName.empty());

   if (!mParsers.empty())
   {

      bool first = true;
      for (Parsers::const_iterator i = mParsers.begin(); 
           i != mParsers.end(); ++i)
      {
         if (first)
         {
            first = false;
         }
         else
         {
            str << Symbols::AMPERSAND;
         }

         str << headerName << Symbols::EQUALS;
         Data buf;
         {
            DataStream s(buf);
            i->encode(s);
         }
         str << Embedded::encode(buf);
      }
   }
   return str;
}

Here is the call graph for this function:

void resip::ParserContainerBase::freeParser ( HeaderKit kit) [inline, protected]

Definition at line 188 of file ParserContainerBase.hxx.

References resip::PoolBase::deallocate(), mPool, resip::ParserContainerBase::HeaderKit::pc, and resip::ParserCategory::~ParserCategory().

Referenced by resip::ParserContainer< NameAddr >::erase(), freeParsers(), pop_back(), and pop_front().

      {
         if(kit.pc)
         {
            kit.pc->~ParserCategory();
            if(mPool)
            {
               mPool->deallocate(kit.pc);
            }
            else
            {
               ::operator delete(kit.pc);
            }
            kit.pc=0;
         }
      }

Here is the call graph for this function:

void ParserContainerBase::freeParsers ( ) [protected]

free parser containers

Definition at line 167 of file ParserContainerBase.cxx.

References freeParser(), and mParsers.

Referenced by operator=(), and ~ParserContainerBase().

{
   for(Parsers::iterator p=mParsers.begin(); p!=mParsers.end(); ++p)
   {
      freeParser(*p);
   }
}

Here is the call graph for this function:

ParserCategory* resip::ParserContainerBase::makeParser ( const ParserCategory orig) [inline, protected]

Definition at line 205 of file ParserContainerBase.hxx.

References resip::ParserCategory::clone(), and mPool.

Referenced by copyParsers(), resip::ParserContainer< NameAddr >::push_back(), and resip::ParserContainer< NameAddr >::push_front().

      {
         return orig.clone(mPool);
      }

Here is the call graph for this function:

ParserContainerBase & ParserContainerBase::operator= ( const ParserContainerBase rhs)

assignment operator copies the mParsers from the rhs

Note:
this is a shallow copy

Definition at line 46 of file ParserContainerBase.cxx.

References copyParsers(), freeParsers(), and mParsers.

{
   if (this != &rhs)
   {
      freeParsers();
      mParsers.clear();
      copyParsers(rhs.mParsers);
   }
   return *this;
}

Here is the call graph for this function:

virtual void resip::ParserContainerBase::parseAll ( ) [pure virtual]

pure virtual function to be implemented in derived classes The intention is to provide an ability to parse all elements in the mParsers vector.

Implemented in resip::ParserContainer< T >, and resip::ParserContainer< NameAddr >.

Referenced by resip::SipMessage::parseAllHeaders().

void ParserContainerBase::pop_back ( )

if mParsers vector is not empty, erase the first element

Definition at line 66 of file ParserContainerBase.cxx.

References freeParser(), and mParsers.

{
   assert(!mParsers.empty());
   freeParser(mParsers.back());
   mParsers.pop_back(); 
}

Here is the call graph for this function:

void ParserContainerBase::pop_front ( )

if mParsers vector is not empty, erase the first element

Definition at line 58 of file ParserContainerBase.cxx.

References freeParser(), and mParsers.

{
   assert(!mParsers.empty());
   freeParser(mParsers.front());
   mParsers.erase(mParsers.begin());
}

Here is the call graph for this function:

size_t resip::ParserContainerBase::size ( ) const [inline]

return the size of the mParsers vector

Definition at line 72 of file ParserContainerBase.hxx.

References mParsers.

Referenced by main(), and resip::TuIM::processRegisterRequest().

{return mParsers.size();}

Member Data Documentation


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