00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
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
00060
00061
00062
00066 virtual void PrintOn(
00067 ostream &strm
00068 ) const;
00069
00073 virtual void ReadFrom(
00074 istream &strm
00075 );
00076
00077
00078
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
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