PMIMEInfo Class Reference

This class contains the Multipurpose Internet Mail Extensions parameters and variables. More...

#include <mime.h>

Inheritance diagram for PMIMEInfo:

PStringOptions PStringToString PStringDictionary< K > PAbstractDictionary PHashTable PCollection PContainer PObject List of all members.

Public Member Functions

 PMIMEInfo ()
 PMIMEInfo (istream &strm)
 Construct a MIME information dictionary from the specified source.
 PMIMEInfo (PInternetProtocol &socket)
 PMIMEInfo (const PStringToString &dict)
 PMIMEInfo (const PString &str)
virtual void PrintOn (ostream &strm) const
 Output the contents of the MIME dictionary to the stream.
virtual void ReadFrom (istream &strm)
 Input the contents of the MIME dictionary from the stream.
PBoolean Read (PInternetProtocol &socket)
 Read MIME information from the socket.
PBoolean Write (PInternetProtocol &socket) const
 Write MIME information to the socket.
PString AsString () const
 Return a string presentation of the MIME.
bool AddMIME (const PString &line)
 Add a MIME field given a "name: value" format string.
bool AddMIME (const PString &fieldName, const PString &fieldValue)
bool AddMIME (const PMIMEInfo &mime)
virtual bool InternalAddMIME (const PString &fieldName, const PString &fieldValue)
bool GetComplex (const char *key, PStringToString &info) const
 Get a complex MIME field.
bool GetComplex (const PString &key, PStringToString &info) const
bool GetComplex (const PCaselessString &key, PStringToString &info) const
bool GetComplex (const PCaselessString &(*key)(), PStringToString &info) const
bool DecodeMultiPartList (PMultiPartList &parts, const PString &body, const PCaselessString &key) const
 Decode parts from a multipart body using the field value.
bool DecodeMultiPartList (PMultiPartList &parts, const PString &body, const PCaselessString &(*key)()=ContentTypeTag) const
 Decode parts from a multipart body using the field value.
virtual ostream & PrintContents (ostream &strm) const
 Output the contents without the trailing CRLF.

Static Public Member Functions

static bool ParseComplex (const PString &str, PStringToString &info)
 Parse the string as a complex field, see GetComplex().
static const PCaselessStringContentTypeTag ()
static const PCaselessStringContentDispositionTag ()
static const PCaselessStringContentTransferEncodingTag ()
static const PCaselessStringContentDescriptionTag ()
static const PCaselessStringContentIdTag ()
static const PCaselessStringTextPlain ()
static void SetAssociation (const PStringToString &allTypes, PBoolean merge=true)
 Set an association between a file type and a MIME content type.
static void SetAssociation (const PString &fileType, const PString &contentType)
static PString GetContentType (const PString &fileType)
 Look up the file type to MIME content type association dictionary and return the MIME content type string.

Detailed Description

This class contains the Multipurpose Internet Mail Extensions parameters and variables.


Constructor & Destructor Documentation

PMIMEInfo::PMIMEInfo (  )  [inline]

PMIMEInfo::PMIMEInfo ( istream &  strm  ) 

Construct a MIME information dictionary from the specified source.

Parameters:
strm  Stream to read the objects contents from.

PMIMEInfo::PMIMEInfo ( PInternetProtocol socket  ) 

Parameters:
socket  Application socket to read MIME info.

PMIMEInfo::PMIMEInfo ( const PStringToString dict  ) 

PMIMEInfo::PMIMEInfo ( const PString str  ) 


Member Function Documentation

bool PMIMEInfo::AddMIME ( const PMIMEInfo mime  ) 

bool PMIMEInfo::AddMIME ( const PString fieldName,
const PString fieldValue 
) [inline]

Parameters:
fieldName  MIME field name
fieldValue  MIME field value

bool PMIMEInfo::AddMIME ( const PString line  ) 

Add a MIME field given a "name: value" format string.

Note that if the field name was already in the MIME dictionary then this will append the new value after a '\n' character to the previous value.

Returns:
true is a field was added.

PString PMIMEInfo::AsString (  )  const

Return a string presentation of the MIME.

static const PCaselessString& PMIMEInfo::ContentDescriptionTag (  )  [static]

static const PCaselessString& PMIMEInfo::ContentDispositionTag (  )  [static]

static const PCaselessString& PMIMEInfo::ContentIdTag (  )  [static]

static const PCaselessString& PMIMEInfo::ContentTransferEncodingTag (  )  [static]

static const PCaselessString& PMIMEInfo::ContentTypeTag (  )  [static]

bool PMIMEInfo::DecodeMultiPartList ( PMultiPartList parts,
const PString body,
const PCaselessString &(*)()  key = ContentTypeTag 
) const [inline]

Decode parts from a multipart body using the field value.

Parameters:
parts  Extracted parts.
body  Body to decode
key  MIME key for multipart info

bool PMIMEInfo::DecodeMultiPartList ( PMultiPartList parts,
const PString body,
const PCaselessString key 
) const

Decode parts from a multipart body using the field value.

Parameters:
parts  Extracted parts.
body  Body to decode
key  MIME key for multipart info

bool PMIMEInfo::GetComplex ( const PCaselessString &(*)()  key,
PStringToString info 
) const [inline]

