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 _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
34 //__________________________________________________________________________________________________
35 inline ByteSequence::ByteSequence() SAL_THROW(())
38 ::rtl_byte_sequence_construct( &_pSequence
, 0 );
40 //__________________________________________________________________________________________________
41 inline ByteSequence::ByteSequence( const ByteSequence
& rSeq
) SAL_THROW(())
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
)
56 ::rtl_byte_sequence_constructFromArray( &_pSequence
, pElements
, len
);
57 #if ! defined EXCEPTIONS_OFF
59 throw ::std::bad_alloc();
62 //__________________________________________________________________________________________________
63 inline ByteSequence::ByteSequence( sal_Int32 len
, enum __ByteSequence_NoDefault
)
66 ::rtl_byte_sequence_constructNoDefault( &_pSequence
, len
);
67 #if ! defined EXCEPTIONS_OFF
69 throw ::std::bad_alloc();
72 //__________________________________________________________________________________________________
73 inline ByteSequence::ByteSequence( sal_Sequence
*pSequence
, enum __ByteSequence_NoAcquire
) SAL_THROW(())
74 : _pSequence( pSequence
)
77 //__________________________________________________________________________________________________
78 inline ByteSequence::ByteSequence( sal_Int32 len
)
81 ::rtl_byte_sequence_construct( &_pSequence
, len
);
82 #if ! defined EXCEPTIONS_OFF
84 throw ::std::bad_alloc();
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
);
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
109 throw ::std::bad_alloc();
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
119 throw ::std::bad_alloc();
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
));
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */