LibreOffice
LibreOffice 5.3 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 #ifndef INCLUDED_COM_SUN_STAR_UNO_SEQUENCE_H
20 #define INCLUDED_COM_SUN_STAR_UNO_SEQUENCE_H
21 
23 #include <uno/sequence2.h>
24 #include <com/sun/star/uno/Type.h>
25 #include <rtl/alloc.h>
26 
27 #include <new>
28 
29 #if defined LIBO_INTERNAL_ONLY
30 #include <initializer_list>
31 #endif
32 
33 namespace rtl
34 {
35 class ByteSequence;
36 }
37 
38 namespace com
39 {
40 namespace sun
41 {
42 namespace star
43 {
44 namespace uno
45 {
46 
54 template< class E >
55 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI Sequence
56 {
59  uno_Sequence * _pSequence;
60 
61 public:
63 
64  // these are here to force memory de/allocation to sal lib.
65  inline static void * SAL_CALL operator new ( ::size_t nSize )
66  { return ::rtl_allocateMemory( nSize ); }
67  inline static void SAL_CALL operator delete ( void * pMem )
68  { ::rtl_freeMemory( pMem ); }
69  inline static void * SAL_CALL operator new ( ::size_t, void * pMem )
70  { return pMem; }
71  inline static void SAL_CALL operator delete ( void *, void * )
72  {}
73 
77  static typelib_TypeDescriptionReference * s_pType;
78 
80 
83  typedef E ElementType;
84 
87  inline Sequence();
88 
93  inline Sequence( const Sequence & rSeq );
94 
101  inline Sequence( uno_Sequence * pSequence, __sal_NoAcquire dummy );
102 
108  inline Sequence( const E * pElements, sal_Int32 len );
109 
114  inline explicit Sequence( sal_Int32 len );
115 
116 #if defined LIBO_INTERNAL_ONLY
117 
123  inline Sequence(std::initializer_list<E> init);
124 #endif
125 
129  inline ~Sequence();
130 
137  inline Sequence & SAL_CALL operator = ( const Sequence & rSeq );
138 
143  inline sal_Int32 SAL_CALL getLength() const
144  { return _pSequence->nElements; }
145 
151  inline bool SAL_CALL hasElements() const
152  { return (_pSequence->nElements > 0); }
153 
160  inline const E * SAL_CALL getConstArray() const
161  { return reinterpret_cast< const E * >( _pSequence->elements ); }
162 
172  inline E * SAL_CALL getArray();
173 
179  inline E * begin();
180 
186  inline E const * begin() const;
187 
193  inline E * end();
194 
200  inline E const * end() const;
201 
212  inline E & SAL_CALL operator [] ( sal_Int32 nIndex );
213 
220  inline const E & SAL_CALL operator [] ( sal_Int32 nIndex ) const;
221 
227  inline bool SAL_CALL operator == ( const Sequence & rSeq ) const;
228 
234  inline bool SAL_CALL operator != ( const Sequence & rSeq ) const;
235 
246  inline void SAL_CALL realloc( sal_Int32 nSize );
247 
252  inline uno_Sequence * SAL_CALL get() const
253  { return _pSequence; }
254 };
255 
256 // Find uses of illegal Sequence<bool> (instead of Sequence<sal_Bool>) during
257 // compilation:
258 template<> class Sequence<bool> {
260 };
261 
267 inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
268  const ::rtl::ByteSequence & rByteSequence );
269 
270 }
271 }
272 }
273 }
274 
288 template< class E > SAL_DEPRECATED("use cppu::UnoType")
289 inline const ::com::sun::star::uno::Type &
290 SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< E > * );
291 
305 template< class E > SAL_DEPRECATED("use cppu::UnoType")
306 inline const ::com::sun::star::uno::Type &
307 SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType );
308 
319 SAL_DEPRECATED("use cppu::UnoType")
320 inline const ::com::sun::star::uno::Type &
321 SAL_CALL getCharSequenceCppuType();
322 
323 #endif
324 
325 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator==(const Any &rAny, const C &value)
Template equality operator: compares set value of left side any to right side value.
Definition: Any.hxx:595
sal_Int32 getLength() const
Gets length of the sequence.
Definition: Sequence.h:143
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:410
const ::com::sun::star::uno::Type & getCharSequenceCppuType()
Gets the meta type of IDL sequence&lt; char &gt;.
Definition: Sequence.hxx:276
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:624
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
Definition: Sequence.h:258
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:450
const E * getConstArray() const
Gets a pointer to elements array for reading.
Definition: Sequence.h:160
const ::com::sun::star::uno::Type & getCppuSequenceType(const ::com::sun::star::uno::Type &rElementType)
Gets the meta type of IDL sequence.
Definition: Sequence.hxx:262
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:197
bool operator!=(const Any &rAny, const C &value)
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:606
__sal_NoAcquire
Definition: types.h:384
E ElementType
typedefs the element type of the sequence
Definition: Sequence.h:83
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:40
This is the binary specification of a SAL sequence.
Definition: types.h:345
#define SAL_DEPRECATED(message)
Use as follows: SAL_DEPRECATED(&quot;Don&#39;t use, it&#39;s evil.&quot;) void doit(int nPara);.
Definition: types.h:509
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
bool hasElements() const
Tests whether the sequence has elements, i.e.
Definition: Sequence.h:151
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
Sequence()
Default constructor: Creates an empty sequence.
Definition: Sequence.hxx:49