reSIProcate/stack  9694
HeaderFieldValueList.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_HEADERFIELDVALUELIST_HXX)
00002 #define RESIP_HEADERFIELDVALUELIST_HXX 
00003 
00004 #include <iosfwd>
00005 #include <vector>
00006 
00007 #include "rutil/StlPoolAllocator.hxx"
00008 #include "rutil/PoolBase.hxx"
00009 
00010 namespace resip
00011 {
00012 
00013 class Data;
00014 class ParserContainerBase;
00015 class HeaderFieldValue;
00016 
00020 class HeaderFieldValueList
00021 {
00022    public:
00023       static const HeaderFieldValueList Empty;
00024 
00025       HeaderFieldValueList()
00026          : mHeaders(), 
00027            mPool(0),
00028            mParserContainer(0)
00029       {}
00030 
00031       HeaderFieldValueList(PoolBase& pool)
00032          : mHeaders(StlPoolAllocator<HeaderFieldValue, PoolBase>(&pool)),
00033            mPool(&pool),
00034            mParserContainer(0)
00035       {}
00036 
00037       ~HeaderFieldValueList();
00038       HeaderFieldValueList(const HeaderFieldValueList& rhs);
00039       HeaderFieldValueList(const HeaderFieldValueList& rhs, PoolBase& pool);
00040       HeaderFieldValueList& operator=(const HeaderFieldValueList& rhs);
00041       
00042       inline void setParserContainer(ParserContainerBase* parser) {mParserContainer = parser;}
00043       inline ParserContainerBase* getParserContainer() const {return mParserContainer;}
00044 
00045       EncodeStream& encode(int headerEnum, EncodeStream& str) const;
00046       EncodeStream& encode(const Data& headerName, EncodeStream& str) const;
00047       EncodeStream& encodeEmbedded(const Data& headerName, EncodeStream& str) const;
00048 
00049       bool empty() const {return mHeaders.empty();}
00050       size_t size() const {return mHeaders.size();}
00051       void clear();
00052       //void push_front(HeaderFieldValue* header) {mHeaders.push_front(header);}
00053 
00066       void push_back(const char* buffer, size_t length, bool own) 
00067       {
00068          mHeaders.push_back(HeaderFieldValue::Empty); 
00069          mHeaders.back().init(buffer,length,own);
00070       }
00071 
00072       //void pop_front() {mHeaders.pop_front();}
00073       void pop_back() {mHeaders.pop_back();};
00074       HeaderFieldValue* front() {return &mHeaders.front();}
00075       HeaderFieldValue* back() {return &mHeaders.back();}
00076       const HeaderFieldValue* front() const {return &mHeaders.front();}
00077       const HeaderFieldValue* back() const {return &mHeaders.back();}
00078 
00079       inline void reserve(size_t size)
00080       {
00081          mHeaders.reserve(size);
00082       }
00083 
00084       bool parsedEmpty() const;
00085    private:
00086       typedef std::vector<HeaderFieldValue, StlPoolAllocator<HeaderFieldValue, PoolBase > >  ListImpl;
00087    public:
00088       typedef ListImpl::iterator iterator;
00089       typedef ListImpl::const_iterator const_iterator;
00090 
00091       iterator begin() {return mHeaders.begin();}
00092       iterator end() {return mHeaders.end();}
00093       const_iterator begin() const {return mHeaders.begin();}
00094       const_iterator end() const {return mHeaders.end();}
00095 
00096    private:
00097       ListImpl mHeaders;
00098       PoolBase* mPool;
00099       ParserContainerBase* mParserContainer;
00100 
00101       void freeParserContainer();
00102 };
00103 
00104 }
00105 
00106 #endif
00107 
00108 /* ====================================================================
00109  * The Vovida Software License, Version 1.0 
00110  * 
00111  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00112  * 
00113  * Redistribution and use in source and binary forms, with or without
00114  * modification, are permitted provided that the following conditions
00115  * are met:
00116  * 
00117  * 1. Redistributions of source code must retain the above copyright
00118  *    notice, this list of conditions and the following disclaimer.
00119  * 
00120  * 2. Redistributions in binary form must reproduce the above copyright
00121  *    notice, this list of conditions and the following disclaimer in
00122  *    the documentation and/or other materials provided with the
00123  *    distribution.
00124  * 
00125  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00126  *    and "Vovida Open Communication Application Library (VOCAL)" must
00127  *    not be used to endorse or promote products derived from this
00128  *    software without prior written permission. For written
00129  *    permission, please contact vocal@vovida.org.
00130  *
00131  * 4. Products derived from this software may not be called "VOCAL", nor
00132  *    may "VOCAL" appear in their name, without prior written
00133  *    permission of Vovida Networks, Inc.
00134  * 
00135  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00136  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00137  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00138  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00139  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00140  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00141  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00142  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00143  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00144  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00145  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00146  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00147  * DAMAGE.
00148  * 
00149  * ====================================================================
00150  * 
00151  * This software consists of voluntary contributions made by Vovida
00152  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00153  * Inc.  For more information on Vovida Networks, Inc., please see
00154  * <http://www.vovida.org/>.
00155  *
00156  */