AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 #ifndef INCLUDED_COM_SUN_STAR_UNO_SEQUENCE_H
4 #define INCLUDED_COM_SUN_STAR_UNO_SEQUENCE_H
5 
7 #include "uno/sequence2.h"
9 #include "rtl/alloc.h"
10 
11 #include <new>
12 
13 #if defined LIBO_INTERNAL_ONLY
14 #include <cassert>
15 #include <initializer_list>
16 #endif
17 
18 namespace rtl
19 {
20 class ByteSequence;
21 }
22 
23 namespace com
24 {
25 namespace sun
26 {
27 namespace star
28 {
29 namespace uno
30 {
31 
39 template< class E >
40 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI Sequence
41 {
44  uno_Sequence * _pSequence;
45 
46 public:
48 
49  // these are here to force memory de/allocation to sal lib.
50  static void * SAL_CALL operator new ( ::size_t nSize )
51  { return ::rtl_allocateMemory( nSize ); }
52  static void SAL_CALL operator delete ( void * pMem )
53  { ::rtl_freeMemory( pMem ); }
54  static void * SAL_CALL operator new ( ::size_t, void * pMem )
55  { return pMem; }
56  static void SAL_CALL operator delete ( void *, void * )
57  {}
58 
62  static typelib_TypeDescriptionReference * s_pType;
63 
65 
68  typedef E ElementType;
69 
72  inline Sequence();
73 
78  inline Sequence( const Sequence & rSeq );
79 
86  inline Sequence( uno_Sequence * pSequence, __sal_NoAcquire dummy );
87 
93  inline Sequence( const E * pElements, sal_Int32 len );
94 
99  inline explicit Sequence( sal_Int32 len );
100 
101 #if defined LIBO_INTERNAL_ONLY
102 
108  inline Sequence(std::initializer_list<E> init);
109 #endif
110 
114  inline ~Sequence();
115 
122  inline Sequence & SAL_CALL operator = ( const Sequence & rSeq );
123 
124 #if defined LIBO_INTERNAL_ONLY
125  inline Sequence & operator =(Sequence && other);
126 #endif
127 
132  sal_Int32 SAL_CALL getLength() const
133  { return _pSequence->nElements; }
134 
140  bool SAL_CALL hasElements() const
141  { return (_pSequence->nElements > 0); }
142 
143 #if defined LIBO_INTERNAL_ONLY
144 
148  sal_uInt32 size() const
149  { assert(getLength() >= 0); return static_cast<sal_uInt32>(getLength()); }
150 #endif
151 
158  const E * SAL_CALL getConstArray() const
159  { return reinterpret_cast< const E * >( _pSequence->elements ); }
160 
170  inline E * SAL_CALL getArray();
171 
172 #if !defined LIBO_INTERNAL_ONLY
173 
178  inline E * begin();
179 #endif
180 
186  inline E const * begin() const;
187 
188 #if !defined LIBO_INTERNAL_ONLY
189 
194  inline E * end();
195 #endif
196 
202  inline E const * end() const;
203 
204 // Non-const operator[] is not available in internal code. Consider explicit use
205 // of getArray(), out of tight loops if possible to avoid unneeded COW overhead.
206 #if !defined LIBO_INTERNAL_ONLY
207 
217  inline E & SAL_CALL operator [] ( sal_Int32 nIndex );
218 #endif
219 
226  inline const E & SAL_CALL operator [] ( sal_Int32 nIndex ) const;
227 
233  inline bool SAL_CALL operator == ( const Sequence & rSeq ) const;
234 
240  inline bool SAL_CALL operator != ( const Sequence & rSeq ) const;
241 
252  inline void SAL_CALL realloc( sal_Int32 nSize );
253 
258  uno_Sequence * SAL_CALL get() const
259  { return _pSequence; }
260 
261 #if defined LIBO_INTERNAL_ONLY
262 
268  inline void swap(Sequence& other);
269 #endif
270 };
271 
272 // Find uses of illegal Sequence<bool> (instead of Sequence<sal_Bool>) during
273 // compilation:
274 template<> class Sequence<bool> {
276 };
277 
283 inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
284  const ::rtl::ByteSequence & rByteSequence );
285 
286 }
287 }
288 }
289 }
290 
304 template< class E > SAL_DEPRECATED("use cppu::UnoType")
305 inline const ::com::sun::star::uno::Type &
306 SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< E > * );
307 
321 template< class E > SAL_DEPRECATED("use cppu::UnoType")
322 inline const ::com::sun::star::uno::Type &
323 SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType );
324 
335 SAL_DEPRECATED("use cppu::UnoType")
336 inline const ::com::sun::star::uno::Type &
337 SAL_CALL getCharSequenceCppuType();
338 
339 #endif
340 
341 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
const E * getConstArray() const
Gets a pointer to elements array for reading.
Definition: Sequence.h:158
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:24
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
__sal_NoAcquire
Definition: types.h:332
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:470
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:642
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:209
sal_Int32 getLength() const
Gets length of the sequence.
Definition: Sequence.h:132
#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:454
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:567
const ::com::sun::star::uno::Type & getCharSequenceCppuType()
Gets the meta type of IDL sequence&lt; char &gt;.
Definition: Sequence.hxx:370
bool operator!=(const Any &rAny, const C &value)
Template inequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:653
This is the binary specification of a SAL sequence.
Definition: types.h:283
bool hasElements() const
Tests whether the sequence has elements, i.e.
Definition: Sequence.h:140
Sequence()
Default constructor: Creates an empty sequence.
Definition: Sequence.hxx:38
E ElementType
typedefs the element type of the sequence
Definition: Sequence.h:68
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
Definition: Sequence.h:274
const ::com::sun::star::uno::Type & getCppuSequenceType(const ::com::sun::star::uno::Type &rElementType)
Gets the meta type of IDL sequence.
Definition: Sequence.hxx:356
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:358