LibreOffice LibreOffice 4.2 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
byteseq.hxx
Go to the documentation of this file.
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 inline ByteSequence::ByteSequence() SAL_THROW(())
33 : _pSequence( 0 )
34 {
35 ::rtl_byte_sequence_construct( &_pSequence, 0 );
36 }
37 //__________________________________________________________________________________________________
38 inline ByteSequence::ByteSequence( const ByteSequence & rSeq ) SAL_THROW(())
39 : _pSequence( 0 )
40 {
41 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
42 }
43 //__________________________________________________________________________________________________
44 inline ByteSequence::ByteSequence( sal_Sequence *pSequence) SAL_THROW(())
45 : _pSequence( pSequence )
46 {
47 ::rtl_byte_sequence_acquire( pSequence );
48 }
49 //__________________________________________________________________________________________________
50 inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
51 : _pSequence( 0 )
52 {
53 ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
54 if (_pSequence == 0)
55 throw ::std::bad_alloc();
56 }
57 //__________________________________________________________________________________________________
58 inline ByteSequence::ByteSequence( sal_Int32 len, enum __ByteSequence_NoDefault )
59 : _pSequence( 0 )
60 {
61 ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
62 if (_pSequence == 0)
63 throw ::std::bad_alloc();
64 }
65 //__________________________________________________________________________________________________
66 inline ByteSequence::ByteSequence( sal_Sequence *pSequence, enum __ByteSequence_NoAcquire ) SAL_THROW(())
67 : _pSequence( pSequence )
68 {
69 }
70 //__________________________________________________________________________________________________
71 inline ByteSequence::ByteSequence( sal_Int32 len )
72 : _pSequence( 0 )
73 {
74 ::rtl_byte_sequence_construct( &_pSequence, len );
75 if (_pSequence == 0)
76 throw ::std::bad_alloc();
77 }
78 //__________________________________________________________________________________________________
79 inline ByteSequence::~ByteSequence() SAL_THROW(())
80 {
81 ::rtl_byte_sequence_release( _pSequence );
82 }
83 //__________________________________________________________________________________________________
84 inline ByteSequence & ByteSequence::operator = ( const ByteSequence & rSeq ) SAL_THROW(())
85 {
86 ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
87 return *this;
88 }
89 //__________________________________________________________________________________________________
90 inline sal_Bool ByteSequence::operator == ( const ByteSequence & rSeq ) const SAL_THROW(())
91 {
92 return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
93 }
94 //__________________________________________________________________________________________________
95 inline sal_Int8 * ByteSequence::getArray()
96 {
97 ::rtl_byte_sequence_reference2One( &_pSequence );
98 if (_pSequence == 0)
99 throw ::std::bad_alloc();
100 return (sal_Int8 *)_pSequence->elements;
101 }
102 //__________________________________________________________________________________________________
103 inline void ByteSequence::realloc( sal_Int32 nSize )
104 {
105 ::rtl_byte_sequence_realloc( &_pSequence, nSize );
106 if (_pSequence == 0)
107 throw ::std::bad_alloc();
108 }
109 //__________________________________________________________________________________________________
110 inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
111 {
112 return getArray()[ nIndex ];
113 }
114 //__________________________________________________________________________________________________
115 inline sal_Bool ByteSequence::operator != ( const ByteSequence & rSeq ) const SAL_THROW(())
116 {
117 return (! operator == ( rSeq ));
118 }
119
120 }
121 #endif
122
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::__ByteSequence_NoAcquire
__ByteSequence_NoAcquire
Definition: byteseq.h:148
rtl_byte_sequence_construct
SAL_DLLPUBLIC void rtl_byte_sequence_construct(sal_Sequence **ppSequence, sal_Int32 nLength) SAL_THROW_EXTERN_C()
Constructs a bytes sequence with length nLength.
rtl::ByteSequence
C++ class representing a SAL byte sequence.
Definition: byteseq.h:161
rtl_byte_sequence_reference2One
SAL_DLLPUBLIC void rtl_byte_sequence_reference2One(sal_Sequence **ppSequence) SAL_THROW_EXTERN_C()
Assures that the reference count of the given byte sequence is one.
rtl::ByteSequence::ByteSequence
ByteSequence()
Default constructor: Creates an empty sequence.
Definition: byteseq.hxx:32
rtl_byte_sequence_assign
SAL_DLLPUBLIC void rtl_byte_sequence_assign(sal_Sequence **ppSequence, sal_Sequence *pSequence) SAL_THROW_EXTERN_C()
Assigns the byte sequence pSequence to *ppSequence.
interlck.h
rtl_byte_sequence_acquire
SAL_DLLPUBLIC void rtl_byte_sequence_acquire(sal_Sequence *pSequence) SAL_THROW_EXTERN_C()
Acquires the byte sequence.
rtl::ByteSequence::~ByteSequence
~ByteSequence()
Destructor: Releases sequence handle.
Definition: byteseq.hxx:79
alloc.h
rtl::ByteSequence::operator[]
sal_Int8 & operator[](sal_Int32 nIndex)
Non-const index operator: Obtains a reference to byte indexed at given position.
Definition: byteseq.hxx:110
byteseq.h
rtl_byte_sequence_release
SAL_DLLPUBLIC void rtl_byte_sequence_release(sal_Sequence *pSequence) SAL_THROW_EXTERN_C()
Releases the byte sequence.
rtl::ByteSequence::operator!=
sal_Bool operator!=(const ByteSequence &rSeq) const
Unequality operator: Compares two sequences.
Definition: byteseq.hxx:115
_sal_Sequence
This is the binary specification of a SAL sequence.
Definition: types.h:325
_sal_Sequence::elements
char elements[1]
elements array
Definition: types.h:335
rtl::ByteSequence::operator=
ByteSequence & operator=(const ByteSequence &rSeq)
Assignment operator: Acquires given sequence handle and releases a previously set handle...
Definition: byteseq.hxx:84
rtl_byte_sequence_realloc
SAL_DLLPUBLIC void rtl_byte_sequence_realloc(sal_Sequence **ppSequence, sal_Int32 nSize) SAL_THROW_EXTERN_C()
Reallocates length of byte sequence.
rtl_byte_sequence_constructFromArray
SAL_DLLPUBLIC void rtl_byte_sequence_constructFromArray(sal_Sequence **ppSequence, const sal_Int8 *pData, sal_Int32 nLength) SAL_THROW_EXTERN_C()
Constructs a byte sequence with length nLength and copies nLength bytes from pData.
sal_Bool
unsigned char sal_Bool
Definition: types.h:46
rtl::ByteSequence::realloc
void realloc(sal_Int32 nSize)
Reallocates sequence to new length.
Definition: byteseq.hxx:103
rtl_byte_sequence_equals
SAL_DLLPUBLIC sal_Bool rtl_byte_sequence_equals(sal_Sequence *pSequence1, sal_Sequence *pSequence2) SAL_THROW_EXTERN_C()
Compares two byte sequences.
sal_Int8
signed char sal_Int8
Definition: types.h:51
rtl::ByteSequence::operator==
sal_Bool operator==(const ByteSequence &rSeq) const
Equality operator: Compares two sequences.
Definition: byteseq.hxx:90
rtl_byte_sequence_constructNoDefault
SAL_DLLPUBLIC void rtl_byte_sequence_constructNoDefault(sal_Sequence **ppSequence, sal_Int32 nLength) SAL_THROW_EXTERN_C()
Constructs a bytes sequence with length nLength.
rtl::ByteSequence::getArray
sal_Int8 * getArray()
Gets a pointer to elements array for READING AND WRITING.
Definition: byteseq.hxx:95
SAL_THROW
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:358
rtl::__ByteSequence_NoDefault
__ByteSequence_NoDefault
Definition: byteseq.h:141