update credits
[LibreOffice.git] / include / rtl / byteseq.hxx
blob80044739517883cc2c78eb75035afcdda8c7a228
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _RTL_BYTESEQ_HXX_
20 #define _RTL_BYTESEQ_HXX_
22 #include <osl/interlck.h>
23 #include <rtl/byteseq.h>
24 #include <rtl/alloc.h>
26 #if ! defined EXCEPTIONS_OFF
27 #include <new>
28 #endif
31 namespace rtl
34 //__________________________________________________________________________________________________
35 inline ByteSequence::ByteSequence() SAL_THROW(())
36 : _pSequence( 0 )
38 ::rtl_byte_sequence_construct( &_pSequence, 0 );
40 //__________________________________________________________________________________________________
41 inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW(())
42 : _pSequence( 0 )
44 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
46 //__________________________________________________________________________________________________
47 inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW(())
48 : _pSequence( pSequence )
50 ::rtl_byte_sequence_acquire( pSequence );
52 //__________________________________________________________________________________________________
53 inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
54 : _pSequence( 0 )
56 ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
57 #if ! defined EXCEPTIONS_OFF
58 if (_pSequence == 0)
59 throw ::std::bad_alloc();
60 #endif
62 //__________________________________________________________________________________________________
63 inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
64 : _pSequence( 0 )
66 ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
67 #if ! defined EXCEPTIONS_OFF
68 if (_pSequence == 0)
69 throw ::std::bad_alloc();
70 #endif
72 //__________________________________________________________________________________________________
73 inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW(())
74 : _pSequence( pSequence )
77 //__________________________________________________________________________________________________
78 inline ByteSequence::ByteSequence( sal_Int32 len )
79 : _pSequence( 0 )
81 ::rtl_byte_sequence_construct( &_pSequence, len );
82 #if ! defined EXCEPTIONS_OFF
83 if (_pSequence == 0)
84 throw ::std::bad_alloc();
85 #endif
87 //__________________________________________________________________________________________________
88 inline ByteSequence::~ByteSequence() SAL_THROW(())
90 ::rtl_byte_sequence_release( _pSequence );
92 //__________________________________________________________________________________________________
93 inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW(())
95 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
96 return *this;
98 //__________________________________________________________________________________________________
99 inline sal_Bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW(())
101 return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
103 //__________________________________________________________________________________________________
104 inline sal_Int8 * ByteSequence::getArray()
106 ::rtl_byte_sequence_reference2One( &_pSequence );
107 #if ! defined EXCEPTIONS_OFF
108 if (_pSequence == 0)
109 throw ::std::bad_alloc();
110 #endif
111 return (sal_Int8 *)_pSequence->elements;
113 //__________________________________________________________________________________________________
114 inline void ByteSequence::realloc( sal_Int32 nSize )
116 ::rtl_byte_sequence_realloc( &_pSequence, nSize );
117 #if ! defined EXCEPTIONS_OFF
118 if (_pSequence == 0)
119 throw ::std::bad_alloc();
120 #endif
122 //__________________________________________________________________________________________________
123 inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
125 return getArray()[ nIndex ];
127 //__________________________________________________________________________________________________
128 inline sal_Bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW(())
130 return (! operator == ( rSeq ));
134 #endif
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */