build fix
[LibreOffice.git] / include / rtl / byteseq.hxx
blob041b8bc361a82015e39e3f625dcc27820e208337
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 <rtl/byteseq.h>
24 #include <cstddef>
25 #include <new>
27 namespace rtl
31 inline ByteSequence::ByteSequence()
32 : _pSequence( NULL )
34 ::rtl_byte_sequence_construct( &_pSequence, 0 );
37 inline ByteSequence::ByteSequence( const ByteSequence & rSeq )
38 : _pSequence( NULL )
40 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
43 inline ByteSequence::ByteSequence( sal_Sequence *pSequence)
44 : _pSequence( pSequence )
46 ::rtl_byte_sequence_acquire( pSequence );
49 inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
50 : _pSequence( NULL )
52 ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
53 if (_pSequence == NULL)
54 throw ::std::bad_alloc();
57 inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
58 : _pSequence( NULL )
60 ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
61 if (_pSequence == NULL)
62 throw ::std::bad_alloc();
65 inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire )
66 : _pSequence( pSequence )
70 inline ByteSequence::ByteSequence( sal_Int32 len )
71 : _pSequence( NULL )
73 ::rtl_byte_sequence_construct( &_pSequence, len );
74 if (_pSequence == NULL)
75 throw ::std::bad_alloc();
78 inline ByteSequence::~ByteSequence()
80 ::rtl_byte_sequence_release( _pSequence );
83 inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq )
85 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
86 return *this;
89 inline bool ByteSequence::operator == ( const ByteSequence & rSeq ) const
91 return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
94 inline sal_Int8 * ByteSequence::getArray()
96 ::rtl_byte_sequence_reference2One( &_pSequence );
97 if (_pSequence == NULL)
98 throw ::std::bad_alloc();
99 return reinterpret_cast<sal_Int8 *>(_pSequence->elements);
102 inline void ByteSequence::realloc( sal_Int32 nSize )
104 ::rtl_byte_sequence_realloc( &_pSequence, nSize );
105 if (_pSequence == NULL)
106 throw ::std::bad_alloc();
109 inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
111 return getArray()[ nIndex ];
114 inline bool ByteSequence::operator != ( const ByteSequence & rSeq ) const
116 return (! operator == ( rSeq ));
120 #endif
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */