reSIProcate/stack  9694
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
resip::Contents Class Reference

Base class for all SIP body types. More...

#include <Contents.hxx>

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

List of all members.

Public Member Functions

 Contents (const HeaderFieldValue &headerFieldValue, const Mime &contentsType)
 pass Mime instance for parameters
 Contents (const Mime &contentsType)
 Create a contents with a given mime type.
 Contents (const Contents &rhs)
 Copy constructor.
 Contents (const Contents &rhs, HeaderFieldValue::CopyPaddingEnum e)
 Contents (const HeaderFieldValue &headerFieldValue, HeaderFieldValue::CopyPaddingEnum e, const Mime &contentsType)
virtual ~Contents ()
Contentsoperator= (const Contents &rhs)
 Assignment operator.
void preParseHeaders (ParseBuffer &pb)
 Preforms preparsing on the headers stored in the ParseBuffer pb.
EncodeStreamencodeHeaders (EncodeStream &str) const
 encodes headers to an output stream
virtual ContentsgetContents ()
 access to wrapped contents (signed, encrypted)
ContentsgetContents (const Mime &)
virtual Data getBodyData () const
virtual Contentsclone () const =0
 returns a copy of a Contents object
const MimegetType () const
 getter for mime type of message
bool exists (const HeaderBase &headerType) const
 checks to see if a header is present
void remove (const HeaderBase &headerType)
 removes a header if it is present
bool exists (const MIME_Header &headerType) const
 checks to see if a MIME header exists
void remove (const MIME_Header &headerType)
 removes a MIME header if it is present
const H_ContentType::Type & header (const H_ContentType &headerType) const
 returns the value of the Content-Type header Throws an Contents::Exception if the header doesn't exist.
H_ContentType::Type & header (const H_ContentType &headerType)
 returns the value of the Content-Type header
const H_ContentDisposition::Type & header (const H_ContentDisposition &headerType) const
 returns the value of the Content-Disposition header Throws an Contents::Exception if the header doesn't exist.
H_ContentDisposition::Type & header (const H_ContentDisposition &headerType)
 returns the value of the Content-Disposition header
const
H_ContentTransferEncoding::Type & 
header (const H_ContentTransferEncoding &headerType) const
 returns the value of the Content-Transfer-Encoding header Throws an Contents::Exception if the header doesn't exist.
H_ContentTransferEncoding::Type & header (const H_ContentTransferEncoding &headerType)
 returns the value of the Content-Transfer-Encoding header
const H_ContentLanguages::Type & header (const H_ContentLanguages &headerType) const
 returns the value of the Content-Languages header Throws an Contents::Exception if the header doesn't exist.
H_ContentLanguages::Type & header (const H_ContentLanguages &headerType)
 returns the value of the Content-Languages header
const H_ContentID::Typeheader (const H_ContentID &headerType) const
 returns the value of the Content-ID MIME header Throws an Contents::Exception if the header doesn't exist.
H_ContentID::Typeheader (const H_ContentID &headerType)
 returns the value of the Content-ID MIME header
const H_ContentDescription::Typeheader (const H_ContentDescription &headerType) const
 returns the Content-Description MIME header Throws an Contents::Exception if the header doesn't exist.
H_ContentDescription::Typeheader (const H_ContentDescription &headerType)
 returns the Content-Description MIME header
int & version ()
 returns the major version of MIME used by the contents
int & minorVersion ()
 returns the minor version of MIME used by the contents
void addBuffer (char *buf)

Static Public Member Functions

static ContentscreateContents (const Mime &contentType, const Data &contents)
 factory method to create a Contents object from a mime type and a payload

Protected Member Functions

void clear ()
void init ()
void init (const Contents &orig)
void freeMem ()
virtual const DataerrorContext () const

Protected Attributes

Mime mType
H_ContentDisposition::Type * mDisposition
H_ContentTransferEncoding::Type * mTransferEncoding
H_ContentLanguages::Type * mLanguages
TokenmId
H_ContentDescription::TypemDescription
StringCategorymLength
int mVersion
int mMinorVersion
std::vector< char * > mBufferList

Detailed Description

Base class for all SIP body types.

