reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
UnknownParameter.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
9
10using namespace resip;
11using namespace std;
12
14 unsigned int nameSize,
15 ParseBuffer& pb,
16 const std::bitset<256>& terminators)
17 : Parameter(ParameterTypes::UNKNOWN),
18 mName(startName, nameSize),
19 mValue(),
20 mIsQuoted(false)
21{
22 pb.skipWhitespace();
23 if (!pb.eof() && *pb.position() == Symbols::EQUALS[0])
24 {
26 pb.skipWhitespace();
27 if (*pb.position() == Symbols::DOUBLE_QUOTE[0])
28 {
29 setQuoted(true);
30 pb.skipChar();
31 const char* pos = pb.position();
32 pb.skipToEndQuote();
33 pb.data(mValue, pos);
34 pb.skipChar();
35 }
36 else
37 {
38 const char* pos = pb.position();
39 pb.skipToOneOf(terminators);
40 pb.data(mValue, pos);
41 }
42
43 }
44 else
45 {
46 // must be a terminator -- exists style
47 }
48}
49
51 : Parameter(ParameterTypes::UNKNOWN),
52 mName(name),
53 mIsQuoted(false)
54{
55}
56
57const Data&
59{
60 return mName;
61}
62
63
66{
67 return new UnknownParameter(*this);
68}
69
71UnknownParameter::encode(EncodeStream& stream) const
72{
73 if (mIsQuoted)
74 {
75 return stream << getName() << Symbols::EQUALS
77 }
78 else if (!mValue.empty())
79 {
80 return stream << getName() << Symbols::EQUALS << mValue;
81 }
82 else
83 {
84 return stream << getName();
85 }
86}
87
88EncodeStream& operator<<(EncodeStream& stream, UnknownParameter& comp)
89{
90 return stream << comp.getName() << "=" << comp.value();
91}
92
93
94/* ====================================================================
95 * The Vovida Software License, Version 1.0
96 *
97 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
98 *
99 * Redistribution and use in source and binary forms, with or without
100 * modification, are permitted provided that the following conditions
101 * are met:
102 *
103 * 1. Redistributions of source code must retain the above copyright
104 * notice, this list of conditions and the following disclaimer.
105 *
106 * 2. Redistributions in binary form must reproduce the above copyright
107 * notice, this list of conditions and the following disclaimer in
108 * the documentation and/or other materials provided with the
109 * distribution.
110 *
111 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
112 * and "Vovida Open Communication Application Library (VOCAL)" must
113 * not be used to endorse or promote products derived from this
114 * software without prior written permission. For written
115 * permission, please contact vocal@vovida.org.
116 *
117 * 4. Products derived from this software may not be called "VOCAL", nor
118 * may "VOCAL" appear in their name, without prior written
119 * permission of Vovida Networks, Inc.
120 *
121 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
122 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
123 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
124 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
125 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
126 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
127 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
128 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
129 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
130 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
131 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
132 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
133 * DAMAGE.
134 *
135 * ====================================================================
136 *
137 * This software consists of voluntary contributions made by Vovida
138 * Networks, Inc. and many individuals on behalf of Vovida Networks,
139 * Inc. For more information on Vovida Networks, Inc., please see
140 * <http://www.vovida.org/>.
141 *
142 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
bool empty() const noexcept
Checks whether the Data is empty.
Definition Data.hxx:591
This is one of the places where new parameter types must be defined.
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipWhitespace()
CurrentPosition position() const
CurrentPosition skipToOneOf(const char *cs)
CurrentPosition skipChar()
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
const char * skipToEndQuote(char quote='"')
static const char * EQUALS
Definition Symbols.hxx:29
static const char * DOUBLE_QUOTE
Definition Symbols.hxx:26
Generically used to represent any parameter that is not known by the implmentation.
UnknownParameter(const char *startName, unsigned int nameSize, ParseBuffer &pb, const std::bitset< 256 > &terminators)
EncodeStream & encode(EncodeStream &stream) const
virtual const Data & getName() const
virtual Parameter * clone() const
dcm! – add UnusedChecking(_enum) below;
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
#define EncodeStream