PMIMEInfo Class Reference

#include <mime.h>

Inheritance diagram for PMIMEInfo:

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

Public Member Functions

 PMIMEInfo (istream &strm)
 PMIMEInfo (PInternetProtocol &socket)
virtual void PrintOn (ostream &strm) const
virtual void ReadFrom (istream &strm)
PBoolean SetAt (const char *key, const PString value)
PBoolean SetAt (const PString &key, const PString value)
PBoolean SetAt (const PCaselessString &key, const PString value)
PBoolean Contains (const char *key) const
PBoolean Contains (const PString &key) const
PBoolean Contains (const PCaselessString &key) const
PBoolean Read (PInternetProtocol &socket)
PBoolean Write (PInternetProtocol &socket) const
PBoolean AddMIME (const PString &line)
PBoolean AddMIME (const PString &fieldName, const PString &_fieldValue)
PString GetString (const PString &key, const PString &dflt=PString::Empty()) const
long GetInteger (const PString &key, long dflt=0) const
void SetInteger (const PCaselessString &key, long value)

Static Public Member Functions

static void SetAssociation (const PStringToString &allTypes, PBoolean merge=PTrue)
static void SetAssociation (const PString &fileType, const PString &contentType)
static PString GetContentType (const PString &fileType)

Detailed Description

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


Constructor & Destructor Documentation

PMIMEInfo::PMIMEInfo ( istream &  strm  ) 

Parameters:
strm  Stream to read the objects contents from.

PMIMEInfo::PMIMEInfo ( PInternetProtocol socket  ) 

Parameters:
socket  Application socket to read MIME info.


Member Function Documentation

PBoolean PMIMEInfo::AddMIME ( const PString fieldName,
const PString _fieldValue 
)

PBoolean 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 '
' character to the previous value.

Returns:
PTrue is a field was added.

PBoolean PMIMEInfo::Contains ( const PCaselessString key  )  const [inline]

Determine if the specified key is present in the MIME information set.

Returns:
PTrue if the MIME variable is present.
Parameters:
key  Key into MIME dictionary to get info.

PBoolean PMIMEInfo::Contains ( const PString key  )  const [inline]

Determine if the specified key is present in the MIME information set.

Returns:
PTrue if the MIME variable is present.
Parameters:
key  Key into MIME dictionary to get info.

PBoolean PMIMEInfo::Contains ( const char *  key  )  const [inline]

Determine if the specified key is present in the MIME information set.

Returns:
PTrue if the MIME variable is present.
Parameters:
key  Key into MIME dictionary to get info.

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.

long PMIMEInfo::GetInteger ( const PString key,
long  dflt = 0 
) const

Get an integer value for the particular MIME info field with checking for existance. The dflt# parameter is substituted if the field does not exist in the MIME information read in.

Returns:
Integer value for the MIME variable.
Parameters:
key  Key into MIME dictionary to get info.
dflt  Default value of field if not in MIME info.

PString PMIMEInfo::GetString ( const PString key,
const PString dflt = PString::Empty() 
) const

Get a string for the particular MIME info field with checking for existance. The dflt# parameter is substituted if the field does not exist in the MIME information read in.

Returns:
String for the value of the MIME variable.
Parameters:
key  Key into MIME dictionary to get info.
dflt  Default value of field if not in MIME info.

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:
PTrue 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 = PTrue 
) [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 PTrue then the dictionary is merged into the current association list and is not a simple replacement.

The default values placed in this dictionary are: {verbatim}

".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" {verbatim}

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

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

PBoolean PMIMEInfo::SetAt ( const PCaselessString key,
const PString  value 
) [inline]

Add a new value to the MIME info. If the value is already in the dictionary then this overrides the previous value.

Returns:
PTrue if the object was successfully added.

PBoolean PMIMEInfo::SetAt ( const PString key,
const PString  value 
) [inline]

Add a new value to the MIME info. If the value is already in the dictionary then this overrides the previous value.

Returns:
PTrue if the object was successfully added.

PBoolean PMIMEInfo::SetAt ( const char *  key,
const PString  value 
) [inline]

Add a new value to the MIME info. If the value is already in the dictionary then this overrides the previous value.

Returns:
PTrue if the object was successfully added.

void PMIMEInfo::SetInteger ( const PCaselessString key,
long  value 
)

Set an integer value for the particular MIME info field.

Parameters:
key  Key into MIME dictionary to get info.
value  New value of field.

PBoolean PMIMEInfo::Write ( PInternetProtocol socket  )  const

Write MIME information to the socket.

Returns:
PTrue 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 Thu May 27 01:36:49 2010 for PTLib by  doxygen 1.4.7