/[resiprocate]/branches/b-identity-0505/DataParameter.cxx
ViewVC logotype

Contents of /branches/b-identity-0505/DataParameter.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4598 - (show annotations) (download)
Wed May 11 22:53:07 2005 UTC (14 years, 6 months ago) by derek
File size: 4331 byte(s)
set svn:eol-style to LF
1 #if defined(HAVE_CONFIG_H)
2 #include "resiprocate/config.hxx"
3 #endif
4
5 #include <cassert>
6 #include "resiprocate/DataParameter.hxx"
7 #include "resiprocate/Symbols.hxx"
8 #include "resiprocate/os/ParseBuffer.hxx"
9 #include "resiprocate/ParseException.hxx"
10 #include "resiprocate/os/Logger.hxx"
11 #include "resiprocate/os/WinLeakCheck.hxx"
12
13 using namespace resip;
14 using namespace std;
15
16 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP
17
18 DataParameter::DataParameter(ParameterTypes::Type type,
19 ParseBuffer& pb,
20 const char* terminators)
21 : Parameter(type),
22 mValue(),
23 mQuoted(false)
24 {
25 pb.skipWhitespace();
26 pb.skipChar(Symbols::EQUALS[0]);
27 pb.skipWhitespace();
28 if (!pb.eof() && *pb.position() == Symbols::DOUBLE_QUOTE[0])
29 {
30 setQuoted(true);
31 pb.skipChar();
32 const char* pos = pb.position();
33 pb.skipToEndQuote();
34 pb.data(mValue, pos);
35 pb.skipChar();
36 }
37 else
38 {
39 const char* pos = pb.position();
40 pb.skipToOneOf(terminators);
41 pb.data(mValue, pos);
42 }
43 }
44
45 DataParameter::DataParameter(ParameterTypes::Type type)
46 : Parameter(type),
47 mValue(),
48 mQuoted(false)
49 {
50 }
51
52 Parameter*
53 DataParameter::clone() const
54 {
55 return new DataParameter(*this);
56 }
57
58 ostream&
59 DataParameter::encode(ostream& stream) const
60 {
61 if (mQuoted)
62 {
63 return stream << getName() << Symbols::EQUALS
64 << Symbols::DOUBLE_QUOTE << mValue << Symbols::DOUBLE_QUOTE;
65 }
66 else
67 {
68 // this will assert if you've accessed a parameter that doesn't exist and
69 // then the stack has created an empty parameter with no value. Try
70 // calling exists(p_foo) before calling param(p_foo)
71 if (mValue.empty())
72 {
73 ErrLog(<< "Accessing defaulted DataParameter: '" << getName() << "'");
74 }
75 assert(!mValue.empty()); // !jf! probably should throw here
76 return stream << getName() << Symbols::EQUALS << mValue;
77 }
78 }
79
80 /* ====================================================================
81 * The Vovida Software License, Version 1.0
82 *
83 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
84 *
85 * Redistribution and use in source and binary forms, with or without
86 * modification, are permitted provided that the following conditions
87 * are met:
88 *
89 * 1. Redistributions of source code must retain the above copyright
90 * notice, this list of conditions and the following disclaimer.
91 *
92 * 2. Redistributions in binary form must reproduce the above copyright
93 * notice, this list of conditions and the following disclaimer in
94 * the documentation and/or other materials provided with the
95 * distribution.
96 *
97 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
98 * and "Vovida Open Communication Application Library (VOCAL)" must
99 * not be used to endorse or promote products derived from this
100 * software without prior written permission. For written
101 * permission, please contact vocal@vovida.org.
102 *
103 * 4. Products derived from this software may not be called "VOCAL", nor
104 * may "VOCAL" appear in their name, without prior written
105 * permission of Vovida Networks, Inc.
106 *
107 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
108 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
109 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
110 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
111 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
112 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
113 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
114 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
115 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
116 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
117 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
118 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
119 * DAMAGE.
120 *
121 * ====================================================================
122 *
123 * This software consists of voluntary contributions made by Vovida
124 * Networks, Inc. and many individuals on behalf of Vovida Networks,
125 * Inc. For more information on Vovida Networks, Inc., please see
126 * <http://www.vovida.org/>.
127 *
128 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27