debian/libbit-dev/usr/include/bit-0.3/bit/data.h

00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation version 2.1.                *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this library; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018  ***************************************************************************/
00019 #ifndef BITDATA_H
00020 #define BITDATA_H
00021 
00022 #include <string>
00023 
00024 #include <sigc++/sigc++.h>
00025 
00026 #include <bit/enums.h>
00027 #include <bit/pointer.h>
00028 
00029 namespace bit {
00030 
00035   typedef uint8_t Octet;
00036 
00043   class Data: public sigc::trackable {
00044 
00045   protected:
00046 
00048     Data( size_t s = 0 ) throw (std::bad_alloc);
00049 
00051     Data( const void* d, size_t s, DataMode mode=COPY ) throw (std::bad_alloc);
00052 
00053   public:
00054     
00056     typedef BitPointer<Data> pointer;
00057 
00059     typedef BitPointer<const Data> const_pointer;
00060 
00062     static pointer create( size_t s = 0 ) throw (std::bad_alloc);
00063 
00065     static pointer create( const void* d, size_t s, DataMode mode=COPY ) throw (std::bad_alloc);
00066 
00068     virtual ~Data();
00069 
00071     Octet* data();
00072 
00074     const Octet* data() const;
00075 
00077     virtual void set_data( const void* newdata, size_t newsize, DataMode mode=COPY ) throw (std::bad_alloc);
00078 
00080     virtual size_t size() const;
00081 
00091     virtual bool resize( size_t s ) throw (std::bad_alloc);
00092 
00098     Data::pointer clone() const;
00099 
00101     operator Octet*();
00102 
00104     operator const Octet*() const;
00105 
00107     operator void*();
00108 
00110     operator const void*() const;
00111     
00113     std::string hex_string( std::string separator = std::string() ) const;
00114 
00116     virtual void clear();
00117 
00119     sigc::signal<void,size_t> signal_size_changed();
00120     
00122     sigc::signal<void,Octet*> signal_data_buffer_changed();
00123 
00124   protected:
00125 
00126     sigc::signal<void,size_t> m_signal_size_changed;
00127     
00128     sigc::signal<void,Octet*> m_signal_data_buffer_changed;
00129     
00130     private:
00131       
00133       Octet* m_data_buffer;
00134 
00136       size_t m_size;
00137 
00139       bool m_manage_data;
00140 
00141   };
00142 
00143 
00144 }
00145 
00146 #endif

Generated on Tue Mar 13 20:00:01 2007 by  doxygen 1.5.1