mem_buf.hpp

См. документацию.
00001 /*
00002 
00003 Copyright (c) 2002-2005, Yauheni Akhotnikau
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008 
00009 - Redistributions of source code must retain the above copyright notice, this
00010 list of conditions and the following disclaimer.
00011 
00012 - Redistributions in binary form must reproduce the above copyright notice, this
00013 list of conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.
00015 
00016 - The name of the author may not be used to endorse or promote products derived
00017 from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00022 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00024 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00027 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00028 OF SUCH DAMAGE.
00029 
00030 */
00031 
00037 #if !defined( _OESS_1__IO__MEM_BUF_HPP_ )
00038 #define _OESS_1__IO__MEM_BUF_HPP_
00039 
00040 #include <oess_1/io/h/declspec.hpp>
00041 
00042 #include <auto_ptr_3/h/vect_ptr.hpp>
00043 
00044 #include <oess_1/io/h/binbuffer.hpp>
00045 
00046 namespace oess_1 {
00047 
00048 namespace io {
00049 
00050 //
00051 // mem_buf_t
00052 //
00053 
00056 
00082 class OESS_1__IO__TYPE  mem_buf_t :
00083   public ibinbuffer_t,
00084   public obinbuffer_t
00085 {
00086   public :
00091     mem_buf_t();
00092     mem_buf_t(
00094       size_t capacity );
00096     mem_buf_t(
00097       const mem_buf_t & o );
00098     virtual ~mem_buf_t();
00099 
00100     mem_buf_t &
00101     operator=(
00102       const mem_buf_t & o );
00103 
00104     enum {
00105       e_initial_capacity = 64
00106     };
00107 
00109     virtual size_t
00110     capacity() const;
00111 
00113 
00121     void
00122     change_capacity(
00124       size_t new_capacity,
00127       bool save_contents = true );
00128 
00130 
00133     virtual size_t
00134     size() const;
00135 
00137 
00143     void
00144     change_size(
00146       size_t new_size );
00147 
00150     virtual size_t
00151     pos() const;
00152 
00155 
00158     void
00159     set_pos( size_t pos );
00160 
00162     virtual bool
00163     eof() const;
00164 
00166     const oess_1::char_t *
00167     ptr() const;
00168 
00170     const oess_1::char_t *
00171     current_ptr() const;
00172 
00174 
00186     void
00187     subbuf(
00189       size_t from_pos,
00191       mem_buf_t & to,
00193       size_t to_pos,
00195       size_t count ) const;
00196 
00198 
00209     void
00210     subbuf(
00212       size_t from_pos,
00214       void * to,
00216       size_t count ) const;
00217 
00219 
00232     void
00233     insert(
00235       size_t to_pos,
00237       const mem_buf_t & from,
00240       size_t from_pos,
00242       size_t count );
00243 
00245 
00256     void
00257     insert(
00258       size_t to_pos,
00259       const void * from,
00260       size_t count );
00261 
00263 
00270     void
00271     erase(
00272       size_t from_offs,
00273       size_t count );
00274 
00276 
00280     void
00281     swap(
00282       mem_buf_t & o );
00283 
00284   protected :
00286 
00291     virtual const oess_1::char_t *
00292     in_reserve(
00295       size_t item_count,
00297       size_t item_size,
00300       size_t & item_available );
00301 
00303     virtual void
00304     in_shift(
00306       size_t item_count,
00308       size_t item_size );
00309 
00311     virtual oess_1::char_t *
00312     out_reserve(
00315       size_t item_count,
00317       size_t item_size,
00320       size_t & item_available );
00321 
00323     virtual void
00324     out_shift(
00326       size_t item_count,
00328       size_t item_size );
00329 
00330   private :
00332     auto_ptr_3::vect_ptr_t< char >  m_buf;
00334     size_t  m_size;
00336     size_t  m_pos;
00337 };
00338 
00339 } /* namespace io */
00340 
00341 } /* namespace oess_1 */
00342 
00343 #endif

Документация по ObjESSty. Последние изменения: Fri Oct 13 18:35:36 2006. Создано системой  doxygen 1.4.7
Hosted by uCoz