Lazily-parsed.

Definition at line 50 of file Contents.hxx.


Constructor & Destructor Documentation

Contents::Contents ( const HeaderFieldValue headerFieldValue,
const Mime contentsType 
)

pass Mime instance for parameters

Definition at line 21 of file Contents.cxx.

References init().

   : LazyParser(headerFieldValue),
      mType(contentType)
{
   init();
}

Here is the call graph for this function:

Contents::Contents ( const Mime contentsType)

Create a contents with a given mime type.

Parameters:
contentsTypethe mime type of the contents

Definition at line 29 of file Contents.cxx.

References init().

   : mType(contentType)
{
   init();
}

Here is the call graph for this function:

Contents::Contents ( const Contents rhs)

Copy constructor.

Parameters:
rhsthe Contents to be copied

Definition at line 35 of file Contents.cxx.

References init().

    : LazyParser(rhs)
{
   init(rhs);
}

Here is the call graph for this function:

Contents::Contents ( const Contents rhs,
HeaderFieldValue::CopyPaddingEnum  e 
)
Todo:
internal documentation

Definition at line 41 of file Contents.cxx.

References init().

    : LazyParser(rhs,e)
{
   init(rhs);
}

Here is the call graph for this function:

Contents::Contents ( const HeaderFieldValue headerFieldValue,
HeaderFieldValue::CopyPaddingEnum  e,
const Mime contentsType 
)
Todo:
internal documentation

Definition at line 47 of file Contents.cxx.

References init().

    : LazyParser(headerFieldValue,e),
    mType(contentsType)
{
   init();
}

Here is the call graph for this function:

Contents::~Contents ( ) [virtual]

Definition at line 57 of file Contents.cxx.

References freeMem().

{
   freeMem();
}

Here is the call graph for this function:


Member Function Documentation

void Contents::addBuffer ( char *  buf)
Todo:
  • is this being used? -- is the buffer list being used as a list?

Definition at line 660 of file Contents.cxx.

References mBufferList.

{
   mBufferList.push_back(buf);
}
void resip::Contents::clear ( void  ) [inline, protected]
Todo:
!bwc! Calls freeMem(), then reverts members to a default state (including setting pointers to 0)

Reimplemented from resip::LazyParser.

Reimplemented in resip::MessageWaitingContents, and resip::MultipartMixedContents.

Definition at line 294 of file Contents.hxx.

References freeMem(), and init().

      {
         freeMem();
         init();
      }

Here is the call graph for this function:

virtual Contents* resip::Contents::clone ( ) const [pure virtual]
Contents * Contents::createContents ( const Mime contentType,
const Data contents 
) [static]

factory method to create a Contents object from a mime type and a payload

Parameters:
contentTypethe mime type of the contents
contentsthe contents
Returns:
a instance of a Contents subclass appropriate to the mime type
Note:
If no registered Contents subclass has been registered with the factory an instance of OctetContents is returned.
See also:
ContentsFactory
ContentsFactoryBase

Definition at line 147 of file Contents.cxx.

References resip::Data::data(), resip::ContentsFactoryBase::getFactoryMap(), and resip::Data::size().

Referenced by resip::MultipartMixedContents::parse().

{
  // !ass! why are we asserting that the Data doesn't own the buffer?
  // .dlb. because this method is to be called only within a multipart
  // !ass! HFV is an overlay -- then setting c->mIsMine to true ?? dlb Q
  // .dlb. we are telling the content that it owns its HFV, not the data that it
  // .dlb. owns its memory
  // .bwc. So, we are _violating_ _encapsulation_, to make an assertion that the 
  // Data is an intermediate instead of owning the buffer itself? What do we 
  // care how this buffer is owned? All we require is that the buffer doesn't 
  // get dealloced/modified while we're still around. The assertion might mean 
  // that the Data will not do either of these things, but it affords no 
  // protection from the actual owner doing so. We are no more protected with 
  // the assertion, so I am removing it.
//   assert(!contents.mMine);

   HeaderFieldValue hfv(contents.data(), (unsigned int)contents.size());

// !bwc! This padding stuff is now the responsibility of the Contents class.
//   if(contentType.subType()=="sipfrag"||contentType.subType()=="external-body")
//   {
//      // .bwc. The parser for sipfrag requires padding at the end of the hfv.
//      HeaderFieldValue* temp = hfv;
//      hfv = new HeaderFieldValue(*temp,HeaderFieldValue::CopyPadding);
//      delete temp;
//   }
   
   Contents* c;
   if (ContentsFactoryBase::getFactoryMap().find(contentType) != ContentsFactoryBase::getFactoryMap().end())
   {
      c = ContentsFactoryBase::getFactoryMap()[contentType]->create(hfv, contentType);
   }
   else
   {
      c = new OctetContents(hfv, contentType);
   }
   return c;
}

