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

Public Types

enum  EncodeAndFoldFlags {
  FORCE_NO_ENCODING = (1 << 0), FORCE_ENCODING = (1 << 1), NO_NEW_LINE_SEQUENCE = (1 << 2), QUOTE_IF_POSSIBLE = (1 << 3),
  QUOTE_IF_NEEDED = (1 << 4)
}
 

Public Member Functions

 text ()
 
 text (const text &t)
 
 text (const string &t, const charset &ch)
 
 text (const string &t)
 
 text (const word &w)
 
 ~text ()
 
bool operator== (const text &t) const
 
bool operator!= (const text &t) const
 
shared_ptr< componentclone () const
 
void copyFrom (const component &other)
 
textoperator= (const component &other)
 
textoperator= (const text &other)
 
const std::vector< shared_ptr
< component > > 
getChildComponents ()
 
void appendWord (shared_ptr< word > w)
 
void insertWordBefore (const size_t pos, shared_ptr< word > w)
 
void insertWordAfter (const size_t pos, shared_ptr< word > w)
 
void removeWord (const size_t pos)
 
void removeAllWords ()
 
size_t getWordCount () const
 
bool isEmpty () const
 
const shared_ptr< wordgetWordAt (const size_t pos)
 
const shared_ptr< const wordgetWordAt (const size_t pos) const
 
const std::vector< shared_ptr
< const word > > 
getWordList () const
 
const std::vector< shared_ptr
< word > > 
getWordList ()
 
const string getConvertedText (const charset &dest, const charsetConverterOptions &opts=charsetConverterOptions()) const
 
const string getWholeBuffer () const
 
void createFromString (const string &in, const charset &ch)
 
void encodeAndFold (const generationContext &ctx, utility::outputStream &os, const size_t firstLineOffset, size_t *lastLineLength, const int flags) const
 
- Public Member Functions inherited from headerFieldValue
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 shared_ptr< textnewFromString (const string &in, const charset &ch)
 
static shared_ptr< textdecodeAndUnfold (const string &in)
 
static shared_ptr< textdecodeAndUnfold (const parsingContext &ctx, const string &in)
 
static textdecodeAndUnfold (const string &in, text *generateInExisting)
 
static textdecodeAndUnfold (const parsingContext &ctx, const string &in, text *generateInExisting)
 

Protected Member Functions