Parameters:
key  Key into MIME dictionary to get info.
info  Dictionary of information from field

bool PMIMEInfo::GetComplex ( const PCaselessString key,
PStringToString info 
) const [inline]

Parameters:
key  Key into MIME dictionary to get info.
info  Dictionary of information from field

bool PMIMEInfo::GetComplex ( const PString key,
PStringToString info 
) const [inline]

Parameters:
key  Key into MIME dictionary to get info.
info  Dictionary of information from field

bool PMIMEInfo::GetComplex ( const char *  key,
PStringToString info 
) const [inline]

Get a complex MIME field.

This will parse a complex MIME field of the general form:

key: base-value;tag1=token;tag2="string";tag3 key: <base-value>;tag1=token;tag2="string";tag3

The base-value will be placed in the dictionary where the key is the empty string. If the base-value is quoted with '<', '>' brackets then the brackets are removed. Note that the string "<>" can be used to have an empty base-value but a field starting with a ';' is illegal and this function will return false.

Each tag will be the key for it's entry in the dictionary, if that tag has no '=' sign then it will have an empty string as its value. If the tag value is quoted using '"', then the RFC822 rules are applied and the quotes and '\' charcters removed.

IF there are multiple "key" entries in the MIME, or there is an entry of the form:

key: <base-value>;tag=token, <base-value1>, <base-value2>;tag=token

then the first entry wil be as described above. All subsequent entries are includedin the dictionary with the key names having the string "n:" prepended, e.g. "1:" would be "base-value1", "2:tag" would be the tag value on the third entry.

Returns true if the field exists and base-value is non-empty or quoted.

Parameters:
key  Key into MIME dictionary to get info.
info  Dictionary of information from field

static PString PMIMEInfo::GetContentType ( const PString fileType  )  [static]

Look up the file type to MIME content type association dictionary and return the MIME content type string.

If the file type is not found in the dictionary then the string "application/octet-stream" is returned.

Returns:
MIME content type for file type.
Parameters:
fileType  File type (extension) to look up.

virtual bool PMIMEInfo::InternalAddMIME ( const PString fieldName,
const PString fieldValue 
) [virtual]

Parameters:
fieldName  MIME field name
fieldValue  MIME field value

static bool PMIMEInfo::ParseComplex ( const PString str,
PStringToString info 
) [static]

Parse the string as a complex field, see GetComplex().

Parameters:
str  String value from MIME field.
info  Dictionary of information from field

virtual ostream& PMIMEInfo::PrintContents ( ostream &  strm  )  const [virtual]

Output the contents without the trailing CRLF.

virtual void PMIMEInfo::PrintOn ( ostream &  strm  )  const [virtual]

Output the contents of the MIME dictionary to the stream.

This is primarily used by the standard operator<< function.

Parameters:
strm  Stream to print the object into.

Reimplemented from PAbstractDictionary.

PBoolean PMIMEInfo::Read ( PInternetProtocol socket  ) 

Read MIME information from the socket.

Returns:
true if the MIME information was successfully read.
Parameters:
socket  Application socket to read MIME info.

virtual void PMIMEInfo::ReadFrom ( istream &  strm  )  [virtual]

Input the contents of the MIME dictionary from the stream.

This is primarily used by the standard operator>> function.

Parameters:
strm  Stream to read the objects contents from.

Reimplemented from PStringToString.

static void PMIMEInfo::SetAssociation ( const PString fileType,
const PString contentType 
) [inline, static]

Parameters:
fileType  File type (extension) to match.
contentType  MIME content type string.

static void PMIMEInfo::SetAssociation ( const PStringToString allTypes,
PBoolean  merge = true 
) [static]

Set an association between a file type and a MIME content type.

The content type is then sent for any file in the directory sub-tree that has the same extension.

Note that if the merge parameter if true then the dictionary is merged into the current association list and is not a simple replacement.

The default values placed in this dictionary are:

          ".txt", "text/plain"
          ".text", "text/plain"
          ".html", "text/html"
          ".htm", "text/html"
          ".aif", "audio/aiff"
          ".aiff", "audio/aiff"
          ".au", "audio/basic"
          ".snd", "audio/basic"
          ".wav", "audio/wav"
          ".gif", "image/gif"
          ".xbm", "image/x-bitmap"
          ".tif", "image/tiff"
          ".tiff", "image/tiff"
          ".jpg", "image/jpeg"
          ".jpe", "image/jpeg"
          ".jpeg", "image/jpeg"
          ".avi", "video/avi"
          ".mpg", "video/mpeg"
          ".mpeg", "video/mpeg"
          ".qt", "video/quicktime"
          ".mov", "video/quicktime"

The default content type will be "application/octet-stream".

Parameters:
allTypes  MIME content type associations.
merge  Flag for merging associations.

static const PCaselessString& PMIMEInfo::TextPlain (  )  [static]

PBoolean PMIMEInfo::Write ( PInternetProtocol socket  )  const

Write MIME information to the socket.

Returns:
true if the MIME information was successfully read.
Parameters:
socket  Application socket to write MIME info.


The documentation for this class was generated from the following file:
Generated on Fri Feb 15 20:58:34 2013 for PTLib by  doxygen 1.4.7