/src/resiprocate/resip/stack/PlainContents.cxx
Line | Count | Source (jump to first uncovered line) |
1 | | #if defined(HAVE_CONFIG_H) |
2 | | #include "config.h" |
3 | | #endif |
4 | | |
5 | | #include "resip/stack/PlainContents.hxx" |
6 | | #include "resip/stack/SipMessage.hxx" |
7 | | #include "rutil/Logger.hxx" |
8 | | #include "rutil/ParseBuffer.hxx" |
9 | | #include "rutil/WinLeakCheck.hxx" |
10 | | |
11 | | using namespace resip; |
12 | | using namespace std; |
13 | | |
14 | | #define RESIPROCATE_SUBSYSTEM Subsystem::SIP |
15 | | |
16 | | const PlainContents PlainContents::Empty; |
17 | | static bool invokePlainContentsInit = PlainContents::init(); |
18 | | |
19 | | |
20 | | bool |
21 | | PlainContents::init() |
22 | 6 | { |
23 | 6 | static ContentsFactory<PlainContents> factory; |
24 | 6 | (void)factory; |
25 | 6 | return true; |
26 | 6 | } |
27 | | |
28 | | |
29 | | PlainContents::PlainContents() |
30 | | : Contents(getStaticType()), |
31 | | mText() |
32 | 2 | {} |
33 | | |
34 | | PlainContents::PlainContents(const Data& txt) |
35 | | : Contents(getStaticType()), |
36 | | mText(txt) |
37 | 0 | {} |
38 | | |
39 | | PlainContents::PlainContents(const HeaderFieldValue& hfv, const Mime& contentsType) |
40 | | : Contents(hfv, contentsType), |
41 | | mText() |
42 | 6.52k | { |
43 | 6.52k | } |
44 | | |
45 | | PlainContents::PlainContents(const Data& txt, const Mime& contentsType) |
46 | | : Contents(contentsType), |
47 | | mText(txt) |
48 | 0 | { |
49 | 0 | } |
50 | | |
51 | | PlainContents::PlainContents(const PlainContents& rhs) |
52 | | : Contents(rhs), |
53 | | mText(rhs.mText) |
54 | 0 | { |
55 | 0 | } |
56 | | |
57 | | PlainContents::~PlainContents() |
58 | 6.52k | { |
59 | 6.52k | } |
60 | | |
61 | | PlainContents& |
62 | | PlainContents::operator=(const PlainContents& rhs) |
63 | 0 | { |
64 | 0 | if (this != &rhs) |
65 | 0 | { |
66 | 0 | Contents::operator=(rhs); |
67 | 0 | mText = rhs.mText; |
68 | 0 | } |
69 | 0 | return *this; |
70 | 0 | } |
71 | | |
72 | | Contents* |
73 | | PlainContents::clone() const |
74 | 0 | { |
75 | 0 | return new PlainContents(*this); |
76 | 0 | } |
77 | | |
78 | | const Mime& |
79 | | PlainContents::getStaticType() |
80 | 4 | { |
81 | 4 | static Mime type("text","plain"); |
82 | 4 | return type; |
83 | 4 | } |
84 | | |
85 | | EncodeStream& |
86 | | PlainContents::encodeParsed(EncodeStream& str) const |
87 | 0 | { |
88 | | //DebugLog(<< "PlainContents::encodeParsed " << mText); |
89 | 0 | str << mText; |
90 | 0 | return str; |
91 | 0 | } |
92 | | |
93 | | void |
94 | | PlainContents::parse(ParseBuffer& pb) |
95 | 6.52k | { |
96 | | //DebugLog(<< "PlainContents::parse: " << pb.position()); |
97 | | |
98 | 6.52k | const char* anchor = pb.position(); |
99 | 6.52k | pb.skipToEnd(); |
100 | 6.52k | pb.data(mText, anchor); |
101 | | |
102 | | //DebugLog("PlainContents::parsed <" << mText << ">" ); |
103 | 6.52k | } |
104 | | |
105 | | |
106 | | /* ==================================================================== |
107 | | * The Vovida Software License, Version 1.0 |
108 | | * |
109 | | * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. |
110 | | * |
111 | | * Redistribution and use in source and binary forms, with or without |
112 | | * modification, are permitted provided that the following conditions |
113 | | * are met: |
114 | | * |
115 | | * 1. Redistributions of source code must retain the above copyright |
116 | | * notice, this list of conditions and the following disclaimer. |
117 | | * |
118 | | * 2. Redistributions in binary form must reproduce the above copyright |
119 | | * notice, this list of conditions and the following disclaimer in |
120 | | * the documentation and/or other materials provided with the |
121 | | * distribution. |
122 | | * |
123 | | * 3. The names "VOCAL", "Vovida Open Communication Application Library", |
124 | | * and "Vovida Open Communication Application Library (VOCAL)" must |
125 | | * not be used to endorse or promote products derived from this |
126 | | * software without prior written permission. For written |
127 | | * permission, please contact vocal@vovida.org. |
128 | | * |
129 | | * 4. Products derived from this software may not be called "VOCAL", nor |
130 | | * may "VOCAL" appear in their name, without prior written |
131 | | * permission of Vovida Networks, Inc. |
132 | | * |
133 | | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
134 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
135 | | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
136 | | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA |
137 | | * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES |
138 | | * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, |
139 | | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
140 | | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
141 | | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
142 | | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
143 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
144 | | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
145 | | * DAMAGE. |
146 | | * |
147 | | * ==================================================================== |
148 | | * |
149 | | * This software consists of voluntary contributions made by Vovida |
150 | | * Networks, Inc. and many individuals on behalf of Vovida Networks, |
151 | | * Inc. For more information on Vovida Networks, Inc., please see |
152 | | * <http://www.vovida.org/>. |
153 | | * |
154 | | */ |