Yate
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MimeBody Class Referenceabstract

Abstract MIME data holder. More...

#include <yatemime.h>

Inheritance diagram for MimeBody:
GenObject MimeBinaryBody MimeLinesBody MimeMultipartBody MimeSdpBody MimeStringBody

Public Member Functions

virtual ~MimeBody ()
 
virtual void * getObject (const String &name) const
 
const MimeHeaderLinegetType () const
 
MimeBodygetFirst (const String &type) const
 
const ObjListheaders () const
 
void appendHdr (MimeHeaderLine *hdr)
 
void removeHdr (MimeHeaderLine *hdr, bool delobj=true)
 
MimeHeaderLinefindHdr (const String &name, const MimeHeaderLine *start=0) const
 
void buildHeaders (String &buf)
 
bool setParam (const char *name, const char *value=0, const char *header=0)
 
bool delParam (const char *name, const char *header=0)
 
const NamedStringgetParam (const char *name, const char *header=0) const
 
const DataBlockgetBody () const
 
const DataBlockbody () const
 
virtual bool isSDP () const
 
virtual bool isMultipart () const
 
virtual MimeBodyclone () const =0
 
- Public Member Functions inherited from GenObject
 GenObject ()
 
virtual ~GenObject ()
 
virtual bool alive () const
 
virtual void destruct ()
 
virtual const StringtoString () const
 
NamedCountergetObjCounter () const
 
NamedCountersetObjCounter (NamedCounter *counter)
 

Static Public Member Functions

static MimeBodybuild (const char *buf, int len, const MimeHeaderLine &type)
 
static StringgetUnfoldedLine (const char *&buf, int &len)
 
- Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
 
static bool getObjCounting ()
 
static void setObjCounting (bool enable)
 
static NamedCountergetObjCounter (const String &name, bool create=true)
 
static ObjListgetObjCounters ()
 

Protected Member Functions

 MimeBody (const String &type)
 
 MimeBody (const MimeHeaderLine &type)
 
virtual void buildBody () const =0
 

Protected Attributes

DataBlock m_body
 
ObjList m_headers
 

Detailed Description

Abstract MIME data holder.

Abstract base class for holding Multipurpose Internet Mail Extensions data. Keeps a Content-Type header line with body type and parameters and any additional header lines the body may have. The body type contains lower case characters.

Constructor & Destructor Documentation

virtual ~MimeBody ( )
virtual

Destructor

MimeBody ( const String type)
protected

Constructor to be used only by derived classes. Converts the MIME type string to lower case

Parameters
typeThe value of the Content-Type header line
MimeBody ( const MimeHeaderLine type)
protected

Constructor to be used only by derived classes. Builds this body from a header line. Converts the MIME type string to lower case

Parameters
typeThe content type header line

Member Function Documentation

void appendHdr ( MimeHeaderLine hdr)
inline

Append an additional header line to this body

Parameters
hdrThe header line to append

References ObjList::append(), and MimeBody::m_headers.

const DataBlock& body ( ) const
inline

Get the binary data of this MIME body without building it.

Returns
Block of binary data

References MimeBody::m_body.

static MimeBody* build ( const char *  buf,
int  len,
const MimeHeaderLine type 
)
static

Method to build a MIME body from a type and data buffer. Unknown body types are built into a binary body. Exactly 1 leading CRLF is removed from the beginning of the buffer if found before building it

Parameters
bufPointer to buffer of data just after the body headers
lenLength of data in buffer
typeThe header line declaring the body's content. Usually this is a Content-Type header line
Returns
Newly allocated MIME body or NULL if the buffer is empty
virtual void buildBody ( ) const
protectedpure virtual

Method that is called internally to build the binary encoded body

Implemented in MimeLinesBody, MimeStringBody, MimeBinaryBody, MimeSdpBody, and MimeMultipartBody.

void buildHeaders ( String buf)
inline

Build a string with this body's header lines

Parameters
bufDestination string

References MimeHeaderLine::buildHeaders(), MimeHeaderLine::buildLine(), and MimeBody::m_headers.

virtual MimeBody* clone ( ) const
pure virtual

Duplicate this MIME body

Returns
Copy of this MIME body

Implemented in MimeLinesBody, MimeStringBody, MimeBinaryBody, MimeSdpBody, and MimeMultipartBody.

bool delParam ( const char *  name,
const char *  header = 0 
)

Remove a header parameter

Parameters
nameParameter's name
headerHeader whose parameter will be removed. Set to 0 to use the body's content type header
Returns
False if the header doesn't exist
MimeHeaderLine* findHdr ( const String name,
const MimeHeaderLine start = 0 
) const

Find an additional header line by its name. The names are compared case insensitive

Parameters
nameThe name of the header to find
startThe starting point in the list. 0 to start from the beginning
Returns
Pointer to MimeHeaderLine or 0 if not found
const DataBlock& getBody ( ) const

Retrieve the binary encoding of this MIME body. Build the body if empty. The body doesn't contain the Content-Type header or the additional headers

Returns
Block of binary data
MimeBody* getFirst ( const String type) const

Get the first body that matches a requested type, descends into multiparts

Parameters
typeName of the MIME type to search for
Returns
Pointer to requested body or NULL if not found
virtual void* getObject ( const String name) const
virtual

RTTI method, get a pointer to a derived class given the class name

Parameters
nameName of the class we are asking for
Returns
Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from GenObject.

Reimplemented in MimeLinesBody, MimeStringBody, MimeBinaryBody, MimeSdpBody, and MimeMultipartBody.

const NamedString* getParam ( const char *  name,
const char *  header = 0 
) const

Get a header parameter

Parameters
nameParameter's name
headerHeader whose parameter will be retrieved. Set to 0 to use the body's content type header
Returns
Pointer to the desired parameter or 0 if not found
const MimeHeaderLine& getType ( ) const
inline

Retrieve the MIME type of this body

Returns
Name of the MIME type/subtype
static String* getUnfoldedLine ( const char *&  buf,
int &  len 
)
static

Utility method, returns an unfolded line and advances the pointer

Parameters
bufReference to pointer to start of buffer data
lenReference to variable holding buffer length
Returns
Newly allocated String holding the line of text
const ObjList& headers ( ) const
inline

Retrieve the additional headers of this MIME body (other then Content-Type)

Returns
The list of header lines of this MIME body

References MimeBody::m_headers.

virtual bool isMultipart ( ) const
inlinevirtual

Check if this body is multipart (can hold other MIME bodies)

Returns
True if this body is multipart

Reimplemented in MimeMultipartBody.

virtual bool isSDP ( ) const
inlinevirtual

Check if this body is a Session Description Protocol

Returns
True if this body holds a SDP

Reimplemented in MimeSdpBody.

void removeHdr ( MimeHeaderLine hdr,
bool  delobj = true 
)
inline

Remove an additional header line from this body

Parameters
hdrThe header line to remove
delobjTrue to delete the header, false to remove from list without deleting it

References MimeBody::m_headers, and ObjList::remove().

bool setParam ( const char *  name,
const char *  value = 0,
const char *  header = 0 
)

Replace the value of an existing parameter or add a new one

Parameters
nameParameter's name
valueParameter's value
headerHeader whose parameter will be changed. Set to 0 to use the body's content type header
Returns
False if the header doesn't exist

Member Data Documentation

DataBlock m_body
mutableprotected

Block of binary data that buildBody() must fill

Referenced by MimeBody::body().

ObjList m_headers
protected

Additional body headers (other then Content-Type)

Referenced by MimeBody::appendHdr(), MimeBody::buildHeaders(), MimeBody::headers(), and MimeBody::removeHdr().


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