VMime
body Class Reference
Inheritance diagram for body:
Collaboration diagram for body:

Public Member Functions

 body ()
 
 ~body ()
 
void appendPart (shared_ptr< bodyPart > part)
 
void insertPartBefore (shared_ptr< bodyPart > beforePart, shared_ptr< bodyPart > part)
 
void insertPartBefore (const size_t pos, shared_ptr< bodyPart > part)
 
void insertPartAfter (shared_ptr< bodyPart > afterPart, shared_ptr< bodyPart > part)
 
void insertPartAfter (const size_t pos, shared_ptr< bodyPart > part)
 
void removePart (shared_ptr< bodyPart > part)
 
void removePart (const size_t pos)
 
void removeAllParts ()
 
size_t getPartCount () const
 
bool isEmpty () const
 
shared_ptr< bodyPartgetPartAt (const size_t pos)
 
const shared_ptr< const bodyPartgetPartAt (const size_t pos) const
 
const std::vector< shared_ptr
< const bodyPart > > 
getPartList () const
 
const std::vector< shared_ptr
< bodyPart > > 
getPartList ()
 
const stringgetPrologText () const
 
void setPrologText (const string &prologText)
 
const stringgetEpilogText () const
 
void setEpilogText (const string &epilogText)
 
const shared_ptr< const
contentHandler
getContents () const
 
void setContents (shared_ptr< const contentHandler > contents)
 
void setContents (shared_ptr< const contentHandler > contents, const mediaType &type)
 
void setContents (shared_ptr< const contentHandler > contents, const mediaType &type, const charset &chset)
 
void setContents (shared_ptr< const contentHandler > contents, const mediaType &type, const charset &chset, const encoding &enc)
 
void setContentType (const mediaType &type, const charset &chset)
 
void setContentType (const mediaType &type)
 
const mediaType getContentType () const
 
void setCharset (const charset &chset)
 
const charset getCharset () const
 
void setEncoding (const encoding &enc)
 
const encoding getEncoding () const
 
shared_ptr< componentclone () const
 
void copyFrom (const component &other)
 
bodyoperator= (const body &other)
 
const std::vector< shared_ptr
< component > > 
getChildComponents ()
 
size_t getGeneratedSize (const generationContext &ctx)
 
- Public Member Functions inherited from component
 component ()
 
virtual ~component ()
 
void parse (const string &buffer)
 
void parse (const parsingContext &ctx, const string &buffer)
 
void parse (shared_ptr< utility::inputStream > inputStream, const size_t length)
 
void parse (const string &buffer, const size_t position, const size_t end, size_t *newPosition=NULL)
 
void parse (const parsingContext &ctx, const string &buffer, const size_t position, const size_t end, size_t *newPosition=NULL)
 
void parse (shared_ptr< utility::inputStream > inputStream, const size_t position, const size_t end, size_t *newPosition=NULL)
 
void parse (const parsingContext &ctx, shared_ptr< utility::inputStream > inputStream, const size_t position, const size_t end, size_t *newPosition=NULL)
 
virtual const string generate (const size_t maxLineLength=lineLengthLimits::infinite, const size_t curLinePos=0) const
 
virtual void generate (utility::outputStream &outputStream, const size_t curLinePos=0, size_t *newLinePos=NULL) const
 
virtual void generate (const generationContext &ctx, utility::outputStream &outputStream, const size_t curLinePos=0, size_t *newLinePos=NULL) const
 
size_t getParsedOffset () const
 
size_t getParsedLength () const
 

Static Public Member Functions

static const string generateRandomBoundaryString ()
 
static bool isValidBoundary (const string &boundary)
 

Protected Member Functions

size_t findNextBoundaryPosition (shared_ptr< utility::parserInputStreamAdapter > parser, const string &boundary, const size_t position, const size_t end, size_t *boundaryStart, size_t *boundaryEnd)
 
void parseImpl (const parsingContext &ctx, shared_ptr< utility::parserInputStreamAdapter > parser, const size_t position, const size_t end, size_t *newPosition=NULL)
 
void generateImpl (const generationContext &ctx, utility::outputStream &os, const size_t curLinePos=0, size_t *newLinePos=NULL) const
 
- Protected Member Functions inherited from component
void setParsedBounds (const size_t start, const size_t end)
 
