Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _RTL_BYTESEQ_HXX_
29 : : #define _RTL_BYTESEQ_HXX_
30 : :
31 : : #include <osl/interlck.h>
32 : : #include <rtl/byteseq.h>
33 : : #include <rtl/alloc.h>
34 : : #include <rtl/memory.h>
35 : :
36 : : #if ! defined EXCEPTIONS_OFF
37 : : #include <new>
38 : : #endif
39 : :
40 : :
41 : : namespace rtl
42 : : {
43 : :
44 : : //__________________________________________________________________________________________________
45 : 448630 : inline ByteSequence::ByteSequence() SAL_THROW(())
46 : 448630 : : _pSequence( 0 )
47 : : {
48 : 448630 : ::rtl_byte_sequence_construct( &_pSequence, 0 );
49 : 448630 : }
50 : : //__________________________________________________________________________________________________
51 : 2422469 : inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW(())
52 : 2422469 : : _pSequence( 0 )
53 : : {
54 : 2422469 : ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
55 : 2422469 : }
56 : : //__________________________________________________________________________________________________
57 : 603481 : inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW(())
58 : 603481 : : _pSequence( pSequence )
59 : : {
60 : 603481 : ::rtl_byte_sequence_acquire( pSequence );
61 : 603481 : }
62 : : //__________________________________________________________________________________________________
63 : 13833 : inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
64 : 13833 : : _pSequence( 0 )
65 : : {
66 : 13833 : ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
67 : : #if ! defined EXCEPTIONS_OFF
68 [ - + ]: 13833 : if (_pSequence == 0)
69 : 0 : throw ::std::bad_alloc();
70 : : #endif
71 : 13833 : }
72 : : //__________________________________________________________________________________________________
73 : 1560 : inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
74 : 1560 : : _pSequence( 0 )
75 : : {
76 : 1560 : ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
77 : : #if ! defined EXCEPTIONS_OFF
78 [ - + ]: 1560 : if (_pSequence == 0)
79 : 0 : throw ::std::bad_alloc();
80 : : #endif
81 : 1560 : }
82 : : //__________________________________________________________________________________________________
83 : 22787 : inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW(())
84 : 22787 : : _pSequence( pSequence )
85 : : {
86 : 22787 : }
87 : : //__________________________________________________________________________________________________
88 : 203 : inline ByteSequence::ByteSequence( sal_Int32 len )
89 : 203 : : _pSequence( 0 )
90 : : {
91 : 203 : ::rtl_byte_sequence_construct( &_pSequence, len );
92 : : #if ! defined EXCEPTIONS_OFF
93 [ - + ]: 203 : if (_pSequence == 0)
94 : 0 : throw ::std::bad_alloc();
95 : : #endif
96 : 203 : }
97 : : //__________________________________________________________________________________________________
98 : 3512413 : inline ByteSequence::~ByteSequence() SAL_THROW(())
99 : : {
100 : 3512413 : ::rtl_byte_sequence_release( _pSequence );
101 : 3512428 : }
102 : : //__________________________________________________________________________________________________
103 : 1586362 : inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW(())
104 : : {
105 : 1586362 : ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
106 : 1586361 : return *this;
107 : : }
108 : : //__________________________________________________________________________________________________
109 : 1333588 : inline sal_Bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW(())
110 : : {
111 : 1333588 : return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
112 : : }
113 : : //__________________________________________________________________________________________________
114 : 21121 : inline sal_Int8 * ByteSequence::getArray()
115 : : {
116 : 21121 : ::rtl_byte_sequence_reference2One( &_pSequence );
117 : : #if ! defined EXCEPTIONS_OFF
118 [ - + ]: 21121 : if (_pSequence == 0)
119 : 0 : throw ::std::bad_alloc();
120 : : #endif
121 : 21121 : return (sal_Int8 *)_pSequence->elements;
122 : : }
123 : : //__________________________________________________________________________________________________
124 : 9758 : inline void ByteSequence::realloc( sal_Int32 nSize )
125 : : {
126 : 9758 : ::rtl_byte_sequence_realloc( &_pSequence, nSize );
127 : : #if ! defined EXCEPTIONS_OFF
128 [ - + ]: 9758 : if (_pSequence == 0)
129 : 0 : throw ::std::bad_alloc();
130 : : #endif
131 : 9758 : }
132 : : //__________________________________________________________________________________________________
133 : 2698 : inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
134 : : {
135 : 2698 : return getArray()[ nIndex ];
136 : : }
137 : : //__________________________________________________________________________________________________
138 : 389831 : inline sal_Bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW(())
139 : : {
140 : 389831 : return (! operator == ( rSeq ));
141 : : }
142 : :
143 : : }
144 : : #endif
145 : :
146 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|