reSIProcate/stack  9694
Public Types | Public Member Functions | Protected Attributes | Static Private Attributes
resip::NameAddr Class Reference

Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar. More...

#include <NameAddr.hxx>

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

List of all members.

Public Types

enum  { commaHandling = CommasAllowedOutputMulti }

Public Member Functions

 NameAddr ()
 NameAddr (const HeaderFieldValue &hfv, Headers::Type type, PoolBase *pool=0)
 NameAddr (const Uri &orig)
 NameAddr (const Data &unparsed, bool preCacheAor=false)
 NameAddr (const NameAddr &orig, PoolBase *pool=0)
NameAddroperator= (const NameAddr &)
bool operator== (const NameAddr &other) const
virtual ~NameAddr ()
Uriuri ()
const Uriuri () const
DatadisplayName ()
const DatadisplayName () const
bool isAllContacts () const
void setAllContacts ()
virtual void parse (ParseBuffer &pb)
virtual ParserCategoryclone () const
virtual ParserCategoryclone (void *location) const
virtual ParserCategoryclone (PoolBase *pool) const
virtual EncodeStreamencodeParsed (EncodeStream &str) const
bool operator< (const NameAddr &other) const
bool mustQuoteDisplayName () const
virtual ParametercreateParam (ParameterTypes::Type type, ParseBuffer &pb, const std::bitset< 256 > &terminators, PoolBase *pool)
bool exists (const Param< NameAddr > &paramType) const
void remove (const Param< NameAddr > &paramType)
 defineParam (data,"data", ExistsParameter,"RFC 3840")
 defineParam (control,"control", ExistsParameter,"RFC 3840")
 defineParam (mobility,"mobility", QuotedDataParameter,"RFC 3840")
 defineParam (description,"description", QuotedDataParameter,"RFC 3840")
 defineParam (events,"events", QuotedDataParameter,"RFC 3840")
 defineParam (priority,"priority", QuotedDataParameter,"RFC 3840")
 defineParam (methods,"methods", QuotedDataParameter,"RFC 3840")
 defineParam (schemes,"schemes", QuotedDataParameter,"RFC 3840")
 defineParam (application,"application", ExistsParameter,"RFC 3840")
 defineParam (video,"video", ExistsParameter,"RFC 3840")
 defineParam (language,"language", QuotedDataParameter,"RFC 3840")
 defineParam (type,"type", QuotedDataParameter,"RFC 3840")
 defineParam (isFocus,"isfocus", ExistsParameter,"RFC 3840")
 defineParam (actor,"actor", QuotedDataParameter,"RFC 3840")
 defineParam (text,"text", ExistsOrDataParameter,"RFC 3840")
 defineParam (extensions,"extensions", QuotedDataParameter,"RFC 3840")
 defineParam (Instance,"+sip.instance", QuotedDataParameter,"RFC 5626")
 defineParam (regid,"reg-id", UInt32Parameter,"RFC 5626")
 defineParam (pubGruu,"pub-gruu", QuotedDataParameter,"RFC 5627")
 defineParam (tempGruu,"temp-gruu", QuotedDataParameter,"RFC 5627")
 defineParam (expires,"expires", UInt32Parameter,"RFC 3261")
 defineParam (q,"q", QValueParameter,"RFC 3261")
 defineParam (tag,"tag", DataParameter,"RFC 3261")

Protected Attributes

bool mAllContacts
Uri mUri
Data mDisplayName
DatamUnknownUriParametersBuffer

Static Private Attributes

static ParameterTypes::Factory ParameterFactories [ParameterTypes::MAX_PARAMETER] = {0}

Detailed Description

Represents the "name-addr" and the "addr-spec" elements in the RFC 3261 grammar.

Definition at line 18 of file NameAddr.hxx.


Member Enumeration Documentation

anonymous enum
Enumerator:
commaHandling 

Definition at line 21 of file NameAddr.hxx.


Constructor & Destructor Documentation

NameAddr::NameAddr ( )