virtual void parseImpl (const parsingContext &ctx, const string &buffer, const size_t position, const size_t end, size_t *newPosition=NULL)
 
- Protected Member Functions inherited from object
 object ()
 
 object (const object &)
 
objectoperator= (const object &)
 
virtual ~object ()
 

Detailed Description

Body section of a MIME part.

Constructor & Destructor Documentation

body ( )
~body ( )

Member Function Documentation

void appendPart ( shared_ptr< bodyPart part)

Add a part at the end of the list.

Parameters
partpart to append
shared_ptr< component > clone ( ) const
virtual

Clone this component.

Returns
a copy of this component

Implements component.

void copyFrom ( const component other)
virtual

Replace data in this component by data in other component.

Both components must be of the same type.

Exceptions
std::bad_cast_exceptionif the components are not of the same (dynamic) type
Parameters
otherother component to copy data from

Implements component.

References bodyPart::createChildPart(), body::getPartAt(), body::getPartCount(), and body::removeAllParts().

Referenced by body::operator=().

size_t findNextBoundaryPosition ( shared_ptr< utility::parserInputStreamAdapter parser,
const string boundary,
const size_t  position,
const size_t  end,
size_t boundaryStart,
size_t boundaryEnd 
)
protected

Finds the next boundary position in the parsing buffer.

Parameters
parserparser object
boundaryboundary string (without "--" nor CR/LF)
positionstart position
endend position
boundaryStartwill hold the start position of the boundary (including any CR/LF and "--" before the boundary)
boundaryEndwill hold the end position of the boundary (position just before the CRLF or "--" which follows)
Returns
the position of the boundary string, or npos if not found

References vmime::npos.

const string generateRandomBoundaryString ( )
static

Generate a new random boundary string.

Returns
randomly generated boundary string

References random::getNext(), and random::getTime().

const charset getCharset ( ) const

Return the charset of the data contained in the body contents.

This is a shortcut for getHeader()->ContentType()->getCharset() on the parent part.

Returns
charset of body contents

References vmime::fields::CONTENT_TYPE, bodyPart::getHeader(), and vmime::charsets::US_ASCII.

const std::vector< shared_ptr< component > > getChildComponents ( )
virtual

Return the list of children of this component.

Returns
list of child components

Implements component.

References vmime::copy_vector().

const shared_ptr< const contentHandler > getContents ( ) const

Return a read-only reference to body contents.

Returns
read-only body contents
const mediaType getContentType ( ) const

Return the media type of the data contained in the body contents.

This is a shortcut for getHeader()->ContentType()->getValue() on the parent part.

Returns
media type of body contents

References vmime::fields::CONTENT_TYPE, bodyPart::getHeader(), headerField::getValue(), vmime::mediaTypes::TEXT, and vmime::mediaTypes::TEXT_PLAIN.

const encoding getEncoding ( ) const

Return the encoding used to encode the body contents.

This is a shortcut for getHeader()->ContentTransferEncoding()->getValue() on the parent part.

Returns
encoding of body contents

References vmime::fields::CONTENT_TRANSFER_ENCODING, bodyPart::getHeader(), and vmime::encodingTypes::SEVEN_BIT.

Referenced by body::getGeneratedSize().

const string & getEpilogText ( ) const

Return the epilog text.

Returns
epilog text
size_t getGeneratedSize ( const generationContext ctx)
virtual

Get the number of bytes that will be used by this component when it is generated.

This may be a heuristically-derived estimate, but such an estimated size should always be larger than the actual generated size.

Parameters
ctxgeneration context
Returns
component size when generated

Reimplemented from component.

References text::encodeAndFold(), text::FORCE_NO_ENCODING, encoding::getEncoder(), body::getEncoding(), body::getPartAt(), body::getPartCount(), text::isEmpty(), and text::NO_NEW_LINE_SEQUENCE.

shared_ptr< bodyPart > getPartAt ( const size_t  pos)

Return the part at the specified position.

Parameters
posposition
Returns
part at position 'pos'

Referenced by body::copyFrom(), and body::getGeneratedSize().

const shared_ptr< const bodyPart > getPartAt ( const size_t  pos) const

Return the part at the specified position.

Parameters
posposition
Returns
part at position 'pos'
size_t getPartCount ( ) const