Here is the call graph for this function:

EncodeStream & Contents::encodeHeaders ( EncodeStream str) const

encodes headers to an output stream

Parameters:
stroutput stream destination for encoded headers
Returns:
a reference to str

Definition at line 580 of file Contents.cxx.

References resip::Symbols::COLON, resip::Symbols::COMMA, CRLF, exists(), header(), mDescription, mId, mLength, mMinorVersion, mTransferEncoding, mType, mVersion, resip::Symbols::PERIOD, and resip::Symbols::SPACE.

{
   if (mVersion != 1 || mMinorVersion != 0)
   {
      str << "MIME-Version" << Symbols::COLON[0] << Symbols::SPACE[0]
          << mVersion << Symbols::PERIOD[0] << mMinorVersion 
          << Symbols::CRLF;
   }

   str << "Content-Type" << Symbols::COLON[0] << Symbols::SPACE[0]
       << mType 
       << Symbols::CRLF;

   if (exists(h_ContentDisposition))
   {
      str <<  "Content-Disposition" << Symbols::COLON[0] << Symbols::SPACE[0];

      header(h_ContentDisposition).encode(str);
      str << Symbols::CRLF;
   }

   if (exists(h_ContentLanguages))
   {
      str <<  "Content-Languages" << Symbols::COLON[0] << Symbols::SPACE[0];

      size_t count = 0;
      size_t size = header(h_ContentLanguages).size();

      for (H_ContentLanguages::Type::const_iterator 
              i = header(h_ContentLanguages).begin();
           i != header(h_ContentLanguages).end(); ++i)
      {
         i->encode(str);

         if (++count < size)
             str << Symbols::COMMA << Symbols::SPACE;
      }
      str << Symbols::CRLF;
   }

   if (mTransferEncoding)
   {
      str << "Content-Transfer-Encoding" << Symbols::COLON[0] << Symbols::SPACE[0]
          << *mTransferEncoding
          << Symbols::CRLF;
   }

   if (mId)
   {
      str << "Content-Id" << Symbols::COLON[0] << Symbols::SPACE[0]
          << *mId
          << Symbols::CRLF;
   }

   if (mDescription)
   {
      str << "Content-Description" << Symbols::COLON[0] << Symbols::SPACE[0]
          << *mDescription
          << Symbols::CRLF;
   }

   if (mLength)
   {
      str << "Content-Length" << Symbols::COLON[0] << Symbols::SPACE[0]
          <<  *mLength 
          << Symbols::CRLF;
   }
   
   str << Symbols::CRLF;
   return str;
}

Here is the call graph for this function:

const Data & Contents::errorContext ( ) const [protected, virtual]

Implements resip::LazyParser.

Definition at line 64 of file Contents.cxx.

References errorContextData.

{
   return errorContextData;
}
bool Contents::exists ( const HeaderBase headerType) const

checks to see if a header is present

Parameters:
headerTypethe header to check for
Returns:
true if that header exists and false otherwise

Definition at line 188 of file Contents.cxx.

References resip::LazyParser::checkParsed(), resip::HeaderBase::getTypeNum(), mDisposition, mLanguages, and mTransferEncoding.

Referenced by encodeHeaders().

{
   checkParsed();
   switch (headerType.getTypeNum())
   {
      case Headers::ContentType :
      {
         return true;
      }
      case Headers::ContentDisposition :
      {
         return mDisposition != 0;
      }
      case Headers::ContentTransferEncoding :
      {
         return mTransferEncoding != 0;
      }
      case Headers::ContentLanguage :
      {
         return mLanguages != 0;
      }
      default : return false;
   }
}

