Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_RTL_BYTESEQ_HXX
20 : #define INCLUDED_RTL_BYTESEQ_HXX
21 :
22 : #include <rtl/byteseq.h>
23 :
24 : #include <new>
25 :
26 : namespace rtl
27 : {
28 :
29 :
30 251033 : inline ByteSequence::ByteSequence()
31 251033 : : _pSequence( 0 )
32 : {
33 251033 : ::rtl_byte_sequence_construct( &_pSequence, 0 );
34 251034 : }
35 :
36 1243271 : inline ByteSequence::ByteSequence( const ByteSequence & rSeq )
37 1243271 : : _pSequence( 0 )
38 : {
39 1243271 : ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
40 1243279 : }
41 :
42 345330 : inline ByteSequence::ByteSequence( sal_Sequence *pSequence)
43 345330 : : _pSequence( pSequence )
44 : {
45 345330 : ::rtl_byte_sequence_acquire( pSequence );
46 345330 : }
47 :
48 1306 : inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
49 1306 : : _pSequence( 0 )
50 : {
51 1306 : ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
52 1306 : if (_pSequence == 0)
53 0 : throw ::std::bad_alloc();
54 1306 : }
55 :
56 2 : inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
57 2 : : _pSequence( 0 )
58 : {
59 2 : ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
60 2 : if (_pSequence == 0)
61 0 : throw ::std::bad_alloc();
62 2 : }
63 :
64 11880 : inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire )
65 11880 : : _pSequence( pSequence )
66 : {
67 11880 : }
68 :
69 97 : inline ByteSequence::ByteSequence( sal_Int32 len )
70 97 : : _pSequence( 0 )
71 : {
72 97 : ::rtl_byte_sequence_construct( &_pSequence, len );
73 97 : if (_pSequence == 0)
74 0 : throw ::std::bad_alloc();
75 97 : }
76 :
77 1852833 : inline ByteSequence::~ByteSequence()
78 : {
79 1852833 : ::rtl_byte_sequence_release( _pSequence );
80 1852900 : }
81 :
82 948899 : inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq )
83 : {
84 948899 : ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
85 948902 : return *this;
86 : }
87 :
88 876762 : inline bool ByteSequence::operator == ( const ByteSequence & rSeq ) const
89 : {
90 876762 : return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
91 : }
92 :
93 2012 : inline sal_Int8 * ByteSequence::getArray()
94 : {
95 2012 : ::rtl_byte_sequence_reference2One( &_pSequence );
96 2012 : if (_pSequence == 0)
97 0 : throw ::std::bad_alloc();
98 2012 : return reinterpret_cast<sal_Int8 *>(_pSequence->elements);
99 : }
100 :
101 547 : inline void ByteSequence::realloc( sal_Int32 nSize )
102 : {
103 547 : ::rtl_byte_sequence_realloc( &_pSequence, nSize );
104 547 : if (_pSequence == 0)
105 0 : throw ::std::bad_alloc();
106 547 : }
107 :
108 1349 : inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
109 : {
110 1349 : return getArray()[ nIndex ];
111 : }
112 :
113 219420 : inline bool ByteSequence::operator != ( const ByteSequence & rSeq ) const
114 : {
115 219420 : return (! operator == ( rSeq ));
116 : }
117 :
118 : }
119 : #endif
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|