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 #ifndef TNT_CONTENTTYPE_H
00031 #define TNT_CONTENTTYPE_H
00032
00033 #include <tnt/messageattribute.h>
00034 #include <map>
00035
00036 namespace tnt
00037 {
00039 class Contenttype : public MessageattributeParser
00040 {
00041 public:
00042 typedef std::multimap<std::string, std::string> parameter_type;
00043 typedef parameter_type::const_iterator parameter_iterator;
00044
00045 private:
00046 virtual return_type onType(const std::string& type, const std::string& subtype);
00047 virtual return_type onParameter(const std::string& attribute, const std::string& value);
00048
00049 std::string type;
00050 std::string subtype;
00051 parameter_type parameter;
00052 std::string boundary;
00053
00054 public:
00055 Contenttype()
00056 { }
00057
00058 explicit Contenttype(const std::string& ct);
00059 Contenttype(const std::string& type_, const std::string& subtype_)
00060 : type(type_),
00061 subtype(subtype_)
00062 { }
00063
00064 const std::string& getType() const { return type; }
00065 const std::string& getSubtype() const { return subtype; }
00066 const std::string& getBoundary() const { return boundary; }
00067 bool isMultipart() const
00068 { return type == "multipart" && !boundary.empty(); }
00069
00070 parameter_iterator parameter_begin() const
00071 { return parameter.begin(); }
00072 parameter_iterator parameter_end() const
00073 { return parameter.end(); }
00074 parameter_iterator parameter_find(parameter_type::key_type key) const
00075 { return parameter.find(key); }
00076 parameter_iterator parameter_upper_bound(parameter_type::key_type key) const
00077 { return parameter.upper_bound(key); }
00078
00079 bool operator== (const Contenttype& ct) const
00080 { return type == ct.type
00081 && subtype == ct.subtype
00082 && parameter == ct.parameter
00083 && boundary == ct.boundary; }
00084 };
00085
00086 inline std::istream& operator>> (std::istream& in, Contenttype& ct)
00087 {
00088 ct.parse(in);
00089 return in;
00090 }
00091 }
00092
00093 #endif // TNT_CONTENTTYPE_H
00094