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 425057 : inline ByteSequence::ByteSequence() SAL_THROW(())
33 425057 : : _pSequence( 0 )
34 : {
35 425057 : ::rtl_byte_sequence_construct( &_pSequence, 0 );
36 425057 : }
37 :
38 170018 : inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW(())
39 170018 : : _pSequence( 0 )
40 : {
41 170018 : ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
42 170018 : }
43 :
44 42506 : inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW(())
45 42506 : : _pSequence( pSequence )
46 : {
47 42506 : ::rtl_byte_sequence_acquire( pSequence );
48 42506 : }
49 :
50 170018 : inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
51 170018 : : _pSequence( 0 )
52 : {
53 170018 : ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
54 170018 : if (_pSequence == 0)
55 0 : throw ::std::bad_alloc();
56 170018 : }
57 :
58 0 : inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
59 0 : : _pSequence( 0 )
60 : {
61 0 : ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
62 0 : if (_pSequence == 0)
63 0 : throw ::std::bad_alloc();
64 0 : }
65 :
66 0 : inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW(())
67 0 : : _pSequence( pSequence )
68 : {
69 0 : }
70 :
71 0 : inline ByteSequence::ByteSequence( sal_Int32 len )
72 0 : : _pSequence( 0 )
73 : {
74 0 : ::rtl_byte_sequence_construct( &_pSequence, len );
75 0 : if (_pSequence == 0)
76 0 : throw ::std::bad_alloc();
77 0 : }
78 :
79 807599 : inline ByteSequence::~ByteSequence() SAL_THROW(())
80 : {
81 807599 : ::rtl_byte_sequence_release( _pSequence );
82 807599 : }
83 :
84 170017 : inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW(())
85 : {
86 170017 : ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
87 170017 : return *this;
88 : }
89 :
90 0 : inline bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW(())
91 : {
92 0 : return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
93 : }
94 :
95 1 : inline sal_Int8 * ByteSequence::getArray()
96 : {
97 1 : ::rtl_byte_sequence_reference2One( &_pSequence );
98 1 : if (_pSequence == 0)
99 0 : throw ::std::bad_alloc();
100 1 : return (sal_Int8 *)_pSequence->elements;
101 : }
102 :
103 0 : inline void ByteSequence::realloc( sal_Int32 nSize )
104 : {
105 0 : ::rtl_byte_sequence_realloc( &_pSequence, nSize );
106 0 : if (_pSequence == 0)
107 0 : throw ::std::bad_alloc();
108 0 : }
109 :
110 0 : inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
111 : {
112 0 : return getArray()[ nIndex ];
113 : }
114 :
115 0 : inline bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW(())
116 : {
117 0 : return (! operator == ( rSeq ));
118 : }
119 :
120 : }
121 : #endif
122 :
123 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|