1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
30 inline ByteSequence::ByteSequence()
33 ::rtl_byte_sequence_construct( &_pSequence
, 0 );
36 inline ByteSequence::ByteSequence( const ByteSequence
& rSeq
)
39 ::rtl_byte_sequence_assign( &_pSequence
, rSeq
._pSequence
);
42 inline ByteSequence::ByteSequence( sal_Sequence
*pSequence
)
43 : _pSequence( pSequence
)
45 ::rtl_byte_sequence_acquire( pSequence
);
48 inline ByteSequence::ByteSequence( const sal_Int8
* pElements
, sal_Int32 len
)
51 ::rtl_byte_sequence_constructFromArray( &_pSequence
, pElements
, len
);
53 throw ::std::bad_alloc();
56 inline ByteSequence::ByteSequence( sal_Int32 len
, enum __ByteSequence_NoDefault
)
59 ::rtl_byte_sequence_constructNoDefault( &_pSequence
, len
);
61 throw ::std::bad_alloc();
64 inline ByteSequence::ByteSequence( sal_Sequence
*pSequence
, enum __ByteSequence_NoAcquire
)
65 : _pSequence( pSequence
)
69 inline ByteSequence::ByteSequence( sal_Int32 len
)
72 ::rtl_byte_sequence_construct( &_pSequence
, len
);
74 throw ::std::bad_alloc();
77 inline ByteSequence::~ByteSequence()
79 ::rtl_byte_sequence_release( _pSequence
);
82 inline ByteSequence
& ByteSequence::operator = ( const ByteSequence
& rSeq
)
84 ::rtl_byte_sequence_assign( &_pSequence
, rSeq
._pSequence
);
88 inline bool ByteSequence::operator == ( const ByteSequence
& rSeq
) const
90 return ::rtl_byte_sequence_equals( _pSequence
, rSeq
._pSequence
);
93 inline sal_Int8
* ByteSequence::getArray()
95 ::rtl_byte_sequence_reference2One( &_pSequence
);
97 throw ::std::bad_alloc();
98 return reinterpret_cast<sal_Int8
*>(_pSequence
->elements
);
101 inline void ByteSequence::realloc( sal_Int32 nSize
)
103 ::rtl_byte_sequence_realloc( &_pSequence
, nSize
);
105 throw ::std::bad_alloc();
108 inline sal_Int8
& ByteSequence::operator [] ( sal_Int32 nIndex
)
110 return getArray()[ nIndex
];
113 inline bool ByteSequence::operator != ( const ByteSequence
& rSeq
) const
115 return (! operator == ( rSeq
));
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */