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

« back to all changes in this revision

Viewing changes to resip/stack/HeaderFieldValueList.hxx

  • 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(RESIP_HEADERFIELDVALUELIST_HXX)
 
2
#define RESIP_HEADERFIELDVALUELIST_HXX 
 
3
 
 
4
#include <iosfwd>
 
5
#include <vector>
 
6
 
 
7
#include "rutil/StlPoolAllocator.hxx"
 
8
#include "rutil/PoolBase.hxx"
 
9
 
 
10
namespace resip
 
11
{
 
12
 
 
13
class Data;
 
14
class ParserContainerBase;
 
15
class HeaderFieldValue;
 
16
 
 
17
/**
 
18
   @internal
 
19
*/
 
20
class HeaderFieldValueList
 
21
{
 
22
   public:
 
23
      static const HeaderFieldValueList Empty;
 
24
 
 
25
      HeaderFieldValueList()
 
26
         : mHeaders(), 
 
27
           mPool(0),
 
28
           mParserContainer(0)
 
29
      {}
 
30
 
 
31
      HeaderFieldValueList(PoolBase& pool)
 
32
         : mHeaders(StlPoolAllocator<HeaderFieldValue, PoolBase>(&pool)),
 
33
           mPool(&pool),
 
34
           mParserContainer(0)
 
35
      {}
 
36
 
 
37
      ~HeaderFieldValueList();
 
38
      HeaderFieldValueList(const HeaderFieldValueList& rhs);
 
39
      HeaderFieldValueList(const HeaderFieldValueList& rhs, PoolBase& pool);
 
40
      HeaderFieldValueList& operator=(const HeaderFieldValueList& rhs);
 
41
      
 
42
      inline void setParserContainer(ParserContainerBase* parser) {mParserContainer = parser;}
 
43
      inline ParserContainerBase* getParserContainer() const {return mParserContainer;}
 
44
 
 
45
      EncodeStream& encode(int headerEnum, EncodeStream& str) const;
 
46
      EncodeStream& encode(const Data& headerName, EncodeStream& str) const;
 
47
      EncodeStream& encodeEmbedded(const Data& headerName, EncodeStream& str) const;
 
48
 
 
49
      bool empty() const {return mHeaders.empty();}
 
50
      size_t size() const {return mHeaders.size();}
 
51
      void clear();
 
52
      //void push_front(HeaderFieldValue* header) {mHeaders.push_front(header);}
 
53
 
 
54
      /**
 
55
         READ THIS CAREFULLY BEFORE USING THIS FUNCTION
 
56
         @param own Specifies whether the created HeaderFieldValue will take 
 
57
            ownership of the buffer passed. This will never make a copy 
 
58
            of the buffer; if own==false, the HeaderFieldValue will retain the 
 
59
            same reference that it would if own==true. The only difference is 
 
60
            that if own==false, the buffer will not be deleted when the 
 
61
            HeaderFieldValue goes away/releases its reference, while if 
 
62
            own==true the buffer will be deleted. This means that no matter what 
 
63
            you pass for this param, you must ensure that the buffer is not 
 
64
            deleted during the lifetime of this HeaderFieldValueList.
 
65
      */
 
66
      void push_back(const char* buffer, size_t length, bool own) 
 
67
      {
 
68
         mHeaders.push_back(HeaderFieldValue::Empty); 
 
69
         mHeaders.back().init(buffer,length,own);
 
70
      }
 
71
 
 
72
      //void pop_front() {mHeaders.pop_front();}
 
73
      void pop_back() {mHeaders.pop_back();};
 
74
      HeaderFieldValue* front() {return &mHeaders.front();}
 
75
      HeaderFieldValue* back() {return &mHeaders.back();}
 
76
      const HeaderFieldValue* front() const {return &mHeaders.front();}
 
77
      const HeaderFieldValue* back() const {return &mHeaders.back();}
 
78
 
 
79
      inline void reserve(size_t size)
 
80
      {
 
81
         mHeaders.reserve(size);
 
82
      }
 
83
 
 
84
      bool parsedEmpty() const;
 
85
   private:
 
86
      typedef std::vector<HeaderFieldValue, StlPoolAllocator<HeaderFieldValue, PoolBase > >  ListImpl;
 
87
   public:
 
88
      typedef ListImpl::iterator iterator;
 
89
      typedef ListImpl::const_iterator const_iterator;
 
90
 
 
91
      iterator begin() {return mHeaders.begin();}
 
92
      iterator end() {return mHeaders.end();}
 
93
      const_iterator begin() const {return mHeaders.begin();}
 
94
      const_iterator end() const {return mHeaders.end();}
 
95
 
 
96
   private:
 
97
      ListImpl mHeaders;
 
98
      PoolBase* mPool;
 
99
      ParserContainerBase* mParserContainer;
 
100
 
 
101
      void freeParserContainer();
 
102
};
 
103
 
 
104
}
 
105
 
 
106
#endif
 
107
 
 
108
/* ====================================================================
 
109
 * The Vovida Software License, Version 1.0 
 
110
 * 
 
111
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
 
112
 * 
 
113
 * Redistribution and use in source and binary forms, with or without
 
114
 * modification, are permitted provided that the following conditions
 
115
 * are met:
 
116
 * 
 
117
 * 1. Redistributions of source code must retain the above copyright
 
118
 *    notice, this list of conditions and the following disclaimer.
 
119
 * 
 
120
 * 2. Redistributions in binary form must reproduce the above copyright
 
121
 *    notice, this list of conditions and the following disclaimer in
 
122
 *    the documentation and/or other materials provided with the
 
123
 *    distribution.
 
124
 * 
 
125
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
 
126
 *    and "Vovida Open Communication Application Library (VOCAL)" must
 
127
 *    not be used to endorse or promote products derived from this
 
128
 *    software without prior written permission. For written
 
129
 *    permission, please contact vocal@vovida.org.
 
130
 *
 
131
 * 4. Products derived from this software may not be called "VOCAL", nor
 
132
 *    may "VOCAL" appear in their name, without prior written
 
133
 *    permission of Vovida Networks, Inc.
 
134
 * 
 
135
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
 
136
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
137
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
 
138
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
 
139
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
 
140
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
 
141
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
142
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
143
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 
144
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
145
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 
146
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 
147
 * DAMAGE.
 
148
 * 
 
149
 * ====================================================================
 
150
 * 
 
151
 * This software consists of voluntary contributions made by Vovida
 
152
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
 
153
 * Inc.  For more information on Vovida Networks, Inc., please see
 
154
 * <http://www.vovida.org/>.
 
155
 *
 
156
 */