1 |
#if defined(HAVE_CONFIG_H) |
2 |
#include "resiprocate/config.hxx" |
3 |
#endif |
4 |
|
5 |
#include "resiprocate/IntegerParameter.hxx" |
6 |
#include "resiprocate/Symbols.hxx" |
7 |
#include "resiprocate/os/ParseBuffer.hxx" |
8 |
#include "resiprocate/os/WinLeakCheck.hxx" |
9 |
|
10 |
using namespace resip; |
11 |
using namespace std; |
12 |
|
13 |
IntegerParameter::IntegerParameter(ParameterTypes::Type type, |
14 |
ParseBuffer& pb, |
15 |
const char* terminators) |
16 |
: Parameter(type), |
17 |
mValue(0) |
18 |
{ |
19 |
pb.skipWhitespace(); |
20 |
pb.skipChar(Symbols::EQUALS[0]); |
21 |
pb.skipWhitespace(); |
22 |
|
23 |
// hack to allow expires to have an 2543 style quoted Date |
24 |
if (type == ParameterTypes::expires) |
25 |
{ |
26 |
try |
27 |
{ |
28 |
mValue = pb.integer(); |
29 |
} |
30 |
catch (ParseBuffer::Exception&) |
31 |
{ |
32 |
mValue = 3600; |
33 |
pb.skipToOneOf(ParseBuffer::ParamTerm); |
34 |
} |
35 |
} |
36 |
else |
37 |
{ |
38 |
mValue = pb.integer(); |
39 |
} |
40 |
} |
41 |
|
42 |
IntegerParameter::IntegerParameter(ParameterTypes::Type type, int value) |
43 |
: Parameter(type), |
44 |
mValue(value) |
45 |
{} |
46 |
|
47 |
Parameter* |
48 |
IntegerParameter::clone() const |
49 |
{ |
50 |
return new IntegerParameter(*this); |
51 |
} |
52 |
|
53 |
ostream& |
54 |
IntegerParameter::encode(ostream& stream) const |
55 |
{ |
56 |
return stream << getName() << Symbols::EQUALS << mValue; |
57 |
} |
58 |
|
59 |
|
60 |
/* ==================================================================== |
61 |
* The Vovida Software License, Version 1.0 |
62 |
* |
63 |
* Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. |
64 |
* |
65 |
* Redistribution and use in source and binary forms, with or without |
66 |
* modification, are permitted provided that the following conditions |
67 |
* are met: |
68 |
* |
69 |
* 1. Redistributions of source code must retain the above copyright |
70 |
* notice, this list of conditions and the following disclaimer. |
71 |
* |
72 |
* 2. Redistributions in binary form must reproduce the above copyright |
73 |
* notice, this list of conditions and the following disclaimer in |
74 |
* the documentation and/or other materials provided with the |
75 |
* distribution. |
76 |
* |
77 |
* 3. The names "VOCAL", "Vovida Open Communication Application Library", |
78 |
* and "Vovida Open Communication Application Library (VOCAL)" must |
79 |
* not be used to endorse or promote products derived from this |
80 |
* software without prior written permission. For written |
81 |
* permission, please contact vocal@vovida.org. |
82 |
* |
83 |
* 4. Products derived from this software may not be called "VOCAL", nor |
84 |
* may "VOCAL" appear in their name, without prior written |
85 |
* permission of Vovida Networks, Inc. |
86 |
* |
87 |
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
88 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
89 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
90 |
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA |
91 |
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES |
92 |
* IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, |
93 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
94 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
95 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
96 |
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
97 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
98 |
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
99 |
* DAMAGE. |
100 |
* |
101 |
* ==================================================================== |
102 |
* |
103 |
* This software consists of voluntary contributions made by Vovida |
104 |
* Networks, Inc. and many individuals on behalf of Vovida Networks, |
105 |
* Inc. For more information on Vovida Networks, Inc., please see |
106 |
* <http://www.vovida.org/>. |
107 |
* |
108 |
*/ |