LibreOffice: rtl/byteseq.h Source File

LibreOffice LibreOffice 7.5 SDK C/C++ API Reference

Loading...
Searching...
No Matches
byteseq.h
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
20/*
21 * This file is part of LibreOffice published API.
22 */
23#ifndef INCLUDED_RTL_BYTESEQ_H
24#define INCLUDED_RTL_BYTESEQ_H
25
26#include "sal/config.h"
27
28#include "rtl/alloc.h"
29#include "sal/saldllapi.h"
30#include "sal/types.h"
31
32#ifdef __cplusplus
33extern "C"
34{
35#endif
36
42 SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_reference2One(
43 sal_Sequence ** ppSequence )
44 SAL_THROW_EXTERN_C();
45
51 SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_realloc(
52 sal_Sequence ** ppSequence, sal_Int32 nSize )
53 SAL_THROW_EXTERN_C();
54
59 SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_acquire(
60 sal_Sequence *pSequence )
61 SAL_THROW_EXTERN_C();
62
67 SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_release(
68 sal_Sequence *pSequence )
69 SAL_THROW_EXTERN_C();
70
77 SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_construct(
78 sal_Sequence **ppSequence , sal_Int32 nLength )
79 SAL_THROW_EXTERN_C();
80
87 SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_constructNoDefault(
88 sal_Sequence **ppSequence , sal_Int32 nLength )
89 SAL_THROW_EXTERN_C();
90
98 SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_constructFromArray(
99 sal_Sequence **ppSequence, const sal_Int8 *pData , sal_Int32 nLength )
100 SAL_THROW_EXTERN_C();
101
108 SAL_DLLPUBLIC void SAL_CALL rtl_byte_sequence_assign(
109 sal_Sequence **ppSequence , sal_Sequence *pSequence )
110 SAL_THROW_EXTERN_C();
111
116 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_byte_sequence_equals(
117 sal_Sequence *pSequence1 , sal_Sequence *pSequence2 )
118 SAL_THROW_EXTERN_C();
119
126 SAL_DLLPUBLIC const sal_Int8 *SAL_CALL rtl_byte_sequence_getConstArray(
127 sal_Sequence *pSequence )
128 SAL_THROW_EXTERN_C();
129
135 SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_byte_sequence_getLength(
136 sal_Sequence *pSequence )
137 SAL_THROW_EXTERN_C();
138
139#ifdef __cplusplus
140}
141namespace rtl
142{
143
144 enum __ByteSequence_NoDefault
145{
148 BYTESEQ_NODEFAULT = 0xcafe
149};
150
151 enum __ByteSequence_NoAcquire
152{
156 BYTESEQ_NOACQUIRE =
157#if defined _MSC_VER
158 int(0xcafebabe)
159#else
160 0xcafebabe
161#endif
162};
163
169 class SAL_WARN_UNUSED ByteSequence
170{
173 sal_Sequence * _pSequence;
174
175public:
177 // these are here to force memory de/allocation to sal lib.
178 static void * SAL_CALL operator new ( size_t nSize )
179 { return ::rtl_allocateMemory( nSize ); }
180 static void SAL_CALL operator delete ( void * pMem )
181 { ::rtl_freeMemory( pMem ); }
182 static void * SAL_CALL operator new ( size_t, void * pMem )
183 { return pMem; }
184 static void SAL_CALL operator delete ( void *, void * )
185 {}
187
190 inline ByteSequence();
195 inline ByteSequence( const ByteSequence & rSeq );
196#if defined LIBO_INTERNAL_ONLY
197 inline ByteSequence( ByteSequence && rSeq ) noexcept;
198#endif
203 inline ByteSequence( sal_Sequence *pSequence );
209 inline ByteSequence( const sal_Int8 * pElements, sal_Int32 len );
214 inline ByteSequence( sal_Int32 len );
221 inline ByteSequence( sal_Int32 len , enum __ByteSequence_NoDefault nodefault );
231 inline ByteSequence( sal_Sequence *pSequence , enum __ByteSequence_NoAcquire noacquire );
234 inline ~ByteSequence();
235
241 inline ByteSequence & SAL_CALL operator = ( const ByteSequence & rSeq );
242#if defined LIBO_INTERNAL_ONLY
243 inline ByteSequence & operator = ( ByteSequence && rSeq ) noexcept;
244#endif
245
250 sal_Int32 SAL_CALL getLength() const
251 { return _pSequence->nElements; }
252
258 const sal_Int8 * SAL_CALL getConstArray() const
259 { return reinterpret_cast<sal_Int8 *>(_pSequence->elements); }
267 inline sal_Int8 * SAL_CALL getArray();
268
281 inline sal_Int8 & SAL_CALL operator [] ( sal_Int32 nIndex );
282
289 const sal_Int8 & SAL_CALL operator [] ( sal_Int32 nIndex ) const
290 { return getConstArray()[ nIndex ]; }
291
297 inline bool SAL_CALL operator == ( const ByteSequence & rSeq ) const;
303 inline bool SAL_CALL operator != ( const ByteSequence & rSeq ) const;
304
311 inline void SAL_CALL realloc( sal_Int32 nSize );
312
317 sal_Sequence * SAL_CALL getHandle() const
318 { return _pSequence; }
323 sal_Sequence * SAL_CALL get() const
324 { return _pSequence; }
325};
326
327}
328#endif
329#endif
330
331/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
config.h
saldllapi.h
SAL_DLLPUBLIC
#define SAL_DLLPUBLIC
Definition: saldllapi.h:34
types.h
sal_Bool
unsigned char sal_Bool
Definition: types.h:38
SAL_THROW_EXTERN_C
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition: types.h:334
sal_Int8
signed char sal_Int8
Definition: types.h:43
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:587
alloc.h
rtl_freeMemory
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
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.
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_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.
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_byte_sequence_acquire
SAL_DLLPUBLIC void rtl_byte_sequence_acquire(sal_Sequence *pSequence) SAL_THROW_EXTERN_C()
Acquires the byte sequence.
rtl_byte_sequence_getConstArray
SAL_DLLPUBLIC const sal_Int8 * rtl_byte_sequence_getConstArray(sal_Sequence *pSequence) SAL_THROW_EXTERN_C()
Returns the data array pointer of the sequence.
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.
rtl_byte_sequence_getLength
SAL_DLLPUBLIC sal_Int32 rtl_byte_sequence_getLength(sal_Sequence *pSequence) SAL_THROW_EXTERN_C()
Returns the length of the sequence.
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_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_byte_sequence_release
SAL_DLLPUBLIC void rtl_byte_sequence_release(sal_Sequence *pSequence) SAL_THROW_EXTERN_C()
Releases the byte sequence.
rtl
Definition: bootstrap.hxx:34
rtl::__ByteSequence_NoDefault
__ByteSequence_NoDefault
Definition: byteseq.h:145
rtl::BYTESEQ_NODEFAULT
@ BYTESEQ_NODEFAULT
This enum value can be used to create a bytesequence with uninitialized data.
Definition: byteseq.h:148
rtl::__ByteSequence_NoAcquire
__ByteSequence_NoAcquire
Definition: byteseq.h:152
rtl::BYTESEQ_NOACQUIRE
@ BYTESEQ_NOACQUIRE
This enum value can be used to create a bytesequence from a C-Handle without acquiring the handle.
Definition: byteseq.h:156
_sal_Sequence
This is the binary specification of a SAL sequence.
Definition: types.h:304
rtl::ByteSequence
C++ class representing a SAL byte sequence.
Definition: byteseq.h:170
rtl::ByteSequence::getLength
sal_Int32 getLength() const
Gets the length of sequence.
Definition: byteseq.h:250
rtl::ByteSequence::get
sal_Sequence * get() const
Returns the UNacquired C handle of the sequence (for compatibility reasons)
Definition: byteseq.h:323
rtl::ByteSequence::getHandle
sal_Sequence * getHandle() const
Returns the UNacquired C handle of the sequence.
Definition: byteseq.h:317
rtl::ByteSequence::getConstArray
const sal_Int8 * getConstArray() const
Gets a pointer to byte array for READING.
Definition: byteseq.h:258