Here is the call graph for this function:

bool Contents::exists ( const MIME_Header headerType) const

checks to see if a MIME header exists

Parameters:
headerTypethe MIME header to check for
Returns:
true if the header exists and false otherwise

Definition at line 214 of file Contents.cxx.

References mDescription, and mId.

{
   if (&type == &h_ContentID)
   {
      return mId != 0;
   }
   
   if (&type == &h_ContentDescription)
   {
      return mDescription != 0;
   }

   assert(false);
   return false;
}
void resip::Contents::freeMem ( ) [inline, protected]

Definition at line 322 of file Contents.hxx.

References mBufferList, mDescription, mDisposition, mId, mLanguages, mLength, and mTransferEncoding.

Referenced by clear(), operator=(), and ~Contents().

      {
         delete mDisposition;
         delete mTransferEncoding;
         delete mLanguages;
         delete mId;
         delete mDescription;
         delete mLength;

         for (std::vector<char*>::iterator i = mBufferList.begin();
              i != mBufferList.end(); i++)
         {
            delete [] *i;
         }

      }
Data Contents::getBodyData ( ) const [virtual]

Definition at line 653 of file Contents.cxx.

References resip::LazyParser::checkParsed(), and resip::Data::from().

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

{
   checkParsed();
   return Data::from(*this);
}

Here is the call graph for this function:

virtual Contents* resip::Contents::getContents ( ) [inline, virtual]

access to wrapped contents (signed, encrypted)

Returns:
a pointer to self

Definition at line 100 of file Contents.hxx.

Referenced by main(), and test7().

{return this;}
Contents* resip::Contents::getContents ( const Mime )
Todo:
  • unimplemented - decide fate
const Mime& resip::Contents::getType ( ) const [inline]

getter for mime type of message

Returns:
the mime type of the message

Definition at line 118 of file Contents.hxx.

References mType.

Referenced by findRlmi(), preParseHeaders(), resip::TuIM::processMessageRequest(), resip::TuIM::processNotifyRequest(), resip::TuIM::processSipFrag(), and test7().

{return mType;}
const H_ContentType::Type & Contents::header ( const H_ContentType &  headerType) const

returns the value of the Content-Type header Throws an Contents::Exception if the header doesn't exist.

                retval = contents.header(Headers::ContentType);
Returns:
the Content-Type header value

Definition at line 279 of file Contents.cxx.

References mType.

Referenced by encodeHeaders(), resip::SipMessage::getContents(), main(), preParseHeaders(), resip::TuIM::sendPage(), and setContentsHeaders().

{
   return mType;
}
H_ContentType::Type & Contents::header ( const H_ContentType &  headerType)

returns the value of the Content-Type header

                retval = contents.header(Headers::ContentType);
Returns:
the Content-Type header value

Definition at line 285 of file Contents.cxx.

References mType.

{
   return mType;
}
const H_ContentDisposition::Type & Contents::header ( const H_ContentDisposition &  headerType) const

returns the value of the Content-Disposition header Throws an Contents::Exception if the header doesn't exist.

        retval = contents.header(Headers::ContentDisposition);
Returns:
the Content-Disposition header value

Definition at line 291 of file Contents.cxx.

References resip::LazyParser::checkParsed(), ErrLog, and mDisposition.

{
   checkParsed();
   if (mDisposition == 0)
   {
      ErrLog(<< "You called "
            "Contents::header(const H_ContentDisposition& headerType) _const_ "
            "without first calling exists(), and the header does not exist. Our"
            " behavior in this scenario is to implicitly create the header(using const_cast!); "
            "this is probably not what you want, but it is either this or "
            "assert/throw an exception. Since this has been the behavior for "
            "so long, we are not throwing here, _yet_. You need to fix your "
            "code, before we _do_ start throwing. This is why const-correctness"
            " should never be made a TODO item </rant>");
      Contents* ncthis = const_cast<Contents*>(this);
      ncthis->mDisposition = new H_ContentDisposition::Type;
   }
   return *mDisposition;
}