Definition at line 22 of file NameAddr.cxx.

Referenced by clone().

NameAddr::NameAddr ( const HeaderFieldValue hfv,
Headers::Type  type,
PoolBase pool = 0 
)

Definition at line 29 of file NameAddr.cxx.

NameAddr::NameAddr ( const Uri orig) [explicit]

Definition at line 66 of file NameAddr.cxx.

NameAddr::NameAddr ( const Data unparsed,
bool  preCacheAor = false 
) [explicit]

Definition at line 49 of file NameAddr.cxx.

References resip::Data::data(), resip::Uri::getAor(), mUri, resip::Data::size(), and resip::Headers::UNKNOWN.

   : ParserCategory(),
     mAllContacts(false),
     mDisplayName(),
     mUnknownUriParametersBuffer(0)
{
   HeaderFieldValue hfv(unparsed.data(), unparsed.size());
   // must copy because parse creates overlays
   NameAddr tmp(hfv, Headers::UNKNOWN);
   tmp.checkParsed();
   *this = tmp;
   if(preCacheAor)
   {
      mUri.getAor();
   }
}

Here is the call graph for this function:

NameAddr::NameAddr ( const NameAddr orig,
PoolBase pool = 0 
)

Definition at line 39 of file NameAddr.cxx.

   : ParserCategory(rhs, pool),
     mAllContacts(rhs.mAllContacts),
     mUri(rhs.mUri, pool),
     mDisplayName(rhs.mDisplayName),
     mUnknownUriParametersBuffer(0)
{}
NameAddr::~NameAddr ( ) [virtual]

Definition at line 74 of file NameAddr.cxx.

References mUnknownUriParametersBuffer.


Member Function Documentation

ParserCategory * NameAddr::clone ( ) const [virtual]

Implements resip::ParserCategory.

Definition at line 110 of file NameAddr.cxx.

References NameAddr().

{
   return new NameAddr(*this);
}

Here is the call graph for this function:

ParserCategory * NameAddr::clone ( void *  location) const [virtual]

Implements resip::ParserCategory.

Definition at line 116 of file NameAddr.cxx.

References NameAddr().

{
   return new (location) NameAddr(*this);
}

Here is the call graph for this function:

ParserCategory * NameAddr::clone ( PoolBase pool) const [virtual]

Implements resip::ParserCategory.

Definition at line 122 of file NameAddr.cxx.

References NameAddr().

{
   return new (pool) NameAddr(*this, pool);
}

Here is the call graph for this function:

