/[resiprocate]/main/sip/resiprocate/Mime.cxx
ViewVC logotype

Contents of /main/sip/resiprocate/Mime.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4599 - (show annotations) (download)
Wed May 11 23:10:19 2005 UTC (14 years, 7 months ago) by derek
File size: 5075 byte(s)
set svn:eol-style to LF
1 #if defined(HAVE_CONFIG_H)
2 #include "resiprocate/config.hxx"
3 #endif
4
5 #include "resiprocate/Mime.hxx"
6 #include "resiprocate/os/Data.hxx"
7 #include "resiprocate/os/DnsUtil.hxx"
8 #include "resiprocate/os/Logger.hxx"
9 #include "resiprocate/os/ParseBuffer.hxx"
10 #include "resiprocate/os/WinLeakCheck.hxx"
11
12 using namespace resip;
13 using namespace std;
14
15 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP
16
17 //====================
18 // MIME
19 //====================
20 Mime::Mime()
21 : ParserCategory(),
22 mType(),
23 mSubType()
24 {}
25
26 Mime::Mime(const Data& type, const Data& subType)
27 : ParserCategory(),
28 mType(type),
29 mSubType(subType)
30 {}
31
32 Mime::Mime(HeaderFieldValue* hfv, Headers::Type type)
33 : ParserCategory(hfv, type),
34 mType(),
35 mSubType()
36 {}
37
38 Mime::Mime(const Mime& rhs)
39 : ParserCategory(rhs),
40 mType(rhs.mType),
41 mSubType(rhs.mSubType)
42 {}
43
44 Mime&
45 Mime::operator=(const Mime& rhs)
46 {
47 if (this != &rhs)
48 {
49 ParserCategory::operator=(rhs);
50 mType = rhs.mType;
51 mSubType = rhs.mSubType;
52 }
53 return *this;
54 }
55
56 bool
57 Mime::operator<(const Mime& rhs) const
58 {
59 if (isLessThanNoCase(type(), rhs.type()))
60 {
61 return true;
62 }
63 else if (isLessThanNoCase(rhs.type(), type()))
64 {
65 return false;
66 }
67 return isLessThanNoCase(subType(), rhs.subType());
68 }
69
70 bool
71 Mime::operator==(const Mime& rhs) const
72 {
73 return (isEqualNoCase(type(), rhs.type()) &&
74 isEqualNoCase(subType(), rhs.subType()));
75 }
76
77 bool
78 Mime::operator!=(const Mime& rhs) const
79 {
80 return !(*this == rhs);
81 }
82
83 Data&
84 Mime::type() const
85 {
86 checkParsed();
87 return mType;
88 }
89
90 Data& Mime::subType() const
91 {
92 checkParsed();
93 return mSubType;
94 }
95
96 void
97 Mime::parse(ParseBuffer& pb)
98 {
99 const char* anchor = pb.skipWhitespace();
100
101 pb.skipToOneOf(ParseBuffer::Whitespace, Symbols::SLASH);
102 pb.data(mType, anchor);
103
104 pb.skipWhitespace();
105 pb.skipChar(Symbols::SLASH[0]);
106
107 anchor = pb.skipWhitespace();
108 pb.skipToOneOf(ParseBuffer::Whitespace, Symbols::SEMI_COLON);
109 pb.data(mSubType, anchor);
110
111 pb.skipWhitespace();
112 parseParameters(pb);
113 }
114
115 ParserCategory*
116 Mime::clone() const
117 {
118 return new Mime(*this);
119 }
120
121 std::ostream&
122 Mime::encodeParsed(std::ostream& str) const
123 {
124 str << mType << Symbols::SLASH << mSubType ;
125 encodeParameters(str);
126 return str;
127 }
128
129 #if defined(HASH_MAP_NAMESPACE)
130 size_t HASH_MAP_NAMESPACE::hash<resip::Mime>::operator()(const resip::Mime& data) const
131 {
132 return data.type().caseInsensitivehash() ^ data.subType().caseInsensitivehash();
133 }
134 #endif
135
136 #if defined(__INTEL_COMPILER)
137 size_t std::hash_value(const resip::Mime& data)
138 {
139 return data.type().caseInsensitivehash() ^ data.subType().caseInsensitivehash();
140 }
141 #endif
142
143
144 /* ====================================================================
145 * The Vovida Software License, Version 1.0
146 *
147 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
148 *
149 * Redistribution and use in source and binary forms, with or without
150 * modification, are permitted provided that the following conditions
151 * are met:
152 *
153 * 1. Redistributions of source code must retain the above copyright
154 * notice, this list of conditions and the following disclaimer.
155 *
156 * 2. Redistributions in binary form must reproduce the above copyright
157 * notice, this list of conditions and the following disclaimer in
158 * the documentation and/or other materials provided with the
159 * distribution.
160 *
161 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
162 * and "Vovida Open Communication Application Library (VOCAL)" must
163 * not be used to endorse or promote products derived from this
164 * software without prior written permission. For written
165 * permission, please contact vocal@vovida.org.
166 *
167 * 4. Products derived from this software may not be called "VOCAL", nor
168 * may "VOCAL" appear in their name, without prior written
169 * permission of Vovida Networks, Inc.
170 *
171 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
172 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
173 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
174 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
175 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
176 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
177 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
178 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
179 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
180 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
181 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
182 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
183 * DAMAGE.
184 *
185 * ====================================================================
186 *
187 * This software consists of voluntary contributions made by Vovida
188 * Networks, Inc. and many individuals on behalf of Vovida Networks,
189 * Inc. For more information on Vovida Networks, Inc., please see
190 * <http://www.vovida.org/>.
191 *
192 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27