void parseImpl (const parsingContext &ctx, const string &buffer, 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, shared_ptr< utility::parserInputStreamAdapter > parser, 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 ()
 

Static Protected Member Functions

static void fixBrokenWords (std::vector< shared_ptr< word > > &words)
 

Detailed Description

List of encoded-words, as defined in RFC-2047 (basic type).

Member Enumeration Documentation

Flags used by "encodeAndFold" function.

Enumerator
FORCE_NO_ENCODING 

Just fold lines, don't encode them.

FORCE_ENCODING 

Encode lines even if they are plain ASCII text.

NO_NEW_LINE_SEQUENCE 

Use CRLF instead of new-line sequence (CRLF + TAB).

QUOTE_IF_POSSIBLE 

Use quoting instead of encoding when possible (even if FORCE_ENCODING is specified).

QUOTE_IF_NEEDED 

Use quoting instead of encoding if needed (eg.

whitespaces and/or special chars).

Constructor & Destructor Documentation

text ( )

Referenced by text::decodeAndUnfold().

text ( const text t)

References text::copyFrom().

text ( const string t,
const charset ch 
)
text ( const string t)
explicit
text ( const word w)
explicit

References text::appendWord().

~text ( )

Member Function Documentation

void appendWord ( shared_ptr< word w)

Add a word at the end of the list.

Parameters
wword to append

Referenced by text::createFromString(), text::text(), and emailAddress::toText().

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 text::removeAllWords().

Referenced by text::operator=(), and text::text().

void createFromString ( const string in,
const charset ch 
)

This function can be used to make several encoded words from a text.

All the characters in the text must be in the same specified charset.

Eg: giving:

   <iso-8859-1> "Linux dans un t'el'ephone mobile"
   ("=?iso-8859-1?Q?Linux_dans_un_t=E9l=E9phone_mobile?=")

it will return:

   <us-ascii>   "Linux dans un "
   <iso-8859-1> "t'el'ephone "
   <us-ascii>   "mobile"
   ("Linux dans un =?iso-8859-1?Q?t=E9l=E9phone_?= mobile")
Parameters
ininput string
chinput charset

References text::appendWord(), vmime::count(), stringUtils::countASCIIchars(), charset::getRecommendedEncoding(), text::getWordAt(), text::getWordCount(), parserHelpers::isAscii(), parserHelpers::isSpace(), text::removeAllWords(), and vmime::charsets::US_ASCII.

Referenced by text::text().

shared_ptr< text > decodeAndUnfold ( const string in)
static

Decode and unfold text (RFC-2047), using the default parsing context.

Parameters
ininput string
Returns
new text object

References parsingContext::getDefaultContext().

Referenced by text::decodeAndUnfold(), mailbox::parseImpl(), and mailboxGroup::parseImpl().

shared_ptr< text > decodeAndUnfold ( const parsingContext ctx,
const string in 
)
static

Decode and unfold text (RFC-2047).

Parameters
ctxparsingContext
ininput string
Returns
new text object

References text::decodeAndUnfold().

text * decodeAndUnfold ( const string in,
text generateInExisting 
)
static

Decode and unfold text (RFC-2047), using the default parsing context.

Parameters
ininput string
generateInExistingif not NULL, the resulting text will be generated in the specified object instead of a new created object (in this case, the function returns the same pointer). Can be used to avoid copying the resulting object into an existing object.
Returns
new text object or existing object if generateInExisting != NULL

References text::decodeAndUnfold(), and parsingContext::getDefaultContext().

text * decodeAndUnfold ( const parsingContext ctx,
const string in,
text generateInExisting 
)
static

Decode and unfold text (RFC-2047).

Parameters
ctxparsing context
ininput string
generateInExistingif not NULL, the resulting text will be generated in the specified object instead of a new created object (in this case, the function returns the same pointer). Can be used to avoid copying the resulting object into an existing object.
Returns
new text object or existing object if generateInExisting != NULL

References vmime::copy_vector(), text::fixBrokenWords(), text::removeAllWords(), and text::text().

void encodeAndFold ( const generationContext ctx,
utility::outputStream os,
const size_t  firstLineOffset,
size_t lastLineLength,
const int  flags 
) const

Encode and fold text in respect to RFC-2047.

Parameters
ctxgeneration context
osoutput stream
firstLineOffsetthe first line length (may be useful if the current output line is not empty)
lastLineLengthwill receive the length of the last line written
flagsencoding flags (see EncodeAndFoldFlags)

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

void fixBrokenWords ( std::vector< shared_ptr< word > > &  words)
staticprotected

Referenced by text::decodeAndUnfold().

void generateImpl ( const generationContext ctx,
utility::outputStream os,
const size_t  curLinePos = 0,
size_t newLinePos = NULL 
) const
protectedvirtual

Implements component.

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 string getConvertedText ( const charset dest,
const charsetConverterOptions opts = charsetConverterOptions() 
) const

Return the text converted into the specified charset.

The encoded-words are decoded and then converted in the specified destination charset.

Parameters
destoutput charset
optsoptions for charset conversion
Returns
text decoded in the specified charset

Referenced by SMTPCommand::MAIL(), and SMTPCommand::RCPT().

const string getWholeBuffer ( ) const

Return the unconverted (raw) data of all words.

This is the concatenation of the results returned by getBuffer() on the contained words.

Returns
raw data

Referenced by importanceHelper::getImportanceHeader(), htmlTextPart::parse(), and body::parseImpl().

const shared_ptr< word > getWordAt ( const size_t  pos)

Return the word at the specified position.

Parameters
posposition
Returns
word at position 'pos'

Referenced by text::createFromString().

const shared_ptr< const word > getWordAt ( const size_t  pos) const

Return the word at the specified position.

Parameters
posposition
Returns
word at position 'pos'
size_t getWordCount ( ) const

Return the number of words in the list.

Returns
number of words

Referenced by text::createFromString(), and text::operator==().

const std::vector< shared_ptr< const word > > getWordList ( ) const

Return the word list.

Returns
list of words
const std::vector< shared_ptr< word > > getWordList ( )

Return the word list.

Returns
list of words
void insertWordAfter ( const size_t  pos,
shared_ptr< word w 
)

Insert a new word after the specified position.

Parameters
posposition of the word before the new word
wword to insert
void insertWordBefore ( const size_t  pos,
shared_ptr< word w 
)

Insert a new word before the specified position.

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

Tests whether the list of words is empty.

Returns
true if there is no word, false otherwise

Referenced by body::generateImpl(), defaultAttachment::generatePart(), and body::getGeneratedSize().

shared_ptr< text > newFromString ( const string in,
const charset ch 
)
static

This function can be used to make several encoded words from a text.

All the characters in the text must be in the same specified charset.

Eg: giving:

   <iso-8859-1> "Linux dans un t'el'ephone mobile"
   ("=?iso-8859-1?Q?Linux_dans_un_t=E9l=E9phone_mobile?=")

it will return:

   <us-ascii>   "Linux dans un "
   <iso-8859-1> "t'el'ephone "
   <us-ascii>   "mobile"
   ("Linux dans un =?iso-8859-1?Q?t=E9l=E9phone_?= mobile")
Parameters
ininput string
chinput charset
Returns
new text object
bool operator!= ( const text t) const
text & operator= ( const component other)

References text::copyFrom().

text & operator= ( const text other)

References text::copyFrom().

bool operator== ( const text t) const

References text::getWordCount().

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

Reimplemented from component.

References vmime::copy_vector().

void removeAllWords ( )
void removeWord ( const size_t  pos)

Remove the word at the specified position.

Parameters
posposition of the word to remove

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