it_bus/binary_buffer.h

00001 #ifndef _IT_BUS_BINARY_BUFFER_H_
00002 #define _IT_BUS_BINARY_BUFFER_H_
00003 
00004 // @Copyright 2004 IONA Technologies, Plc. All Rights Reserved.
00005 //
00006 
00007 #include <it_bus/api_defines.h>
00008 #include <it_bus/string.h>
00009 #include <it_bus/exception.h>
00010 
00011 namespace IT_Bus
00012 {
00027     class IT_AFC_API BinaryBuffer
00028     {
00029     public:
00033         BinaryBuffer();
00034 
00038         BinaryBuffer(const BinaryBuffer& rhs);
00039 
00043         virtual ~BinaryBuffer();
00044 
00048         BinaryBuffer(String rhs);
00049 
00053         BinaryBuffer(const char * data, long size = -1);
00054 
00060         void operator=(const BinaryBuffer& rhs);
00061 
00067         void operator=(String rhs);
00068         
00078         BinaryBuffer&
00079             assign(const String & rhs, size_t n);
00080 
00086         void operator=(const char* rhs);
00087         
00097         BinaryBuffer& 
00098         assign(const char* rhs, size_t n);
00099 
00105         char operator[](long lIndex);
00106 
00107         operator const char*() const;
00108         operator unsigned char*();
00109 
00110         operator void*();
00111 
00112         operator const void * () const;
00113 
00119         bool
00120         operator==(
00121             const BinaryBuffer & rhs
00122         ) const;
00123 
00140         void attach(BinaryBuffer& attach_buffer);
00141 
00152         void borrow(const BinaryBuffer& borrow_buffer);
00153 
00166         void borrow(const char* borrow_data, long size = -1);
00167 
00175         bool is_borrowing();
00176 
00189         void attach_external(char* p, long size, bool borrow = true);
00190 
00199         void attach_external_const(const char* p, long size);
00200 
00208         void detach_external();
00209 
00235         void allocate(long size);
00236 
00270         void resize(long size) IT_THROW_DECL((IT_Bus::Exception));
00271 
00283         void copy(const char* p, long size = -1);
00284 
00291         void clear();
00292 
00303         const char* get_const_pointer() const;
00304 
00317         char* get_pointer() IT_THROW_DECL((IT_Bus::Exception));
00318 
00324         long get_size() const;
00325 
00331         IT_String get_it_string() const;
00332 
00347         char* at(long lIndex);
00348 
00358         String substr(long lIndex, long size = -1) const;
00359 
00370         long find_binary_buffer(long& dwFindIdx, long dwFindMaxIdx, BinaryBuffer& vvPacketTerminator) const;
00371 
00385         char* instr(char c, long lIndex = 0);
00386 
00399         long find(const char* s, long lIndex = 0) const;
00400 
00415         char* concat(const char* szThisString, long size = -1);
00416 
00422         bool empty() const { return (get_size() == 0); }
00423         
00429         String get_string() const;
00430 
00431     private:
00435         char*               m_data;
00436 
00440         long                m_size;
00441 
00448         bool                m_just_borrowing;
00449 
00450 
00458         bool                m_borrowed_const;
00459     };
00460 }
00461 
00462 #ifndef IT_IOSTREAMS_FREE
00463 inline IT_ostream & operator<< (IT_ostream& os, const IT_Bus::BinaryBuffer& buffer)
00464 {
00465     return os << buffer.get_const_pointer();
00466 }
00467 #endif 
00469 #endif  

Generated on Thu Sep 7 11:38:51 2006 for Artix by  doxygen 1.4.7