Update ooo320-m1
[ooovba.git] / sal / inc / rtl / byteseq.hxx
blob7b8ee1dc33213cf7e7cc26ceba169ba7302d858f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: byteseq.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _RTL_BYTESEQ_HXX_
31 #define _RTL_BYTESEQ_HXX_
33 #include <osl/interlck.h>
34 #include <rtl/byteseq.h>
35 #include <rtl/alloc.h>
36 #include <rtl/memory.h>
38 #if ! defined EXCEPTIONS_OFF
39 #include <new>
40 #endif
43 namespace rtl
46 //__________________________________________________________________________________________________
47 inline ByteSequence::ByteSequence() SAL_THROW( () )
48 : _pSequence( 0 )
50 ::rtl_byte_sequence_construct( &_pSequence, 0 );
52 //__________________________________________________________________________________________________
53 inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW( () )
54 : _pSequence( 0 )
56 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
58 //__________________________________________________________________________________________________
59 inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW( () )
60 : _pSequence( pSequence )
62 ::rtl_byte_sequence_acquire( pSequence );
64 //__________________________________________________________________________________________________
65 inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
66 : _pSequence( 0 )
68 ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
69 #if ! defined EXCEPTIONS_OFF
70 if (_pSequence == 0)
71 throw ::std::bad_alloc();
72 #endif
74 //__________________________________________________________________________________________________
75 inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
76 : _pSequence( 0 )
78 ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
79 #if ! defined EXCEPTIONS_OFF
80 if (_pSequence == 0)
81 throw ::std::bad_alloc();
82 #endif
84 //__________________________________________________________________________________________________
85 inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW( () )
86 : _pSequence( pSequence )
89 //__________________________________________________________________________________________________
90 inline ByteSequence::ByteSequence( sal_Int32 len )
91 : _pSequence( 0 )
93 ::rtl_byte_sequence_construct( &_pSequence, len );
94 #if ! defined EXCEPTIONS_OFF
95 if (_pSequence == 0)
96 throw ::std::bad_alloc();
97 #endif
99 //__________________________________________________________________________________________________
100 inline ByteSequence::~ByteSequence() SAL_THROW( () )
102 ::rtl_byte_sequence_release( _pSequence );
104 //__________________________________________________________________________________________________
105 inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW( () )
107 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
108 return *this;
110 //__________________________________________________________________________________________________
111 inline sal_Bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW( () )
113 return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
115 //__________________________________________________________________________________________________
116 inline sal_Int8 * ByteSequence::getArray()
118 ::rtl_byte_sequence_reference2One( &_pSequence );
119 #if ! defined EXCEPTIONS_OFF
120 if (_pSequence == 0)
121 throw ::std::bad_alloc();
122 #endif
123 return (sal_Int8 *)_pSequence->elements;
125 //__________________________________________________________________________________________________
126 inline void ByteSequence::realloc( sal_Int32 nSize )
128 ::rtl_byte_sequence_realloc( &_pSequence, nSize );
129 #if ! defined EXCEPTIONS_OFF
130 if (_pSequence == 0)
131 throw ::std::bad_alloc();
132 #endif
134 //__________________________________________________________________________________________________
135 inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
137 return getArray()[ nIndex ];
139 //__________________________________________________________________________________________________
140 inline sal_Bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW( () )
142 return (! operator == ( rSeq ));
146 #endif