00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _RTL_BYTESEQ_HXX_
00020 #define _RTL_BYTESEQ_HXX_
00021
00022 #include <osl/interlck.h>
00023 #include <rtl/byteseq.h>
00024 #include <rtl/alloc.h>
00025
00026 #if ! defined EXCEPTIONS_OFF
00027 #include <new>
00028 #endif
00029
00030
00031 namespace rtl
00032 {
00033
00034
00035 inline ByteSequence::ByteSequence() SAL_THROW(())
00036 : _pSequence( 0 )
00037 {
00038 ::rtl_byte_sequence_construct( &_pSequence, 0 );
00039 }
00040
00041 inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW(())
00042 : _pSequence( 0 )
00043 {
00044 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
00045 }
00046
00047 inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW(())
00048 : _pSequence( pSequence )
00049 {
00050 ::rtl_byte_sequence_acquire( pSequence );
00051 }
00052
00053 inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
00054 : _pSequence( 0 )
00055 {
00056 ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
00057 #if ! defined EXCEPTIONS_OFF
00058 if (_pSequence == 0)
00059 throw ::std::bad_alloc();
00060 #endif
00061 }
00062
00063 inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
00064 : _pSequence( 0 )
00065 {
00066 ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
00067 #if ! defined EXCEPTIONS_OFF
00068 if (_pSequence == 0)
00069 throw ::std::bad_alloc();
00070 #endif
00071 }
00072
00073 inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW(())
00074 : _pSequence( pSequence )
00075 {
00076 }
00077
00078 inline ByteSequence::ByteSequence( sal_Int32 len )
00079 : _pSequence( 0 )
00080 {
00081 ::rtl_byte_sequence_construct( &_pSequence, len );
00082 #if ! defined EXCEPTIONS_OFF
00083 if (_pSequence == 0)
00084 throw ::std::bad_alloc();
00085 #endif
00086 }
00087
00088 inline ByteSequence::~ByteSequence() SAL_THROW(())
00089 {
00090 ::rtl_byte_sequence_release( _pSequence );
00091 }
00092
00093 inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW(())
00094 {
00095 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
00096 return *this;
00097 }
00098
00099 inline sal_Bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW(())
00100 {
00101 return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
00102 }
00103
00104 inline sal_Int8 * ByteSequence::getArray()
00105 {
00106 ::rtl_byte_sequence_reference2One( &_pSequence );
00107 #if ! defined EXCEPTIONS_OFF
00108 if (_pSequence == 0)
00109 throw ::std::bad_alloc();
00110 #endif
00111 return (sal_Int8 *)_pSequence->elements;
00112 }
00113
00114 inline void ByteSequence::realloc( sal_Int32 nSize )
00115 {
00116 ::rtl_byte_sequence_realloc( &_pSequence, nSize );
00117 #if ! defined EXCEPTIONS_OFF
00118 if (_pSequence == 0)
00119 throw ::std::bad_alloc();
00120 #endif
00121 }
00122
00123 inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
00124 {
00125 return getArray()[ nIndex ];
00126 }
00127
00128 inline sal_Bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW(())
00129 {
00130 return (! operator == ( rSeq ));
00131 }
00132
00133 }
00134 #endif
00135
00136