Here is the call graph for this function:

H_ContentDisposition::Type & Contents::header ( const H_ContentDisposition &  headerType)

returns the value of the Content-Disposition header

        retval = contents.header(Headers::ContentDisposition);
Returns:
the Content-Disposition header value

Definition at line 312 of file Contents.cxx.

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

{
   checkParsed();
   if (mDisposition == 0)
   {
      mDisposition = new H_ContentDisposition::Type;
   }
   return *mDisposition;
}

Here is the call graph for this function:

const H_ContentTransferEncoding::Type & Contents::header ( const H_ContentTransferEncoding &  headerType) const

returns the value of the Content-Transfer-Encoding header Throws an Contents::Exception if the header doesn't exist.

        retval = contents.header(Headers::ContentTransferEncoding);
Returns:
the Content-Transfer-Encoding header value

Definition at line 323 of file Contents.cxx.

References resip::LazyParser::checkParsed(), ErrLog, and mTransferEncoding.

{
   checkParsed();
   if (mTransferEncoding == 0)
   {
      ErrLog(<< "You called "
            "Contents::header(const H_ContentTransferEncoding& headerType) _const_ "
            "without first calling exists(), and the header does not exist. Our"
            " behavior in this scenario is to implicitly create the header(using const_cast!); "
            "this is probably not what you want, but it is either this or "
            "assert/throw an exception. Since this has been the behavior for "
            "so long, we are not throwing here, _yet_. You need to fix your "
            "code, before we _do_ start throwing. This is why const-correctness"
            " should never be made a TODO item </rant>");
      Contents* ncthis = const_cast<Contents*>(this);
      ncthis->mTransferEncoding = new H_ContentTransferEncoding::Type;
   }
   return *mTransferEncoding;
}

Here is the call graph for this function:

H_ContentTransferEncoding::Type & Contents::header ( const H_ContentTransferEncoding &  headerType)

returns the value of the Content-Transfer-Encoding header

        retval = contents.header(Headers::ContentTransferEncoding);
Returns:
the Content-Transfer-Encoding header value

Definition at line 344 of file Contents.cxx.

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

{
   checkParsed();
   if (mTransferEncoding == 0)
   {
      mTransferEncoding = new H_ContentTransferEncoding::Type;
   }
   return *mTransferEncoding;
}

Here is the call graph for this function:

const H_ContentLanguages::Type & Contents::header ( const H_ContentLanguages &  headerType) const

returns the value of the Content-Languages header Throws an Contents::Exception if the header doesn't exist.

        retval = contents.header(Headers::ContentLanguages);
Returns:
the Content-Languages header value

Definition at line 355 of file Contents.cxx.

References resip::LazyParser::checkParsed(), ErrLog, and mLanguages.

{
   checkParsed();
   if (mLanguages == 0)
   {
      ErrLog(<< "You called "
            "Contents::header(const H_ContentLanguages& headerType) _const_ "
            "without first calling exists(), and the header does not exist. Our"
            " behavior in this scenario is to implicitly create the header(using const_cast!); "
            "this is probably not what you want, but it is either this or "
            "assert/throw an exception. Since this has been the behavior for "
            "so long, we are not throwing here, _yet_. You need to fix your "
            "code, before we _do_ start throwing. This is why const-correctness"
            " should never be made a TODO item </rant>");
      Contents* ncthis = const_cast<Contents*>(this);
      ncthis->mLanguages = new H_ContentLanguages::Type;
   }
   return *mLanguages;
}

Here is the call graph for this function:

H_ContentLanguages::Type & Contents::header ( const H_ContentLanguages &  headerType)

returns the value of the Content-Languages header

        retval = contents.header(Headers::ContentLanguages);
Returns:
the Content-Languages header value

Definition at line 376 of file Contents.cxx.

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

{
   checkParsed();
   if (mLanguages == 0)
   {
      mLanguages = new H_ContentLanguages::Type;
   }
   return *mLanguages;
}

Here is the call graph for this function:

const H_ContentID::Type & Contents::header ( const H_ContentID headerType) const

returns the value of the Content-ID MIME header Throws an Contents::Exception if the header doesn't exist.

        retval = contents.header(Headers::ContentId);
