reSIProcate/stack  9694
Token.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_TOKEN_HXX)
00002 #define RESIP_TOKEN_HXX 
00003 
00004 #include <iosfwd>
00005 #include "rutil/Data.hxx"
00006 #include "resip/stack/ParserCategory.hxx"
00007 #include "resip/stack/ParserContainer.hxx"
00008 
00009 namespace resip
00010 {
00011 
00012 
00017 class Token : public ParserCategory
00018 {
00019    public:
00020       enum {commaHandling = CommasAllowedOutputCommas};
00021 
00022       Token();
00023       explicit Token(const Data& d);
00024       Token(const HeaderFieldValue& hfv, 
00025             Headers::Type type,
00026             PoolBase* pool=0);
00027       Token(const Token& orig,
00028             PoolBase* pool=0);
00029       Token& operator=(const Token&);
00030       bool isEqual(const Token& rhs) const;
00031       bool operator==(const Token& rhs) const;
00032       bool operator!=(const Token& rhs) const;
00033       bool operator<(const Token& rhs) const;
00034 
00038       const Data& value() const;
00039       Data& value();
00040 
00041       virtual void parse(ParseBuffer& pb); // remember to call parseParameters()
00042       virtual ParserCategory* clone() const;
00043       virtual ParserCategory* clone(void* location) const;
00044       virtual ParserCategory* clone(PoolBase* pool) const;
00045 
00046       virtual EncodeStream& encodeParsed(EncodeStream& str) const;
00047 
00048       // Inform the compiler that overloads of these may be found in
00049       // ParserCategory, too.
00050       using ParserCategory::exists;
00051       using ParserCategory::remove;
00052       using ParserCategory::param;
00053 
00054       virtual Parameter* createParam(ParameterTypes::Type type, ParseBuffer& pb, const std::bitset<256>& terminators, PoolBase* pool);
00055       bool exists(const Param<Token>& paramType) const;
00056       void remove(const Param<Token>& paramType);
00057 
00058 #define defineParam(_enum, _name, _type, _RFC_ref_ignored)                      \
00059       const _enum##_Param::DType& param(const _enum##_Param& paramType) const;  \
00060       _enum##_Param::DType& param(const _enum##_Param& paramType); \
00061       friend class _enum##_Param
00062 
00063       defineParam(text, "text", ExistsOrDataParameter, "RFC 3840");
00064       defineParam(dAlg, "d-alg", DataParameter, "RFC 3329");
00065       defineParam(dQop, "d-qop", DataParameter, "RFC 3329");
00066       defineParam(dVer, "d-ver", QuotedDataParameter, "RFC 3329");
00067       defineParam(expires, "expires", UInt32Parameter, "RFC 3261");
00068       defineParam(filename, "filename", DataParameter, "RFC 2183");
00069       defineParam(fromTag, "from-tag", DataParameter, "RFC 4235");
00070       defineParam(handling, "handling", DataParameter, "RFC 3261");
00071       defineParam(id, "id", DataParameter, "RFC 3265");
00072       defineParam(q, "q", QValueParameter, "RFC 3261");
00073       defineParam(reason, "reason", DataParameter, "RFC 3265");
00074       defineParam(retryAfter, "retry-after", UInt32Parameter, "RFC 3265");
00075       defineParam(toTag, "to-tag", DataParameter, "RFC 4235");
00076       defineParam(extension, "ext", DataParameter, "RFC 3966"); // Token is used when ext is a user-parameter
00077       defineParam(profileType, "profile-type", DataParameter, "RFC 6080");
00078       defineParam(vendor, "vendor", QuotedDataParameter, "RFC 6080");
00079       defineParam(model, "model", QuotedDataParameter, "RFC 6080");
00080       defineParam(version, "version", QuotedDataParameter, "RFC 6080");
00081       defineParam(effectiveBy, "effective-by", UInt32Parameter, "RFC 6080");
00082       defineParam(document, "document", DataParameter, "draft-ietf-sipping-config-framework-07 (removed in 08)");
00083       defineParam(appId, "app-id", DataParameter, "draft-ietf-sipping-config-framework-05 (renamed to auid in 06, which was then removed in 08)");
00084       defineParam(networkUser, "network-user", DataParameter, "draft-ietf-sipping-config-framework-11 (removed in 12)");
00085       defineParam(require, "require", DataParameter, "RFC 5373");
00086 
00087 #undef defineParam
00088 
00089    private:
00090       Data mValue;
00091 
00092       static ParameterTypes::Factory ParameterFactories[ParameterTypes::MAX_PARAMETER];
00093 };
00094 typedef ParserContainer<Token> Tokens;
00095  
00096 }
00097 
00098 #endif
00099 
00100 /* ====================================================================
00101  * The Vovida Software License, Version 1.0 
00102  * 
00103  * Copyright (c) 2000-2005 Vovida Networks, Inc.  All rights reserved.
00104  * 
00105  * Redistribution and use in source and binary forms, with or without
00106  * modification, are permitted provided that the following conditions
00107  * are met:
00108  * 
00109  * 1. Redistributions of source code must retain the above copyright
00110  *    notice, this list of conditions and the following disclaimer.
00111  * 
00112  * 2. Redistributions in binary form must reproduce the above copyright
00113  *    notice, this list of conditions and the following disclaimer in
00114  *    the documentation and/or other materials provided with the
00115  *    distribution.
00116  * 
00117  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00118  *    and "Vovida Open Communication Application Library (VOCAL)" must
00119  *    not be used to endorse or promote products derived from this
00120  *    software without prior written permission. For written
00121  *    permission, please contact vocal@vovida.org.
00122  *
00123  * 4. Products derived from this software may not be called "VOCAL", nor
00124  *    may "VOCAL" appear in their name, without prior written
00125  *    permission of Vovida Networks, Inc.
00126  * 
00127  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00128  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00129  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00130  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00131  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00132  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00133  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00134  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00135  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00136  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00137  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00138  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00139  * DAMAGE.
00140  * 
00141  * ====================================================================
00142  * 
00143  * This software consists of voluntary contributions made by Vovida
00144  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00145  * Inc.  For more information on Vovida Networks, Inc., please see
00146  * <http://www.vovida.org/>.
00147  *
00148  */