~ubuntu-branches/ubuntu/saucy/resiprocate/saucy-proposed

« back to all changes in this revision

Viewing changes to resip/stack/UnknownParameter.cxx

  • Committer: Package Import Robot
  • Author(s): Daniel Pocock
  • Date: 2012-05-17 19:29:59 UTC
  • Revision ID: package-import@ubuntu.com-20120517192959-vv00m77isztdy64q
Tags: upstream-1.8.2
ImportĀ upstreamĀ versionĀ 1.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#if defined(HAVE_CONFIG_H)
 
2
#include "config.h"
 
3
#endif
 
4
 
 
5
#include "resip/stack/UnknownParameter.hxx"
 
6
#include "rutil/ParseBuffer.hxx"
 
7
#include "resip/stack/Symbols.hxx"
 
8
#include "rutil/WinLeakCheck.hxx"
 
9
 
 
10
using namespace resip;
 
11
using namespace std;
 
12
 
 
13
UnknownParameter::UnknownParameter(const char* startName, 
 
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
   {
 
25
      pb.skipChar(Symbols::EQUALS[0]);
 
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
 
 
50
UnknownParameter::UnknownParameter(const Data& name)
 
51
   : Parameter(ParameterTypes::UNKNOWN),
 
52
     mName(name),
 
53
     mIsQuoted(false)
 
54
{
 
55
}
 
56
 
 
57
const Data& 
 
58
UnknownParameter::getName() const
 
59
{
 
60
   return mName;
 
61
}
 
62
 
 
63
 
 
64
Parameter* 
 
65
UnknownParameter::clone() const
 
66
{
 
67
   return new UnknownParameter(*this);
 
68
}
 
69
 
 
70
EncodeStream&
 
71
UnknownParameter::encode(EncodeStream& stream) const
 
72
{
 
73
   if (mIsQuoted)
 
74
   {
 
75
      return stream << getName() << Symbols::EQUALS 
 
76
                    << Symbols::DOUBLE_QUOTE << mValue << Symbols::DOUBLE_QUOTE;
 
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
 
 
88
EncodeStream& 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
 */