Returns:
the Content-Id MIME header value

Definition at line 419 of file Contents.cxx.

References resip::LazyParser::checkParsed(), ErrLog, and mId.

{
   checkParsed();
   if (mId == 0)
   {
      ErrLog(<< "You called "
            "Contents::header(const H_ContentID& headerType) _const_ "
            "without first calling exists(), and the header does not exist. Our"
            " behavior in this scenario is to implicitly create the header(using const_cast!); "
            "this is probably not what you want, but it is either this or "
            "assert/throw an exception. Since this has been the behavior for "
            "so long, we are not throwing here, _yet_. You need to fix your "
            "code, before we _do_ start throwing. This is why const-correctness"
            " should never be made a TODO item </rant>");
      Contents* ncthis = const_cast<Contents*>(this);
      ncthis->mId = new H_ContentID::Type;
   }
   return *mId;
}

Here is the call graph for this function:

H_ContentID::Type & Contents::header ( const H_ContentID headerType)

returns the value of the Content-ID MIME header

        retval = contents.header(Headers::ContentId);
Returns:
the Content-Id MIME header value

Definition at line 440 of file Contents.cxx.

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

{
   checkParsed();
   if (mId == 0)
   {
      mId = new H_ContentID::Type;
   }
   return *mId;
}

Here is the call graph for this function:

const H_ContentDescription::Type & Contents::header ( const H_ContentDescription headerType) const

returns the Content-Description MIME header Throws an Contents::Exception if the header doesn't exist.

        retval = contents.header(Headers::ContentDescription)
Returns:
the Content-Description MIME header

Definition at line 387 of file Contents.cxx.

References resip::LazyParser::checkParsed(), ErrLog, and mDescription.

{
   checkParsed();
   if (mDescription == 0)
   {
      ErrLog(<< "You called "
            "Contents::header(const H_ContentDescription& headerType) _const_ "
            "without first calling exists(), and the header does not exist. Our"
            " behavior in this scenario is to implicitly create the header(using const_cast!); "
            "this is probably not what you want, but it is either this or "
            "assert/throw an exception. Since this has been the behavior for "
            "so long, we are not throwing here, _yet_. You need to fix your "
            "code, before we _do_ start throwing. This is why const-correctness"
            " should never be made a TODO item </rant>");
      Contents* ncthis = const_cast<Contents*>(this);
      ncthis->mDescription = new H_ContentDescription::Type;
   }
   return *mDescription;
}

Here is the call graph for this function:

H_ContentDescription::Type & Contents::header ( const H_ContentDescription headerType)

returns the Content-Description MIME header

        retval = contents.header(Headers::ContentDescription)
Returns:
the Content-Description MIME header

Definition at line 408 of file Contents.cxx.

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

Here is the call graph for this function:

void resip::Contents::init ( ) [inline, protected]
void Contents::init ( const Contents orig) [protected]

Definition at line 83 of file Contents.cxx.

References mBufferList, mDescription, mDisposition, mId, mLanguages, mLength, mMinorVersion, mTransferEncoding, mType, and mVersion.

{
   mBufferList.clear();
   mType = orig.mType;
   if (orig.mDisposition)
   {
       mDisposition = new H_ContentDisposition::Type(*orig.mDisposition);
   }
   else
   {
      mDisposition = 0;
   }
   
   if (orig.mTransferEncoding)
   {
       mTransferEncoding = new H_ContentTransferEncoding::Type(*orig.mTransferEncoding);
   }
   else
   {
      mTransferEncoding = 0;
   }
   
   if (orig.mLanguages)
   {
       mLanguages = new H_ContentLanguages::Type(*orig.mLanguages);
   }
   else
   {
      mLanguages = 0;
   }
   
   if (orig.mId)
   {
       mId = new Token(*orig.mId);
   }
   else
   {
      mId = 0;
   }
   
   if (orig.mDescription)
   {
       mDescription = new StringCategory(*orig.mDescription);
   }
   else
   {
      mDescription = 0;
   }
   
   if(orig.mLength)
   {
      mLength = new StringCategory(*orig.mLength);
   }
   else
   {
      mLength = 0;
   }

   mVersion = orig.mVersion;
   mMinorVersion = orig.mMinorVersion;

}
int& resip::Contents::minorVersion ( ) [inline]