Return the number of parts in the list.

Returns
number of parts

Referenced by body::copyFrom(), and body::getGeneratedSize().

const std::vector< shared_ptr< const bodyPart > > getPartList ( ) const

Return the part list.

Returns
list of parts
const std::vector< shared_ptr< bodyPart > > getPartList ( )

Return the part list.

Returns
list of parts
const string & getPrologText ( ) const

Return the prolog text.

Returns
prolog text
void insertPartAfter ( shared_ptr< bodyPart afterPart,
shared_ptr< bodyPart part 
)

Insert a new part after the specified part.

Parameters
afterPartpart after which the new part will be inserted
partpart to insert
Exceptions
exceptions::no_such_partif the part is not in the list
void insertPartAfter ( const size_t  pos,
shared_ptr< bodyPart part 
)

Insert a new part after the specified position.

Parameters
posposition of the part before the new part
partpart to insert
void insertPartBefore ( shared_ptr< bodyPart beforePart,
shared_ptr< bodyPart part 
)

Insert a new part before the specified part.

Parameters
beforePartpart before which the new part will be inserted
partpart to insert
Exceptions
exceptions::no_such_partif the part is not in the list
void insertPartBefore ( const size_t  pos,
shared_ptr< bodyPart part 
)

Insert a new part before the specified position.

Parameters
posposition at which to insert the new part (0 to insert at the beginning of the list)
partpart to insert
bool isEmpty ( ) const

Tests whether the list of parts is empty.

Returns
true if there is no part, false otherwise
bool isValidBoundary ( const string boundary)
static

Test a boundary string for validity (as defined in RFC #1521, page 19).

Parameters
boundaryboundary string to test
Returns
true if the boundary string is valid, false otherwise

References vmime::end(), and vmime::npos.

body & operator= ( const body other)

References body::copyFrom().

void removeAllParts ( )

Remove all parts from the list.

Referenced by body::copyFrom().

void removePart ( shared_ptr< bodyPart part)

Remove the specified part from the list.

Parameters
partpart to remove
Exceptions
exceptions::no_such_partif the part is not in the list
void removePart ( const size_t  pos)

Remove the part at the specified position.

Parameters
posposition of the part to remove
void setCharset ( const charset chset)

Set the charset of contents.

If the type is not set, it will be set to default "text/plain" type.

Parameters
chsetcharset of contents

References vmime::fields::CONTENT_TYPE, bodyPart::getHeader(), contentTypeField::setCharset(), body::setContentType(), vmime::mediaTypes::TEXT, and vmime::mediaTypes::TEXT_PLAIN.

void setContents ( shared_ptr< const contentHandler contents)

Set the body contents.

Parameters
contentsnew body contents
void setContents ( shared_ptr< const contentHandler contents,
const mediaType type 
)

Set the body contents and type.

Parameters
contentsnew body contents
typetype of contents

References body::setContentType().

void setContents ( shared_ptr< const contentHandler contents,
const mediaType type,
const charset chset 
)

Set the body contents, type and charset.

Parameters
contentsnew body contents
typetype of contents
chsetcharset of contents

References body::setContentType().

void setContents ( shared_ptr< const contentHandler contents,
const mediaType type,
const charset chset,
const encoding enc 
)

Set the body contents, type, charset and encoding.

Parameters
contentsnew body contents
typetype of contents
chsetcharset of contents
enccontents encoding

References body::setContentType(), and body::setEncoding().

void setContentType ( const mediaType type,
const charset chset 
)

Set the MIME type and charset of contents.

If a charset is defined, it will not be modified.

Parameters
typeMIME media type of contents
chsetcharset of contents

References bodyPart::getHeader().

Referenced by body::setCharset(), and body::setContents().

void setContentType ( const mediaType type)

Set the MIME type of contents.

Parameters
typeMIME media type of contents

References bodyPart::getHeader().

void setEncoding ( const encoding enc)

Set the output encoding of contents.

Contents will be encoded (or re-encoded) when this node is being generated.

Parameters
encencoding of contents

References bodyPart::getHeader().

Referenced by body::setContents().

void setEpilogText ( const string epilogText)

Set the epilog text.

Parameters
epilogTextnew epilog text
void setPrologText ( const string prologText)

Set the prolog text.

Parameters
prologTextnew prolog text

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