Parameter * NameAddr::createParam ( ParameterTypes::Type  type,
ParseBuffer pb,
const std::bitset< 256 > &  terminators,
PoolBase pool 
) [virtual]
resip::NameAddr::defineParam ( data  ,
"data"  ,
ExistsParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( control  ,
"control"  ,
ExistsParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( mobility  ,
"mobility"  ,
QuotedDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( description  ,
"description"  ,
QuotedDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( events  ,
"events"  ,
QuotedDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( priority  ,
"priority"  ,
QuotedDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( methods  ,
"methods"  ,
QuotedDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( schemes  ,
"schemes"  ,
QuotedDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( application  ,
"application"  ,
ExistsParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( video  ,
"video"  ,
ExistsParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( language  ,
"language"  ,
QuotedDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( type  ,
"type"  ,
QuotedDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( isFocus  ,
"isfocus"  ,
ExistsParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( actor  ,
"actor"  ,
QuotedDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( text  ,
"text"  ,
ExistsOrDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( extensions  ,
"extensions"  ,
QuotedDataParameter  ,
"RFC 3840"   
)
resip::NameAddr::defineParam ( Instance  ,
"+sip.instance"  ,
QuotedDataParameter  ,
"RFC 5626"   
)
resip::NameAddr::defineParam ( regid  ,
"reg-id"  ,
UInt32Parameter  ,
"RFC 5626"   
)
resip::NameAddr::defineParam ( pubGruu  ,
"pub-gruu"  ,
QuotedDataParameter  ,
"RFC 5627"   
)
resip::NameAddr::defineParam ( tempGruu  ,
"temp-gruu"  ,
QuotedDataParameter  ,
"RFC 5627"   
)
resip::NameAddr::defineParam ( expires  ,
"expires"  ,
UInt32Parameter  ,
"RFC 3261"   
)
resip::NameAddr::defineParam ( ,
"q"  ,
QValueParameter  ,
"RFC 3261"   
)
resip::NameAddr::defineParam ( tag  ,
"tag"  ,
DataParameter  ,
"RFC 3261"   
)
Data & NameAddr::displayName ( )

Definition at line 142 of file NameAddr.cxx.

References resip::LazyParser::checkParsed(), and mDisplayName.

Referenced by main(), and operator==().

{
   checkParsed(); 
   return mDisplayName;
}

Here is the call graph for this function:

const Data & NameAddr::displayName ( ) const

Definition at line 149 of file NameAddr.cxx.

References resip::LazyParser::checkParsed(), and mDisplayName.

{
   checkParsed(); 
   return mDisplayName;
}

Here is the call graph for this function:

EncodeStream & NameAddr::encodeParsed ( EncodeStream str) const [virtual]

Implements resip::LazyParser.

Definition at line 274 of file NameAddr.cxx.

References resip::Symbols::DOUBLE_QUOTE, resip::Data::empty(), resip::ParserCategory::encodeParameters(), resip::Uri::encodeParsed(), resip::Symbols::LA_QUOTE, mAllContacts, mDisplayName, mUri, mustQuoteDisplayName(), resip::Symbols::RA_QUOTE, resip::Data::size(), and resip::Symbols::STAR.

{
   //bool displayName = !mDisplayName.empty();
  if (mAllContacts)
  {
     str << Symbols::STAR;
  }
  else
  {
     if (!mDisplayName.empty())
     {
#ifndef HANDLE_EMBEDDED_QUOTES_DNAME
        // .dlb. doesn't deal with embedded quotes
        str << Symbols::DOUBLE_QUOTE << mDisplayName << Symbols::DOUBLE_QUOTE;
#else
        // does nothing if display name is properly quoted
        if (mustQuoteDisplayName())
        {
           str << Symbols::DOUBLE_QUOTE;
           for (unsigned int i=0; i < mDisplayName.size(); i++)
           {
              char c = mDisplayName[i];
              switch(c)
              {
                 case '"':
                 case '\\':
                    str << '\\' << c;
                    break;
                 default:
                    str << c;
              }
           }
           str << Symbols::DOUBLE_QUOTE;
        }
        else
        {
           str << mDisplayName;           
        }
#endif
     }     
     str << Symbols::LA_QUOTE;
     mUri.encodeParsed(str);
     str << Symbols::RA_QUOTE;
  }
  
  encodeParameters(str);
  return str;
}

Here is the call graph for this function:

bool NameAddr::exists ( const Param< NameAddr > &  paramType) const

Definition at line 432 of file NameAddr.cxx.

References resip::LazyParser::checkParsed(), resip::ParserCategory::getParameterByEnum(), and resip::ParamBase::getTypeNum().

Referenced by main(), resip::TransactionState::process(), and resip::TransportSelector::transmit().

{
    checkParsed();
    bool ret = getParameterByEnum(paramType.getTypeNum()) != NULL;
    return ret;
}

Here is the call graph for this function:

bool NameAddr::isAllContacts ( ) const

Definition at line 156 of file NameAddr.cxx.

References resip::LazyParser::checkParsed(), and mAllContacts.

{
   checkParsed(); 
   return mAllContacts;
}

Here is the call graph for this function:

bool NameAddr::mustQuoteDisplayName ( ) const

Definition at line 325 of file NameAddr.cxx.

References resip::Data::data(), resip::Data::empty(), mDisplayName, resip::Data::size(), and resip::ParseBuffer::skipWhitespace().

Referenced by encodeParsed().

{
   if (mDisplayName.empty())
   {
      return false;
   }
   ParseBuffer pb(mDisplayName.data(), mDisplayName.size());   
   
   //shouldn't really be any leading whitespace
   pb.skipWhitespace();
   if (pb.eof())
   {
      return false;
   }
   if ((*pb.position() == '"'))
   {
      bool escaped = false;
      while(!pb.eof())
      {
         pb.skipChar();
         if (escaped)
         {
            escaped = false;
         }
         else if (*pb.position() == '\\')
         {
            escaped = true;
         }
         else if (*pb.position() == '"')
         {
            break;
         }
      }
      if (*pb.position() == '"')
      {
         //should only have whitespace left, and really non of that
         pb.skipChar();
         if (pb.eof())
         {
            return false;
         }
         pb.skipWhitespace();
         if (pb.eof())
         {
            return false; //properly quoted
         }
         else
         {
            return true; 
         }
      }
      else
      {
         return true; //imbalanced quotes
      }
   }
   else
   {
      while (!pb.eof())
      {
         const char* start;
         start = pb.skipWhitespace();
         pb.skipNonWhitespace();
                 const char* end = pb.position();
         for (const char* c = start; c < end; c++)
         {
            if ( (*c >= 'a' && *c <= 'z') ||
                 (*c >= 'A' && *c <= 'Z') ||
                 (*c >= '0' && *c <= '9'))
            {
               continue;
            }
            switch(*c)
            {
               case '-':
               case '.':
               case '!':
               case '%':
               case '*':
               case '_':
               case '+':
               case '`':
               case '\'':
               case '~':
                  break;
               default:
                  return true;
            }
         }
      }
   }
   return false;
}

Here is the call graph for this function:

bool NameAddr::operator< ( const NameAddr other) const

Definition at line 104 of file NameAddr.cxx.

References uri().

{
   return uri() < rhs.uri();
}

Here is the call graph for this function:

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

Definition at line 83 of file NameAddr.cxx.

References mAllContacts, mDisplayName, and mUri.

{
   if (this != &rhs)
   {
      assert( &rhs != 0 );
      
      ParserCategory::operator=(rhs);
      mAllContacts = rhs.mAllContacts;
      mDisplayName = rhs.mDisplayName;
      mUri = rhs.mUri;
   }
   return *this;
}
bool NameAddr::operator== ( const NameAddr other) const

Definition at line 98 of file NameAddr.cxx.

References displayName(), and uri().

{
    return uri() == other.uri() && displayName() == other.displayName();
}

Here is the call graph for this function:

void NameAddr::parse ( ParseBuffer pb) [virtual]

Implements resip::LazyParser.

Definition at line 169 of file NameAddr.cxx.

References resip::ParseBuffer::assertNotEof(), resip::ParserCategory::clearUnknownParameters(), resip::ParseBuffer::data(), resip::Symbols::DOUBLE_QUOTE, resip::ParseBuffer::eof(), resip::Symbols::LA_QUOTE, mAllContacts, mDisplayName, resip::ParserCategory::mUnknownParameters, mUnknownUriParametersBuffer, mUri, resip::Uri::parse(), resip::ParserCategory::parseParameters(), resip::ParseBuffer::position(), resip::Symbols::RA_QUOTE, resip::ParseBuffer::reset(), resip::Symbols::SEMI_COLON, resip::ParseBuffer::skipBackWhitespace(), resip::ParseBuffer::skipChar(), resip::ParseBuffer::skipToChar(), resip::ParseBuffer::skipToEndQuote(), resip::ParseBuffer::skipWhitespace(), and resip::Symbols::STAR.

Referenced by main().

{
   const char* start;
   start = pb.skipWhitespace();
   pb.assertNotEof();
   bool laQuote = false;
   bool starContact = false;
   
   if (*pb.position() == Symbols::STAR[0])
   {
      pb.skipChar(Symbols::STAR[0]);
      pb.skipWhitespace();
      if (pb.eof() || *pb.position() == Symbols::SEMI_COLON[0])
      {
         starContact = true;
      }
   }

   if (starContact)
   {
      mAllContacts = true;
      // now fall through to parse header parameters
   }
   else
   {
      pb.reset(start);
      if (*pb.position() == Symbols::DOUBLE_QUOTE[0])
      {
         start = pb.skipChar(Symbols::DOUBLE_QUOTE[0]);
         pb.skipToEndQuote();
         pb.data(mDisplayName, start);
         pb.skipChar(Symbols::DOUBLE_QUOTE[0]);
         laQuote = true;
         pb.skipToChar(Symbols::LA_QUOTE[0]);
         if (pb.eof())
         {
            throw ParseException("Expected '<'", 
                                 "NameAddr", 
                                 __FILE__, 
                                 __LINE__);
         }
         else
         {
            pb.skipChar(Symbols::LA_QUOTE[0]);
         }
      }
      else if (*pb.position() == Symbols::LA_QUOTE[0])
      {
         pb.skipChar(Symbols::LA_QUOTE[0]);
         laQuote = true;
      }
      else
      {
         start = pb.position();
         pb.skipToChar(Symbols::LA_QUOTE[0]);
         if (pb.eof())
         {
            pb.reset(start);
         }
         else
         {
            laQuote = true;
            pb.skipBackWhitespace();
            pb.data(mDisplayName, start);
            pb.skipToChar(Symbols::LA_QUOTE[0]);
            pb.skipChar(Symbols::LA_QUOTE[0]);
         }
      }
      pb.skipWhitespace();
      mUri.parse(pb);
      if (laQuote)
      {
         pb.skipChar(Symbols::RA_QUOTE[0]);
         pb.skipWhitespace();
         // now fall through to parse header parameters
      }
      else
      {
         if(mUri.mUnknownParameters.size() > 0)
         {
            assert(!mUnknownUriParametersBuffer);
            mUnknownUriParametersBuffer = new Data;
            {  // Scope stream
               oDataStream str(*mUnknownUriParametersBuffer);
               // deal with Uri/NameAddr parameter ambiguity
               // heuristically assign Uri parameters to the Uri
               for (ParameterList::iterator it = mUri.mUnknownParameters.begin(); 
                  it != mUri.mUnknownParameters.end(); ++it)
               {
                  // We're just going to assume all unknown (to Uri) params really
                  // belong on the header. This is not necessarily the case.
                  str << ";";
                  (*it)->encode(str);
               }
            }
            mUri.clearUnknownParameters();
            ParseBuffer pb2(*mUnknownUriParametersBuffer);
            parseParameters(pb2);
         }
      }
   }
   parseParameters(pb);
}

Here is the call graph for this function:

void NameAddr::remove ( const Param< NameAddr > &  paramType)

Definition at line 440 of file NameAddr.cxx.

References resip::LazyParser::checkParsed(), resip::ParamBase::getTypeNum(), and resip::ParserCategory::removeParameterByEnum().

Here is the call graph for this function:

void NameAddr::setAllContacts ( )

Definition at line 163 of file NameAddr.cxx.

References mAllContacts.

{
   mAllContacts = true;
}
Uri & NameAddr::uri ( )
const Uri & NameAddr::uri ( ) const

Definition at line 128 of file NameAddr.cxx.

References resip::LazyParser::checkParsed(), and mUri.

{
   checkParsed(); 
   return mUri;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 96 of file NameAddr.hxx.

Referenced by encodeParsed(), isAllContacts(), operator=(), parse(), and setAllContacts().

Definition at line 98 of file NameAddr.hxx.

Referenced by displayName(), encodeParsed(), mustQuoteDisplayName(), operator=(), and parse().

Definition at line 99 of file NameAddr.hxx.

Referenced by parse(), and ~NameAddr().

Definition at line 97 of file NameAddr.hxx.

Referenced by encodeParsed(), NameAddr(), operator=(), parse(), and uri().

Definition at line 103 of file NameAddr.hxx.

Referenced by createParam().


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