returns the minor version of MIME used by the contents

Returns:
MIME minor version

Definition at line 280 of file Contents.hxx.

References mMinorVersion.

{return mMinorVersion;}
Contents & Contents::operator= ( const Contents rhs)

Assignment operator.

Parameters:
rhsContents object to be copied
Returns:
a reference to a copy of rhs

Definition at line 70 of file Contents.cxx.

References freeMem(), and init().

{
   if (this != &rhs)
   {
      freeMem();
      LazyParser::operator=(rhs);
      init(rhs);
   }

   return *this;
}

Here is the call graph for this function:

void Contents::preParseHeaders ( ParseBuffer pb)

Preforms preparsing on the headers stored in the ParseBuffer pb.

Parameters:
pba ParseBuffer containing the headers to preparse

Definition at line 452 of file Contents.cxx.

References resip::Symbols::COLON, resip::Symbols::COMMA, resip::ParseBuffer::data(), resip::ParseBuffer::end(), resip::ParseBuffer::eof(), ErrLog, getType(), header(), resip::isEqualNoCase(), resip::Symbols::LPAREN, mDescription, mDisposition, mId, mLanguages, mLength, mMinorVersion, mTransferEncoding, mVersion, resip::StringCategory::parse(), resip::Token::parse(), resip::Symbols::PERIOD, resip::ParseBuffer::position(), resip::Symbols::RPAREN, resip::ParseBuffer::skipChar(), resip::ParseBuffer::skipToOneOf(), resip::ParseBuffer::skipToTermCRLF(), resip::ParseBuffer::skipWhitespace(), type, and resip::ParseBuffer::Whitespace.

{
   const char* start = pb.position();
   Data all( start, pb.end()-start);

   Data headerName;

   try
   {
      
   while (!pb.eof())
   {
      const char* anchor = pb.skipWhitespace();
      pb.skipToOneOf(Symbols::COLON, ParseBuffer::Whitespace);
      pb.data(headerName, anchor);

      pb.skipWhitespace();
      pb.skipChar(Symbols::COLON[0]);
      anchor = pb.skipWhitespace();
      pb.skipToTermCRLF();

      Headers::Type type = Headers::getType(headerName.data(), (int)headerName.size());
      ParseBuffer subPb(anchor, pb.position() - anchor);

      switch (type)
      {
         case Headers::ContentType :
         {
            // already set
            break;
         }
         case Headers::ContentDisposition :
         {
            mDisposition = new H_ContentDisposition::Type;
            mDisposition->parse(subPb);
            break;
         }
         case Headers::ContentTransferEncoding :
         {
            mTransferEncoding = new H_ContentTransferEncoding::Type;
            mTransferEncoding->parse(subPb);
            break;
         }
         // !dlb! not sure this ever happens?
         case Headers::ContentLanguage :
         {
            if (mLanguages == 0)
            {
               mLanguages = new H_ContentLanguages::Type;
            }

            subPb.skipWhitespace();
            while (!subPb.eof() && *subPb.position() != Symbols::COMMA[0])
            {
               H_ContentLanguages::Type::value_type tmp;
               header(h_ContentLanguages).push_back(tmp);
               header(h_ContentLanguages).back().parse(subPb);
               subPb.skipLWS();
            }
            break;      // .kw. added -- this is needed, right?
         }
         default :
         {
            if (isEqualNoCase(headerName, "Content-Transfer-Encoding"))
            {
               mTransferEncoding = new StringCategory();
               mTransferEncoding->parse(subPb);
            }
            else if (isEqualNoCase(headerName, "Content-Description"))
            {
               mDescription = new StringCategory();
               mDescription->parse(subPb);
            }
            else if (isEqualNoCase(headerName, "Content-Id"))
            {
               mId = new Token();
               mId->parse(subPb);
            }
            // Some people put this in ...
            else if (isEqualNoCase(headerName, "Content-Length"))
            {
               mLength = new StringCategory();
               mLength->parse(subPb);
            }
            else if (isEqualNoCase(headerName, "MIME-Version"))
            {
               subPb.skipWhitespace();
               if (!subPb.eof() && *subPb.position() == Symbols::LPAREN[0])
               {
                  subPb.skipToEndQuote(Symbols::RPAREN[0]);
                  subPb.skipChar(Symbols::RPAREN[0]);
               }
               mVersion = subPb.integer();

               if (!subPb.eof() && *subPb.position() == Symbols::LPAREN[0])
               {
                  subPb.skipToEndQuote(Symbols::RPAREN[0]);
                  subPb.skipChar(Symbols::RPAREN[0]);
               }
               subPb.skipChar(Symbols::PERIOD[0]);
               
               if (!subPb.eof() && *subPb.position() == Symbols::LPAREN[0])
               {
                  subPb.skipToEndQuote(Symbols::RPAREN[0]);
                  subPb.skipChar(Symbols::RPAREN[0]);
               }
               
               mMinorVersion = subPb.integer();
            }
            else
            {
               // add to application headers someday
               std::cerr << "Unknown MIME Content- header: " << headerName << std::endl;
               ErrLog(<< "Unknown MIME Content- header: " << headerName);
               assert(false);
            }
         }
      }
   }
   }
   catch (ParseException &  e )
   {
      ErrLog( << "Some problem parsing contents: " << e );
      throw e;
   }
}

Here is the call graph for this function:

void Contents::remove ( const HeaderBase headerType)

removes a header if it is present

Parameters:
headerTypethe header to remove

Definition at line 231 of file Contents.cxx.

References resip::HeaderBase::getTypeNum(), mDisposition, mLanguages, and mTransferEncoding.

{
   switch (headerType.getTypeNum())
   {
      case Headers::ContentDisposition :
      {
         delete mDisposition;
         mDisposition = 0;
         break;
      }
      case Headers::ContentLanguage :
      {
         delete mLanguages;
         mLanguages = 0;
         break;
      }
      case Headers::ContentTransferEncoding :
      {
         delete mTransferEncoding;
         mTransferEncoding = 0;
         break;
      }
      default :
         ;
   }
}

Here is the call graph for this function:

void Contents::remove ( const MIME_Header headerType)

removes a MIME header if it is present

Parameters:
headerTypethe MIME header to remove

Definition at line 259 of file Contents.cxx.

References mDescription, and mId.

{
   if (&type == &h_ContentID)
   {
      delete mId;
      mId = 0;
      return;
   }
    
   if (&type == &h_ContentDescription)
   {
      delete mDescription;
      mDescription = 0;
      return;
   }

   assert(false);
}
int& resip::Contents::version ( ) [inline]

returns the major version of MIME used by the contents

Returns:
MIME major version

Definition at line 275 of file Contents.hxx.

References mVersion.

{return mVersion;}

Member Data Documentation

std::vector<char*> resip::Contents::mBufferList [protected]

Definition at line 361 of file Contents.hxx.

Referenced by addBuffer(), freeMem(), and init().

Definition at line 352 of file Contents.hxx.

Referenced by encodeHeaders(), exists(), freeMem(), header(), init(), preParseHeaders(), and remove().

H_ContentDisposition::Type* resip::Contents::mDisposition [protected]

Definition at line 344 of file Contents.hxx.

Referenced by exists(), freeMem(), header(), init(), preParseHeaders(), and remove().

Definition at line 350 of file Contents.hxx.

Referenced by encodeHeaders(), exists(), freeMem(), header(), init(), preParseHeaders(), and remove().

H_ContentLanguages::Type* resip::Contents::mLanguages [protected]

Definition at line 348 of file Contents.hxx.

Referenced by exists(), freeMem(), header(), init(), preParseHeaders(), and remove().

Definition at line 354 of file Contents.hxx.

Referenced by encodeHeaders(), freeMem(), init(), and preParseHeaders().

Definition at line 359 of file Contents.hxx.

Referenced by encodeHeaders(), init(), minorVersion(), and preParseHeaders().

H_ContentTransferEncoding::Type* resip::Contents::mTransferEncoding [protected]
int resip::Contents::mVersion [protected]

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