Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / include / rtl / byteseq.hxx
blob200cff3c95e5129e18e7a1df4060028b364d873d
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 INCLUDED_RTL_BYTESEQ_HXX
20 #define INCLUDED_RTL_BYTESEQ_HXX
22 #include <osl/interlck.h>
23 #include <rtl/byteseq.h>
24 #include <rtl/alloc.h>
26 #include <new>
28 namespace rtl
32 inline ByteSequence::ByteSequence() SAL_THROW(())
33 : _pSequence( 0 )
35 ::rtl_byte_sequence_construct( &_pSequence, 0 );
38 inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW(())
39 : _pSequence( 0 )
41 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
44 inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW(())
45 : _pSequence( pSequence )
47 ::rtl_byte_sequence_acquire( pSequence );
50 inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
51 : _pSequence( 0 )
53 ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
54 if (_pSequence == 0)
55 throw ::std::bad_alloc();
58 inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
59 : _pSequence( 0 )
61 ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
62 if (_pSequence == 0)
63 throw ::std::bad_alloc();
66 inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW(())
67 : _pSequence( pSequence )
71 inline ByteSequence::ByteSequence( sal_Int32 len )
72 : _pSequence( 0 )
74 ::rtl_byte_sequence_construct( &_pSequence, len );
75 if (_pSequence == 0)
76 throw ::std::bad_alloc();
79 inline ByteSequence::~ByteSequence() SAL_THROW(())
81 ::rtl_byte_sequence_release( _pSequence );
84 inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW(())
86 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
87 return *this;
90 inline bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW(())
92 return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
95 inline sal_Int8 * ByteSequence::getArray()
97 ::rtl_byte_sequence_reference2One( &_pSequence );
98 if (_pSequence == 0)
99 throw ::std::bad_alloc();
100 return (sal_Int8 *)_pSequence->elements;
103 inline void ByteSequence::realloc( sal_Int32 nSize )
105 ::rtl_byte_sequence_realloc( &_pSequence, nSize );
106 if (_pSequence == 0)
107 throw ::std::bad_alloc();
110 inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
112 return getArray()[ nIndex ];
115 inline bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW(())
117 return (! operator == ( rSeq ));
121 #endif
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */