mime.h

Go to the documentation of this file.
00001 /*
00002  * mime.h
00003  *
00004  * Multipurpose Internet Mail Extensions support classes.
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 1993-2002 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Contributor(s): ______________________________________.
00025  *
00026  * $Revision: 20385 $
00027  * $Author: rjongbloed $
00028  * $Date: 2008-06-04 10:40:38 +0000 (Wed, 04 Jun 2008) $
00029  */
00030 
00031 #ifndef _PMIME
00032 #define _PMIME
00033 
00034 #ifdef P_USE_PRAGMA
00035 #pragma interface
00036 #endif
00037 
00038 #include <ptclib/inetprot.h>
00039 #include <ptclib/cypher.h>
00040 
00042 // PMIMEInfo
00043 
00048 #ifdef DOC_PLUS_PLUS
00049 class PMIMEInfo : public PStringToString {
00050 #endif
00051 PDECLARE_STRING_DICTIONARY(PMIMEInfo, PCaselessString);
00052   public:
00053     PMIMEInfo(
00054       istream &strm   
00055     );
00056     PMIMEInfo(
00057       PInternetProtocol & socket   
00058     );
00059     // Construct a MIME information dictionary from the specified source.
00060 
00061 
00062   // Overrides from class PObject
00066     virtual void PrintOn(
00067       ostream &strm   
00068     ) const;
00069 
00073     virtual void ReadFrom(
00074       istream &strm   
00075     );
00076 
00077 
00078   // Overrides from class PStringToString
00085     PBoolean SetAt(
00086       const char * key,
00087       const PString value
00088     ) { return AbstractSetAt(PCaselessString(key), PNEW PString(value)); }
00089 
00096     PBoolean SetAt(
00097       const PString & key,
00098       const PString value
00099     ) { return AbstractSetAt(PCaselessString(key), PNEW PString(value)); }
00100 
00107     PBoolean SetAt(
00108       const PCaselessString & key,
00109       const PString value
00110     ) { return AbstractSetAt(PCaselessString(key), PNEW PString(value)); }
00111 
00118     PBoolean Contains(
00119       const char * key       
00120     ) const { return GetAt(PCaselessString(key)) != NULL; }
00121 
00128     PBoolean Contains(
00129       const PString & key       
00130     ) const { return GetAt(PCaselessString(key)) != NULL; }
00131 
00138     PBoolean Contains(
00139       const PCaselessString & key       
00140     ) const { return GetAt(key) != NULL; }
00141 
00142   // New functions for class.
00148     PBoolean Read(
00149       PInternetProtocol & socket   
00150     );
00151 
00157     PBoolean Write(
00158       PInternetProtocol & socket   
00159     ) const;
00160 
00169     PBoolean AddMIME(
00170       const PString & line
00171     );
00172     PBoolean AddMIME(
00173       const PString & fieldName, 
00174       const PString & _fieldValue
00175     );
00176 
00184     PString GetString(
00185       const PString & key,       
00186       const PString & dflt = PString::Empty() 
00187     ) const;
00188 
00196     long GetInteger(
00197       const PString & key,    
00198       long dflt = 0           
00199     ) const;
00200 
00203     void SetInteger(
00204       const PCaselessString & key,  
00205       long value                    
00206     );
00207 
00208 
00246     static void SetAssociation(
00247       const PStringToString & allTypes,  
00248       PBoolean merge = PTrue                  
00249     );
00250     static void SetAssociation(
00251       const PString & fileType,         
00252       const PString & contentType       
00253     ) { GetContentTypes().SetAt(fileType, contentType); }
00254 
00262     static PString GetContentType(
00263       const PString & fileType   
00264     );
00265 
00266   private:
00267     static PStringToString & GetContentTypes();
00268 };
00269 
00270 
00271 
00272 #endif
00273 
00274 
00275 // End Of File ///////////////////////////////////////////////////////////////

Generated on Mon Sep 15 01:21:35 2008 for PTLib by  doxygen 1.5.1