reSIProcate/stack  9694
Mime.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_MIME_HXX)
00002 #define RESIP_MIME_HXX 
00003 
00004 #include <iosfwd>
00005 #include "rutil/Data.hxx"
00006 #include "rutil/HashMap.hxx"
00007 #include "resip/stack/ParserCategory.hxx"
00008 #include "resip/stack/ParserContainer.hxx"
00009 
00010 namespace resip
00011 {
00012 
00013 class HeaderFieldValue;
00014 
00019 class Mime : public ParserCategory
00020 {
00021    public:
00022       enum {commaHandling = CommasAllowedOutputCommas};
00023 
00024       Mime();
00025       Mime(const Data& type, const Data& subType);
00026       Mime(const HeaderFieldValue& hfv, 
00027             Headers::Type type,
00028             PoolBase* pool=0);
00029       Mime(const Mime& orig,
00030             PoolBase* pool=0);
00031       Mime& operator=(const Mime&);
00032       bool operator<(const Mime& rhs) const;
00033       bool isEqual(const Mime& rhs) const;
00034       bool operator==(const Mime& rhs) const;
00035       bool operator!=(const Mime& rhs) const;
00036       
00037       const Data& type() const;
00038       const Data& subType() const;
00039       Data& type();
00040       Data& subType();
00041          
00042       virtual void parse(ParseBuffer& pb);
00043       virtual ParserCategory* clone() const;
00044       virtual ParserCategory* clone(void* location) const;
00045       virtual ParserCategory* clone(PoolBase* pool) const;
00046 
00047       virtual EncodeStream& encodeParsed(EncodeStream& str) const;
00048 
00049       // Inform the compiler that overloads of these may be found in
00050       // ParserCategory, too.
00051       using ParserCategory::exists;
00052       using ParserCategory::remove;
00053       using ParserCategory::param;
00054 
00055       virtual Parameter* createParam(ParameterTypes::Type type, ParseBuffer& pb, const std::bitset<256>& terminators, PoolBase* pool);
00056       bool exists(const Param<Mime>& paramType) const;
00057       void remove(const Param<Mime>& paramType);
00058 
00059 #define defineParam(_enum, _name, _type, _RFC_ref_ignored)                      \
00060       const _enum##_Param::DType& param(const _enum##_Param& paramType) const;  \
00061       _enum##_Param::DType& param(const _enum##_Param& paramType); \
00062       friend class _enum##_Param
00063 
00064       defineParam(accessType, "access-type", DataParameter, "RFC 2046");
00065       defineParam(boundary, "boundary", DataParameter, "RFC 2046");
00066       defineParam(charset, "charset", DataParameter, "RFC 2045");
00067       defineParam(directory, "directory", DataParameter, "RFC 2046");
00068       defineParam(expiration, "expiration", QuotedDataParameter, "RFC 2046");
00069       defineParam(micalg, "micalg", DataParameter, "RFC 1847");
00070       defineParam(mode, "mode", DataParameter, "RFC 2046");
00071       defineParam(name, "name", DataParameter, "RFC 2046");
00072       defineParam(permission, "permission", DataParameter, "RFC 2046");
00073       defineParam(protocol, "protocol", QuotedDataParameter, "RFC 1847");
00074       defineParam(q, "q", QValueParameter, "RFC 3261");
00075       defineParam(server, "server", DataParameter, "RFC 2046");
00076       defineParam(site, "site", DataParameter, "RFC 2046");
00077       defineParam(size, "size", DataParameter, "RFC 2046");
00078       defineParam(smimeType, "smime-type", DataParameter, "RFC 2633");
00079       defineParam(url, "url", QuotedDataParameter, "RFC 4483");
00080 
00081 #undef defineParam
00082 
00083    private:
00084       Data mType;
00085       Data mSubType;
00086 
00087       static ParameterTypes::Factory ParameterFactories[ParameterTypes::MAX_PARAMETER];
00088 };
00089 typedef ParserContainer<Mime> Mimes;
00090  
00091 }
00092 
00093 
00094 HashValue(resip::Mime);
00095 
00096 #endif
00097 
00098 /* ====================================================================
00099  * The Vovida Software License, Version 1.0 
00100  * 
00101  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00102  * 
00103  * Redistribution and use in source and binary forms, with or without
00104  * modification, are permitted provided that the following conditions
00105  * are met:
00106  * 
00107  * 1. Redistributions of source code must retain the above copyright
00108  *    notice, this list of conditions and the following disclaimer.
00109  * 
00110  * 2. Redistributions in binary form must reproduce the above copyright
00111  *    notice, this list of conditions and the following disclaimer in
00112  *    the documentation and/or other materials provided with the
00113  *    distribution.
00114  * 
00115  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00116  *    and "Vovida Open Communication Application Library (VOCAL)" must
00117  *    not be used to endorse or promote products derived from this
00118  *    software without prior written permission. For written
00119  *    permission, please contact vocal@vovida.org.
00120  *
00121  * 4. Products derived from this software may not be called "VOCAL", nor
00122  *    may "VOCAL" appear in their name, without prior written
00123  *    permission of Vovida Networks, Inc.
00124  * 
00125  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00126  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00127  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00128  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00129  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00130  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00131  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00132  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00133  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00134  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00135  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00136  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00137  * DAMAGE.
00138  * 
00139  * ====================================================================
00140  * 
00141  * This software consists of voluntary contributions made by Vovida
00142  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00143  * Inc.  For more information on Vovida Networks, Inc., please see
00144  * <http://www.vovida.org/>.
00145  *
00146  */