VMime
component Class Referenceabstract

#include <component.hpp>

Inheritance diagram for component:
Collaboration diagram for component:

Public Member Functions

 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
virtual shared_ptr< componentclone () const =0
virtual void copyFrom (const component &other)=0
size_t getParsedOffset () const
size_t getParsedLength () const
virtual const std::vector< shared_ptr< component > > getChildComponents ()=0
virtual size_t getGeneratedSize (const generationContext &ctx)

Protected Member Functions

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

Detailed Description

This abstract class is the base class for all the components of a message.

It defines methods for parsing and generating a component.

Constructor & Destructor Documentation

◆ component()

◆ ~component()

~component ( )
virtual

Member Function Documentation

◆ clone()

virtual shared_ptr< component > clone ( ) const
pure virtual

◆ copyFrom()

virtual void copyFrom ( const component & other)
pure 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

Implemented in addressList, body, bodyPart, charset, contentDisposition, datetime, disposition, emailAddress, encoding, header, headerField, mailbox, mailboxGroup, mailboxList, mediaType, messageId, messageIdSequence, parameter, parameterizedHeaderField, path, relay, text, and word.

References component(), getParsedLength(), and getParsedOffset().

◆ generate() [1/3]

void generate ( const generationContext & ctx,
utility::outputStream & outputStream,
const size_t curLinePos = 0,
size_t * newLinePos = NULL ) const
virtual

Generate RFC-2822/MIME data for this component, using the default generation context.

Parameters
ctxgeneration context
outputStreamoutput stream
curLinePoslength of the current line in the output buffer
newLinePoswill receive the new line position (length of the last line written)

Reimplemented in emailAddress, and word.

References generateImpl().

◆ generate() [2/3]

const string generate ( const size_t maxLineLength = lineLengthLimits::infinite,
const size_t curLinePos = 0 ) const
virtual

Generate RFC-2822/MIME data for this component.

Deprecated
Use the new generate() method, which takes an outputStream parameter.
Parameters
maxLineLengthmaximum line length for output
curLinePoslength of the current line in the output buffer
Returns
generated data

Reimplemented in emailAddress, message, and word.

References generateImpl(), generationContext::getDefaultContext(), and generationContext::setMaxLineLength().

Referenced by textPartFactory::create(), message::generate(), encoding::getEncoder(), headerFieldValue::getGeneratedSize(), and parameter::setValue().

◆ generate() [3/3]

void generate ( utility::outputStream & outputStream,
const size_t curLinePos = 0,
size_t * newLinePos = NULL ) const
virtual

Generate RFC-2822/MIME data for this component, using the default generation context.

Parameters
outputStreamoutput stream
curLinePoslength of the current line in the output buffer
newLinePoswill receive the new line position (length of the last line written)

Reimplemented in emailAddress, and word.

References generateImpl(), and generationContext::getDefaultContext().

◆ generateImpl()

virtual void generateImpl ( const generationContext & ctx,
utility::outputStream & os,
const size_t curLinePos = 0,
size_t * newLinePos = NULL ) const
protectedpure virtual

◆ getChildComponents()

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

◆ getGeneratedSize()

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 in body, bodyPart, header, headerField, headerFieldValue, parameter, and parameterizedHeaderField.

References getChildComponents().

Referenced by getChildComponents(), and header::getGeneratedSize().

◆ getParsedLength()

size_t getParsedLength ( ) const

Return the length of this component in the parsed message contents.

Use for debugging only.

Returns
length of the component in parsed buffer or 0 if this component has not been parsed

Referenced by copyFrom().

◆ getParsedOffset()

size_t getParsedOffset ( ) const

Return the start position of this component in the parsed message contents.

Use for debugging only.

Returns
start position in parsed buffer or 0 if this component has not been parsed

Referenced by copyFrom().

◆ parse() [1/7]

void parse ( const parsingContext & ctx,
const string & buffer )

Parse RFC-822/MIME data for this component.

Parameters
ctxparsing context
bufferinput buffer

References parseImpl().

◆ parse() [2/7]

void parse ( const parsingContext & ctx,
const string & buffer,
const size_t position,
const size_t end,
size_t * newPosition = NULL )

Parse RFC-822/MIME data for this component.

Parameters
ctxparsing context
bufferinput buffer
positioncurrent position in the input buffer
endend position in the input buffer
newPositionwill receive the new position in the input buffer

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

◆ parse() [3/7]

void parse ( const parsingContext & ctx,
shared_ptr< utility::inputStream > inputStream,
const size_t position,
const size_t end,
size_t * newPosition = NULL )

Parse RFC-822/MIME data for this component.

If stream is not seekable, or if end position is not specified, entire contents of the stream will be loaded into memory before parsing.

Parameters
ctxparsing context
inputStreamstream from which to read data
positioncurrent position in the input stream
endend position in the input stream
newPositionwill receive the new position in the input stream

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

◆ parse() [4/7]

void parse ( const string & buffer)

Parse RFC-822/MIME data for this component, using the default parsing context.

Parameters
bufferinput buffer

Referenced by datetime::datetime(), mediaType::mediaType(), messageId::messageId(), datetime::operator=(), mediaType::operator=(), messageId::operator=(), parse(), body::parseImpl(), mediaType::setFromString(), and headerField::setValue().

◆ parse() [5/7]

void parse ( const string & buffer,
const size_t position,
const size_t end,
size_t * newPosition = NULL )

Parse RFC-822/MIME data for this component, using the default parsing context.

Parameters
bufferinput buffer
positioncurrent position in the input buffer
endend position in the input buffer
newPositionwill receive the new position in the input buffer

References vmime::end().

◆ parse() [6/7]

void parse ( shared_ptr< utility::inputStream > inputStream,
const size_t length )

Parse RFC-822/MIME data for this component.

If stream is not seekable, or if length is not specified, entire contents of the stream will be loaded into memory before parsing.

Parameters
inputStreamstream from which to read data
lengthdata length, in bytes (0 = unknown/not specified)

References parse().

◆ parse() [7/7]

void parse ( shared_ptr< utility::inputStream > inputStream,
const size_t position,
const size_t end,
size_t * newPosition = NULL )

Parse RFC-822/MIME data for this component.

If stream is not seekable, or if end position is not specified, entire contents of the stream will be loaded into memory before parsing. The default parsing context will be used.

Parameters
inputStreamstream from which to read data
positioncurrent position in the input stream
endend position in the input stream
newPositionwill receive the new position in the input stream

◆ parseImpl() [1/2]

void parseImpl ( const parsingContext & ctx,
const string & buffer,
const size_t position,
const size_t end,
size_t * newPosition = NULL )
protectedvirtual

◆ parseImpl() [2/2]

void parseImpl ( const parsingContext & ctx,
shared_ptr< utility::parserInputStreamAdapter > parser,
const size_t position,
const size_t end,
size_t * newPosition = NULL )
protectedvirtual

◆ setParsedBounds()


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