AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 #ifndef INCLUDED_RTL_BYTESEQ_HXX
4 #define INCLUDED_RTL_BYTESEQ_HXX
5 
6 #include "rtl/byteseq.h"
7 
8 #include <cstddef>
9 #include <new>
10 
11 namespace rtl
12 {
13 
14 
16  : _pSequence( NULL )
17 {
18  ::rtl_byte_sequence_construct( &_pSequence, 0 );
19 }
20 
22  : _pSequence( NULL )
23 {
24  ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
25 }
26 
27 #if defined LIBO_INTERNAL_ONLY
28 inline ByteSequence::ByteSequence( ByteSequence && rSeq ) noexcept
29  : _pSequence(rSeq._pSequence)
30 {
31  rSeq._pSequence = nullptr;
32 }
33 #endif
34 
36  : _pSequence( pSequence )
37 {
38  ::rtl_byte_sequence_acquire( pSequence );
39 }
40 
41 inline ByteSequence::ByteSequence( const sal_Int8 * pElements, sal_Int32 len )
42  : _pSequence( NULL )
43 {
44  ::rtl_byte_sequence_constructFromArray( &_pSequence, pElements, len );
45  if (_pSequence == NULL)
46  throw ::std::bad_alloc();
47 }
48 
50  : _pSequence( NULL )
51 {
52  ::rtl_byte_sequence_constructNoDefault( &_pSequence, len );
53  if (_pSequence == NULL)
54  throw ::std::bad_alloc();
55 }
56 
58  : _pSequence( pSequence )
59 {
60 }
61 
62 inline ByteSequence::ByteSequence( sal_Int32 len )
63  : _pSequence( NULL )
64 {
65  ::rtl_byte_sequence_construct( &_pSequence, len );
66  if (_pSequence == NULL)
67  throw ::std::bad_alloc();
68 }
69 
71 {
72  ::rtl_byte_sequence_release( _pSequence );
73 }
74 
76 {
77  ::rtl_byte_sequence_assign( &_pSequence, rSeq._pSequence );
78  return *this;
79 }
80 
81 #if defined LIBO_INTERNAL_ONLY
82 inline ByteSequence & ByteSequence::operator = ( ByteSequence && rSeq ) noexcept
83 {
84  ::rtl_byte_sequence_release(_pSequence);
85  _pSequence = rSeq._pSequence;
86  rSeq._pSequence = nullptr;
87  return *this;
88 }
89 #endif
90 
91 inline bool ByteSequence::operator == ( const ByteSequence & rSeq ) const
92 {
93  return ::rtl_byte_sequence_equals( _pSequence, rSeq._pSequence );
94 }
95 
97 {
98  ::rtl_byte_sequence_reference2One( &_pSequence );
99  if (_pSequence == NULL)
100  throw ::std::bad_alloc();
101  return reinterpret_cast<sal_Int8 *>(_pSequence->elements);
102 }
103 
104 inline void ByteSequence::realloc( sal_Int32 nSize )
105 {
106  ::rtl_byte_sequence_realloc( &_pSequence, nSize );
107  if (_pSequence == NULL)
108  throw ::std::bad_alloc();
109 }
110 
111 inline sal_Int8 & ByteSequence::operator [] ( sal_Int32 nIndex )
112 {
113  return getArray()[ nIndex ];
114 }
115 
116 inline bool ByteSequence::operator != ( const ByteSequence & rSeq ) const
117 {
118  return (! operator == ( rSeq ));
119 }
120 
121 }
122 #endif
123 
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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.
SAL_DLLPUBLIC void rtl_byte_sequence_constructNoDefault(sal_Sequence **ppSequence, sal_Int32 nLength) SAL_THROW_EXTERN_C()
Constructs a bytes sequence with length nLength.
sal_Int8 * getArray()
Gets a pointer to elements array for READING AND WRITING.
Definition: byteseq.hxx:96
char elements[1]
elements array
Definition: types.h:293
__ByteSequence_NoAcquire
Definition: byteseq.h:131
SAL_DLLPUBLIC sal_Bool rtl_byte_sequence_equals(sal_Sequence *pSequence1, sal_Sequence *pSequence2) SAL_THROW_EXTERN_C()
Compares two byte sequences.
ByteSequence()
Default constructor: Creates an empty sequence.
Definition: byteseq.hxx:15
~ByteSequence()
Destructor: Releases sequence handle.
Definition: byteseq.hxx:70
bool operator!=(const ByteSequence &rSeq) const
Unequality operator: Compares two sequences.
Definition: byteseq.hxx:116
SAL_DLLPUBLIC void rtl_byte_sequence_release(sal_Sequence *pSequence) SAL_THROW_EXTERN_C()
Releases the byte sequence.
SAL_DLLPUBLIC void rtl_byte_sequence_realloc(sal_Sequence **ppSequence, sal_Int32 nSize) SAL_THROW_EXTERN_C()
Reallocates length of byte sequence.
__ByteSequence_NoDefault
Definition: byteseq.h:124
sal_Int8 & operator[](sal_Int32 nIndex)
Non-const index operator: Obtains a reference to byte indexed at given position.
Definition: byteseq.hxx:111
void realloc(sal_Int32 nSize)
Reallocates sequence to new length.
Definition: byteseq.hxx:104
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_DLLPUBLIC void rtl_byte_sequence_assign(sal_Sequence **ppSequence, sal_Sequence *pSequence) SAL_THROW_EXTERN_C()
Assigns the byte sequence pSequence to *ppSequence.
This is the binary specification of a SAL sequence.
Definition: types.h:283
SAL_DLLPUBLIC void rtl_byte_sequence_construct(sal_Sequence **ppSequence, sal_Int32 nLength) SAL_THROW_EXTERN_C()
Constructs a bytes sequence with length nLength.
C++ class representing a SAL byte sequence.
Definition: byteseq.h:149
ByteSequence & operator=(const ByteSequence &rSeq)
Assignment operator: Acquires given sequence handle and releases a previously set handle...
Definition: byteseq.hxx:75
signed char sal_Int8
Definition: types.h:23
SAL_DLLPUBLIC void rtl_byte_sequence_acquire(sal_Sequence *pSequence) SAL_THROW_EXTERN_C()
Acquires the byte sequence.
bool operator==(const ByteSequence &rSeq) const
Equality operator: Compares two sequences.
Definition: byteseq.hxx:91