/src/resiprocate/resip/stack/TokenOrQuotedStringCategory.hxx
Line | Count | Source |
1 | | #if !defined(RESIP_TOKEN_OR_QUOTED_STRING_CATEGORY_HXX) |
2 | | #define RESIP_TOKEN_OR_QUOTED_STRING_CATEGORY_HXX |
3 | | |
4 | | #include <iosfwd> |
5 | | #include "rutil/Data.hxx" |
6 | | #include "resip/stack/ParserCategory.hxx" |
7 | | #include "resip/stack/ParserContainer.hxx" |
8 | | |
9 | | namespace resip |
10 | | { |
11 | | |
12 | | /** |
13 | | @ingroup sip_grammar |
14 | | @brief Generically represents a token whose value can be |
15 | | wrapped and encoded using double quotes. |
16 | | */ |
17 | | |
18 | | class TokenOrQuotedStringCategory : public ParserCategory |
19 | | { |
20 | | public: |
21 | | static constexpr CommaHandlingMode commaHandling = CommasAllowedOutputCommas; |
22 | | |
23 | | TokenOrQuotedStringCategory(); |
24 | | explicit TokenOrQuotedStringCategory(const Data& value, bool quoted); |
25 | | TokenOrQuotedStringCategory(const HeaderFieldValue& hfv, |
26 | | Headers::Type type, |
27 | | PoolBase* pool = 0); |
28 | | TokenOrQuotedStringCategory(const TokenOrQuotedStringCategory& rhs, |
29 | | PoolBase* pool = 0); |
30 | | TokenOrQuotedStringCategory& operator=(const TokenOrQuotedStringCategory& rhs); |
31 | | |
32 | | virtual ParserCategory* clone() const; |
33 | | virtual ParserCategory* clone(void* location) const; |
34 | | virtual ParserCategory* clone(PoolBase* pool) const; |
35 | | |
36 | | bool isEqual(const TokenOrQuotedStringCategory& rhs) const; |
37 | | bool operator==(const TokenOrQuotedStringCategory& rhs) const; |
38 | | bool operator!=(const TokenOrQuotedStringCategory& rhs) const; |
39 | | bool operator<(const TokenOrQuotedStringCategory& rhs) const; |
40 | | |
41 | | virtual void parse(ParseBuffer& pb); |
42 | | virtual EncodeStream& encodeParsed(EncodeStream& str) const; |
43 | | |
44 | | // Gets the value (ie; no parameters) of this Token as a Data&. |
45 | | const Data& value() const; |
46 | | Data& value(); |
47 | | |
48 | | // mValue will be enclosed in quotes e.g. "foo" |
49 | 0 | bool isQuoted() const { return mQuoted; } |
50 | 0 | void setQuoted(bool b) { mQuoted = b; }; |
51 | | |
52 | | Data quotedValue() const; |
53 | | |
54 | | // Inform the compiler that overloads of these may be found in ParserCategory, too. |
55 | | using ParserCategory::exists; |
56 | | using ParserCategory::remove; |
57 | | using ParserCategory::param; |
58 | | |
59 | | virtual Parameter* createParam(ParameterTypes::Type type, ParseBuffer& pb, const std::bitset<256>& terminators, PoolBase* pool); |
60 | | bool exists(const Param<TokenOrQuotedStringCategory>& paramType) const; |
61 | | void remove(const Param<TokenOrQuotedStringCategory>& paramType); |
62 | | |
63 | | #define defineParam(_enum, _name, _type, _RFC_ref_ignored) \ |
64 | | const _enum##_Param::DType& param(const _enum##_Param& paramType) const; \ |
65 | | _enum##_Param::DType& param(const _enum##_Param& paramType); \ |
66 | | friend class _enum##_Param |
67 | | |
68 | | defineParam(purpose, "purpose", DataParameter, "draft-ietf-cuss-sip-uui-17"); // User-to-User |
69 | | defineParam(content, "content", DataParameter, "draft-ietf-cuss-sip-uui-17"); // User-to-User |
70 | | defineParam(encoding, "encoding", DataParameter, "draft-ietf-cuss-sip-uui-17"); // User-to-User |
71 | | |
72 | | #undef defineParam |
73 | | |
74 | | private: |
75 | | Data mValue; |
76 | | bool mQuoted; |
77 | | |
78 | | static ParameterTypes::Factory ParameterFactories[ParameterTypes::MAX_PARAMETER]; |
79 | | }; |
80 | | |
81 | | typedef ParserContainer<TokenOrQuotedStringCategory> TokenOrQuotedStringCategories; |
82 | | |
83 | | } |
84 | | |
85 | | #endif |
86 | | |
87 | | /* ==================================================================== |
88 | | * The Vovida Software License, Version 1.0 |
89 | | * |
90 | | * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. |
91 | | * |
92 | | * Redistribution and use in source and binary forms, with or without |
93 | | * modification, are permitted provided that the following conditions |
94 | | * are met: |
95 | | * |
96 | | * 1. Redistributions of source code must retain the above copyright |
97 | | * notice, this list of conditions and the following disclaimer. |
98 | | * |
99 | | * 2. Redistributions in binary form must reproduce the above copyright |
100 | | * notice, this list of conditions and the following disclaimer in |
101 | | * the documentation and/or other materials provided with the |
102 | | * distribution. |
103 | | * |
104 | | * 3. The names "VOCAL", "Vovida Open Communication Application Library", |
105 | | * and "Vovida Open Communication Application Library (VOCAL)" must |
106 | | * not be used to endorse or promote products derived from this |
107 | | * software without prior written permission. For written |
108 | | * permission, please contact vocal@vovida.org. |
109 | | * |
110 | | * 4. Products derived from this software may not be called "VOCAL", nor |
111 | | * may "VOCAL" appear in their name, without prior written |
112 | | * permission of Vovida Networks, Inc. |
113 | | * |
114 | | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
115 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
116 | | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
117 | | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA |
118 | | * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES |
119 | | * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, |
120 | | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
121 | | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
122 | | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
123 | | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
124 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
125 | | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
126 | | * DAMAGE. |
127 | | * |
128 | | * ==================================================================== |
129 | | * |
130 | | * This software consists of voluntary contributions made by Vovida |
131 | | * Networks, Inc. and many individuals on behalf of Vovida Networks, |
132 | | * Inc. For more information on Vovida Networks, Inc., please see |
133 | | * <http://www.vovida.org/>. |
134 | | * |
135 | | */ |