reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Contents.hxx
Go to the documentation of this file.
1#ifndef RESIP_Contents_hxx
2#define RESIP_Contents_hxx
3
4#include <iosfwd>
5#include <vector>
6
12#include "rutil/Data.hxx"
14
15namespace resip
16{
17
18class Token;
19class Contents;
20class HeaderFieldValue;
21class ParseBuffer;
22
25{
26};
27
30{
31 public:
32 typedef Token Type;
33};
35
38{
39 public:
41};
43
44
50class Contents : public LazyParser
51{
52 public:
54 Contents(const HeaderFieldValue& headerFieldValue, const Mime& contentsType);
59 Contents(const Mime& contentsType);
64 Contents(const Contents& rhs);
74 Contents(const HeaderFieldValue& headerFieldValue,
76 const Mime& contentsType);
77 virtual ~Contents();
83 Contents& operator=(const Contents& rhs);
95
100 virtual Contents* getContents() {return this;}
101
107
108 virtual Data getBodyData() const;
109
113 virtual Contents* clone() const = 0;
118 const Mime& getType() const {return mType;}
129 static Contents* createContents(const Mime& contentType,
130 const Data& contents);
136 bool exists(const HeaderBase& headerType) const;
141 void remove(const HeaderBase& headerType);
147 bool exists(const MIME_Header& headerType) const;
152 void remove(const MIME_Header& headerType);
153
154 // !dlb! break into const and non-const -- throw on const if not exists
155 // !dlb! requires a nested exception...
156
157 // shared header types
168 const H_ContentType::Type& header(const H_ContentType& headerType) const;
178 H_ContentType::Type& header(const H_ContentType& headerType);
179
188 const H_ContentDisposition::Type& header(const H_ContentDisposition& headerType) const;
196 H_ContentDisposition::Type& header(const H_ContentDisposition& headerType);
197
206 const H_ContentTransferEncoding::Type& header(const H_ContentTransferEncoding& headerType) const;
214 H_ContentTransferEncoding::Type& header(const H_ContentTransferEncoding& headerType);
215
224 const H_ContentLanguages::Type& header(const H_ContentLanguages& headerType) const;
232 H_ContentLanguages::Type& header(const H_ContentLanguages& headerType);
233
234 // MIME specific header types
243 const H_ContentID::Type& header(const H_ContentID& headerType) const;
251 H_ContentID::Type& header(const H_ContentID& headerType);
252
261 const H_ContentDescription::Type& header(const H_ContentDescription& headerType) const;
270
275 int& version() {return mVersion;}
285 void addBuffer(char* buf);
286
287 protected:
288
294 inline void clear()
295 {
296 freeMem();
297 init();
298 }
299
301 inline void init()
302 {
303 mBufferList.clear();
304 mDisposition = 0;
306 mLanguages = 0;
307 mId = 0;
308 mDescription = 0;
309 mLength = 0;
310 mVersion = 1;
311 mMinorVersion = 0;
312 }
314 void init(const Contents& orig);
315
316 // !bwc! Just frees up heap-allocated stuff, doesn't set pointers to 0
317 // This exists because it is pointless (and inefficient) to revert
318 // members to a default state while deleting (they're just going to go
319 // out of scope anyway) The d'tor is the only thing that uses this by
320 // itself. Everything else should use clear()
322 inline void freeMem()
323 {
324 delete mDisposition;
325 delete mTransferEncoding;
326 delete mLanguages;
327 delete mId;
328 delete mDescription;
329 delete mLength;
330
331 for (std::vector<char*>::iterator i = mBufferList.begin();
332 i != mBufferList.end(); i++)
333 {
334 delete [] *i;
335 }
336
337 }
339 virtual const Data& errorContext() const;
340
344 H_ContentDisposition::Type *mDisposition;
346 H_ContentTransferEncoding::Type *mTransferEncoding;
348 H_ContentLanguages::Type *mLanguages;
355
360
361 std::vector<char*> mBufferList;
362};
363
364bool operator==(const Contents& lhs, const Contents& rhs);
365bool operator!=(const Contents& lhs, const Contents& rhs);
366
367}
368
369#endif
370
371/* ====================================================================
372 * The Vovida Software License, Version 1.0
373 *
374 * Copyright (c) 2000-2005
375 *
376 * Redistribution and use in source and binary forms, with or without
377 * modification, are permitted provided that the following conditions
378 * are met:
379 *
380 * 1. Redistributions of source code must retain the above copyright
381 * notice, this list of conditions and the following disclaimer.
382 *
383 * 2. Redistributions in binary form must reproduce the above copyright
384 * notice, this list of conditions and the following disclaimer in
385 * the documentation and/or other materials provided with the
386 * distribution.
387 *
388 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
389 * and "Vovida Open Communication Application Library (VOCAL)" must
390 * not be used to endorse or promote products derived from this
391 * software without prior written permission. For written
392 * permission, please contact vocal@vovida.org.
393 *
394 * 4. Products derived from this software may not be called "VOCAL", nor
395 * may "VOCAL" appear in their name, without prior written
396 * permission of Vovida Networks, Inc.
397 *
398 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
399 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
400 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
401 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
402 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
403 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
404 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
405 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
406 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
407 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
408 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
409 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
410 * DAMAGE.
411 *
412 * ====================================================================
413 *
414 * This software consists of voluntary contributions made by Vovida
415 * Networks, Inc. and many individuals on behalf of Vovida Networks,
416 * Inc. For more information on Vovida Networks, Inc., please see
417 * <http://www.vovida.org/>.
418 *
419 */
Base class for all SIP body types.
Definition Contents.hxx:51
void addBuffer(char *buf)
Definition Contents.cxx:668
bool exists(const HeaderBase &headerType) const
checks to see if a header is present
Definition Contents.cxx:189
virtual Data getBodyData() const
Definition Contents.cxx:661
virtual ~Contents()
Definition Contents.cxx:58
int & version()
returns the major version of MIME used by the contents
Definition Contents.hxx:275
virtual Contents * getContents()
access to wrapped contents (signed, encrypted)
Definition Contents.hxx:100
H_ContentDescription::Type * mDescription
Definition Contents.hxx:352
std::vector< char * > mBufferList
Definition Contents.hxx:361
const H_ContentType::Type & header(const H_ContentType &headerType) const
returns the value of the Content-Type header Throws an Contents::Exception if the header doesn't exis...
Definition Contents.cxx:280
EncodeStream & encodeHeaders(EncodeStream &str) const
encodes headers to an output stream
Definition Contents.cxx:588
Contents & operator=(const Contents &rhs)
Assignment operator.
Definition Contents.cxx:71
const Mime & getType() const
getter for mime type of message
Definition Contents.hxx:118
H_ContentLanguages::Type * mLanguages
Definition Contents.hxx:348
static Contents * createContents(const Mime &contentType, const Data &contents)
factory method to create a Contents object from a mime type and a payload
Definition Contents.cxx:148
H_ContentTransferEncoding::Type * mTransferEncoding
Definition Contents.hxx:346
void preParseHeaders(ParseBuffer &pb)
Preforms preparsing on the headers stored in the ParseBuffer pb.
Definition Contents.cxx:453
H_ContentDisposition::Type * mDisposition
Definition Contents.hxx:344
StringCategory * mLength
Definition Contents.hxx:354
Contents * getContents(const Mime &)
void remove(const HeaderBase &headerType)
removes a header if it is present
Definition Contents.cxx:232
int & minorVersion()
returns the minor version of MIME used by the contents
Definition Contents.hxx:280
virtual Contents * clone() const =0
returns a copy of a Contents object
virtual const Data & errorContext() const
Definition Contents.cxx:65
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Content-ID MIME header identifier class.
Definition Contents.hxx:38
Content-ID MIME header identifier class.
Definition Contents.hxx:30
The base-class for all lazily-parsed SIP grammar elements.
friend class Contents
MIME header identifier base class.
Definition Contents.hxx:25
Represents the "media-type" element in the RFC 3261 grammar.
Definition Mime.hxx:20
Provides string-parsing functionality with protection from buffer overflow.
Represents the "header-value" element in the RFC 3261 grammar (ie, an unknown header field value).
Represents the "token" element in the RFC 3261 grammar.
Definition Token.hxx:18
dcm! – add UnusedChecking(_enum) below;
H_ContentDescription h_ContentDescription
Definition Contents.cxx:20
H_ContentID h_ContentID
Definition Contents.cxx:19
bool operator==(const char *lhs, const Data &rhs)
Definition Data.hxx:1197
bool operator!=(const Data &lhs, const Data &rhs)
Definition Data.hxx:1187
#define EncodeStream