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"
31 inline ByteSequence::ByteSequence()
34 ::rtl_byte_sequence_construct( &_pSequence
, 0 );
37 inline ByteSequence::ByteSequence( const ByteSequence
& rSeq
)
40 ::rtl_byte_sequence_assign( &_pSequence
, rSeq
._pSequence
);
43 #if defined LIBO_INTERNAL_ONLY
44 inline ByteSequence::ByteSequence( ByteSequence
&& rSeq
)
45 : _pSequence(rSeq
._pSequence
)
47 rSeq
._pSequence
= nullptr;
51 inline ByteSequence::ByteSequence( sal_Sequence
*pSequence
)
52 : _pSequence( pSequence
)
54 ::rtl_byte_sequence_acquire( pSequence
);
57 inline ByteSequence::ByteSequence( const sal_Int8
* pElements
, sal_Int32 len
)
60 ::rtl_byte_sequence_constructFromArray( &_pSequence
, pElements
, len
);
61 if (_pSequence
== NULL
)
62 throw ::std::bad_alloc();
65 inline ByteSequence::ByteSequence( sal_Int32 len
, enum __ByteSequence_NoDefault
)
68 ::rtl_byte_sequence_constructNoDefault( &_pSequence
, len
);
69 if (_pSequence
== NULL
)
70 throw ::std::bad_alloc();
73 inline ByteSequence::ByteSequence( sal_Sequence
*pSequence
, enum __ByteSequence_NoAcquire
)
74 : _pSequence( pSequence
)
78 inline ByteSequence::ByteSequence( sal_Int32 len
)
81 ::rtl_byte_sequence_construct( &_pSequence
, len
);
82 if (_pSequence
== NULL
)
83 throw ::std::bad_alloc();
86 inline ByteSequence::~ByteSequence()
88 ::rtl_byte_sequence_release( _pSequence
);
91 inline ByteSequence
& ByteSequence::operator = ( const ByteSequence
& rSeq
)
93 ::rtl_byte_sequence_assign( &_pSequence
, rSeq
._pSequence
);
97 #if defined LIBO_INTERNAL_ONLY
98 inline ByteSequence
& ByteSequence::operator = ( ByteSequence
&& rSeq
)
100 ::rtl_byte_sequence_release(_pSequence
);
101 _pSequence
= rSeq
._pSequence
;
102 rSeq
._pSequence
= nullptr;
107 inline bool ByteSequence::operator == ( const ByteSequence
& rSeq
) const
109 return ::rtl_byte_sequence_equals( _pSequence
, rSeq
._pSequence
);
112 inline sal_Int8
* ByteSequence::getArray()
114 ::rtl_byte_sequence_reference2One( &_pSequence
);
115 if (_pSequence
== NULL
)
116 throw ::std::bad_alloc();
117 return reinterpret_cast<sal_Int8
*>(_pSequence
->elements
);
120 inline void ByteSequence::realloc( sal_Int32 nSize
)
122 ::rtl_byte_sequence_realloc( &_pSequence
, nSize
);
123 if (_pSequence
== NULL
)
124 throw ::std::bad_alloc();
127 inline sal_Int8
& ByteSequence::operator [] ( sal_Int32 nIndex
)
129 return getArray()[ nIndex
];
132 inline bool ByteSequence::operator != ( const ByteSequence
& rSeq
) const
134 return (! operator == ( rSeq
));
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */