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 <osl/interlck.h>
23 : #include <rtl/byteseq.h>
24 : #include <rtl/alloc.h>
25 :
26 : #include <new>
27 :
28 : namespace rtl
29 : {
30 :
31 :
32 470061 : inline ByteSequence::ByteSequence()
33 470061 : : _pSequence( 0 )
34 : {
35 470061 : ::rtl_byte_sequence_construct( &_pSequence, 0 );
36 470063 : }
37 :
38 2683246 : inline ByteSequence::ByteSequence( const ByteSequence & rSeq )
39 2683246 : : _pSequence( 0 )
40 : {
41 2683246 : ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
42 2683248 : }
43 :
44 669038 : inline ByteSequence::ByteSequence( sal_Sequence *pSequence)
45 669038 : : _pSequence( pSequence )
46 : {
47 669038 : ::rtl_byte_sequence_acquire( pSequence );
48 669038 : }
49 :
50 1790 : inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
51 1790 : : _pSequence( 0 )
52 : {
53 1790 : ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
54 1790 : if (_pSequence == 0)
55 0 : throw ::std::bad_alloc();
56 1790 : }
57 :
58 4 : inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
59 4 : : _pSequence( 0 )
60 : {
61 4 : ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
62 4 : if (_pSequence == 0)
63 0 : throw ::std::bad_alloc();
64 4 : }
65 :
66 23763 : inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire )
67 23763 : : _pSequence( pSequence )
68 : {
69 23763 : }
70 :
71 194 : inline ByteSequence::ByteSequence( sal_Int32 len )
72 194 : : _pSequence( 0 )
73 : {
74 194 : ::rtl_byte_sequence_construct( &_pSequence, len );
75 194 : if (_pSequence == 0)
76 0 : throw ::std::bad_alloc();
77 194 : }
78 :
79 3848021 : inline ByteSequence::~ByteSequence()
80 : {
81 3848021 : ::rtl_byte_sequence_release( _pSequence );
82 3848021 : }
83 :
84 1746587 : inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq )
85 : {
86 1746587 : ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
87 1746587 : return *this;
88 : }
89 :
90 1498517 : inline bool ByteSequence::operator == ( const ByteSequence & rSeq ) const
91 : {
92 1498517 : return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
93 : }
94 :
95 3604 : inline sal_Int8 * ByteSequence::getArray()
96 : {
97 3604 : ::rtl_byte_sequence_reference2One( &_pSequence );
98 3604 : if (_pSequence == 0)
99 0 : throw ::std::bad_alloc();
100 3604 : return (sal_Int8 *)_pSequence->elements;
101 : }
102 :
103 674 : inline void ByteSequence::realloc( sal_Int32 nSize )
104 : {
105 674 : ::rtl_byte_sequence_realloc( &_pSequence, nSize );
106 674 : if (_pSequence == 0)
107 0 : throw ::std::bad_alloc();
108 674 : }
109 :
110 2698 : inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
111 : {
112 2698 : return getArray()[ nIndex ];
113 : }
114 :
115 416001 : inline bool ByteSequence::operator != ( const ByteSequence & rSeq ) const
116 : {
117 416001 : return (! operator == ( rSeq ));
118 : }
119 :
120 : }
121 : #endif
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|