LibreOffice: com/sun/star/uno/Sequence.h Source File

LibreOffice LibreOffice 25.2 SDK C/C++ API Reference |

Loading...
Searching...
No Matches
Sequence.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_COM_SUN_STAR_UNO_SEQUENCE_H
24#define INCLUDED_COM_SUN_STAR_UNO_SEQUENCE_H
25
26#include "typelib/typedescription.h"
27#include "uno/sequence2.h"
28#include "com/sun/star/uno/Type.h"
29#include "rtl/alloc.h"
30
31#include <new>
32
33#if defined LIBO_INTERNAL_ONLY
34#include <cassert>
35#include <initializer_list>
36#endif
37
38namespace rtl
39{
40class ByteSequence;
41}
42
43namespace com
44{
45namespace sun
46{
47namespace star
48{
49namespace uno
50{
51
59template< class E >
60 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI Sequence
61{
64 uno_Sequence * _pSequence;
65
66public:
68
69 // these are here to force memory de/allocation to sal lib.
70 static void * SAL_CALL operator new ( ::size_t nSize )
71 { return ::rtl_allocateMemory( nSize ); }
72 static void SAL_CALL operator delete ( void * pMem )
73 { ::rtl_freeMemory( pMem ); }
74 static void * SAL_CALL operator new ( ::size_t, void * pMem )
75 { return pMem; }
76 static void SAL_CALL operator delete ( void *, void * )
77 {}
78
82 static typelib_TypeDescriptionReference * s_pType;
83
85
88 typedef E ElementType;
89
92 inline Sequence();
93
98 inline Sequence( const Sequence & rSeq );
99
106 inline Sequence( uno_Sequence * pSequence, __sal_NoAcquire dummy );
107
113 inline Sequence( const E * pElements, sal_Int32 len );
114
119 inline explicit Sequence( sal_Int32 len );
120
121#if defined LIBO_INTERNAL_ONLY
128 inline Sequence(std::initializer_list<E> init);
129#endif
130
134 inline ~Sequence();
135
142 inline Sequence & SAL_CALL operator = ( const Sequence & rSeq );
143
144#if defined LIBO_INTERNAL_ONLY
145 inline Sequence & operator =(Sequence && other);
146#endif
147
152 sal_Int32 SAL_CALL getLength() const
153 { return _pSequence->nElements; }
154
160 bool SAL_CALL hasElements() const
161 { return (_pSequence->nElements > 0); }
162
163#if defined LIBO_INTERNAL_ONLY
168 sal_uInt32 size() const
169 { assert(getLength() >= 0); return static_cast<sal_uInt32>(getLength()); }
170#endif
171
178 const E * SAL_CALL getConstArray() const
179 { return reinterpret_cast< const E * >( _pSequence->elements ); }
180
190 inline E * SAL_CALL getArray();
191
192#if !defined LIBO_INTERNAL_ONLY
198 inline E * begin();
199#endif
200
206 inline E const * begin() const;
207
208#if !defined LIBO_INTERNAL_ONLY
214 inline E * end();
215#endif
216
222 inline E const * end() const;
223
224// Non-const operator[] is not available in internal code. Consider explicit use
225// of getArray(), out of tight loops if possible to avoid unneeded COW overhead.
226#if !defined LIBO_INTERNAL_ONLY
237 inline E & SAL_CALL operator [] ( sal_Int32 nIndex );
238#endif
239
246 inline const E & SAL_CALL operator [] ( sal_Int32 nIndex ) const;
247
253 inline bool SAL_CALL operator == ( const Sequence & rSeq ) const;
254
260 inline bool SAL_CALL operator != ( const Sequence & rSeq ) const;
261
272 inline void SAL_CALL realloc( sal_Int32 nSize );
273
278 uno_Sequence * SAL_CALL get() const
279 { return _pSequence; }
280
281#if defined LIBO_INTERNAL_ONLY
288 inline void swap(Sequence& other);
289#endif
290};
291
292// Find uses of illegal Sequence<bool> (instead of Sequence<sal_Bool>) during
293// compilation:
294 template<> class Sequence<bool> {
295 Sequence(Sequence<bool> const &) SAL_DELETED_FUNCTION;
296};
297
303inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
304 const ::rtl::ByteSequence & rByteSequence );
305
306}
307}
308}
309}
310
324template< class E > SAL_DEPRECATED("use cppu::UnoType")
325inline const ::com::sun::star::uno::Type &
326SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< E > * );
327
341template< class E > SAL_DEPRECATED("use cppu::UnoType")
342inline const ::com::sun::star::uno::Type &
343SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType );
344
355 SAL_DEPRECATED("use cppu::UnoType")
356inline const ::com::sun::star::uno::Type &
357SAL_CALL getCharSequenceCppuType();
358
359#endif
360
361/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DEPRECATED
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED("Don't use, it's evil.") void doit(int nPara);.
Definition types.h:492
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition types.h:396
__sal_NoAcquire
__sal_NoAcquire
Definition types.h:371
SAL_WARN_UNUSED
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition types.h:611
alloc.h
rtl_freeMemory
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
typedescription.h
typelib_TypeDescriptionReference
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
sequence2.h
uno_Sequence
sal_Sequence uno_Sequence
Definition sequence2.h:36
getCppuType
const ::com::sun::star::uno::Type & getCppuType(SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Any *)
Gets the meta type of IDL type any.
Definition Any.h:501
getCharSequenceCppuType
const ::com::sun::star::uno::Type & getCharSequenceCppuType()
Gets the meta type of IDL sequence< char >.
Definition Sequence.hxx:390
getCppuSequenceType
const ::com::sun::star::uno::Type & getCppuSequenceType(const ::com::sun::star::uno::Type &rElementType)
Gets the meta type of IDL sequence.
Definition Sequence.hxx:376
Type.h
com
Definition types.h:377
com::sun
Definition types.h:377
com::sun::star
Definition types.h:377
rtl
Definition bootstrap.hxx:34
com::sun::star::uno
Definition typedescription.hxx:43
com::sun::star::uno::toUnoSequence
inline ::com::sun::star::uno::Sequence< sal_Int8 > toUnoSequence(const ::rtl::ByteSequence &rByteSequence)
Creates a UNO byte sequence from a SAL byte sequence.
Definition Sequence.hxx:229
com::sun::star::uno::s_pType
typelib_TypeDescriptionReference * Array< T >::s_pType
Definition Type.hxx:106
rtl::ByteSequence
C++ class representing a SAL byte sequence.
Definition byteseq.h:170
com::sun::star::uno::Sequence
Template C++ class representing an IDL sequence.
Definition Sequence.h:61
com::sun::star::uno::Sequence::getConstArray
const E * getConstArray() const
Gets a pointer to elements array for reading.
Definition Sequence.h:178
com::sun::star::uno::Sequence::getLength
sal_Int32 getLength() const
Gets length of the sequence.
Definition Sequence.h:152
com::sun::star::uno::Sequence::get
uno_Sequence * get() const
Provides UNacquired sequence handle.
Definition Sequence.h:278
com::sun::star::uno::Sequence::Sequence
Sequence()
Default constructor: Creates an empty sequence.
Definition Sequence.hxx:58
com::sun::star::uno::Sequence::hasElements
bool hasElements() const
Tests whether the sequence has elements, i.e.
Definition Sequence.h:160
com::sun::star::uno::Sequence::ElementType
E ElementType
typedefs the element type of the sequence
Definition Sequence.h:88