LibreOffice
LibreOffice 4.3 SDK C/C++ API Reference
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 namespace rtl
30 {
31 class ByteSequence;
32 }
33 
34 namespace com
35 {
36 namespace sun
37 {
38 namespace star
39 {
40 namespace uno
41 {
42 
50 template< class E >
51 class SAL_WARN_UNUSED Sequence
52 {
55  uno_Sequence * _pSequence;
56 
57 public:
59 
60  // these are here to force memory de/allocation to sal lib.
61  inline static void * SAL_CALL operator new ( ::size_t nSize )
62  SAL_THROW(())
63  { return ::rtl_allocateMemory( nSize ); }
64  inline static void SAL_CALL operator delete ( void * pMem )
65  SAL_THROW(())
66  { ::rtl_freeMemory( pMem ); }
67  inline static void * SAL_CALL operator new ( ::size_t, void * pMem )
68  SAL_THROW(())
69  { return pMem; }
70  inline static void SAL_CALL operator delete ( void *, void * )
71  SAL_THROW(())
72  {}
73 
77  static typelib_TypeDescriptionReference * s_pType;
78 
80 
83  typedef E ElementType;
84 
87  inline Sequence() SAL_THROW(());
88 
93  inline Sequence( const Sequence< E > & rSeq ) SAL_THROW(());
94 
101  inline Sequence( uno_Sequence * pSequence, __sal_NoAcquire dummy )
102  SAL_THROW(());
103 
109  inline Sequence( const E * pElements, sal_Int32 len );
110 
115  inline explicit Sequence( sal_Int32 len );
116 
120  inline ~Sequence() SAL_THROW(());
121 
128  inline Sequence< E > & SAL_CALL operator = ( const Sequence< E > & rSeq )
129  SAL_THROW(());
130 
135  inline sal_Int32 SAL_CALL getLength() const SAL_THROW(())
136  { return _pSequence->nElements; }
137 
143  inline bool SAL_CALL hasElements() const SAL_THROW(())
144  { return (_pSequence->nElements > 0); }
145 
152  inline const E * SAL_CALL getConstArray() const SAL_THROW(())
153  { return reinterpret_cast< const E * >( _pSequence->elements ); }
154 
164  inline E * SAL_CALL getArray();
165 
171  inline E * begin();
172 
178  inline E const * begin() const;
179 
185  inline E * end();
186 
192  inline E const * end() const;
193 
204  inline E & SAL_CALL operator [] ( sal_Int32 nIndex );
205 
212  inline const E & SAL_CALL operator [] ( sal_Int32 nIndex ) const
213  SAL_THROW(());
214 
220  inline bool SAL_CALL operator == ( const Sequence< E > & rSeq ) const
221  SAL_THROW(());
222 
228  inline bool SAL_CALL operator != ( const Sequence< E > & rSeq ) const
229  SAL_THROW(());
230 
241  inline void SAL_CALL realloc( sal_Int32 nSize );
242 
247  inline uno_Sequence * SAL_CALL get() const SAL_THROW(())
248  { return _pSequence; }
249 };
250 
251 // Find uses of illegal Sequence<bool> (instead of Sequence<sal_Bool>) during
252 // compilation:
253 template<> class Sequence<bool> {
255 };
256 
262 inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
263  const ::rtl::ByteSequence & rByteSequence ) SAL_THROW(());
264 
265 }
266 }
267 }
268 }
269 
280 template< class E >
281 inline const ::com::sun::star::uno::Type &
282 SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< E > * )
283  SAL_THROW(());
284 
295 template< class E >
296 inline const ::com::sun::star::uno::Type &
297 SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType )
298  SAL_THROW(());
299 
307 inline const ::com::sun::star::uno::Type &
308 SAL_CALL getCharSequenceCppuType() SAL_THROW(());
309 
310 #endif
311 
312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator!=(const Any &rAny, const C &value) SAL_THROW(())
Template unequality operator: compares set value of left side any to right side value.
Definition: Any.hxx:582
Definition: bootstrap.hxx:24
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
E ElementType
typedefs the element type of the sequence
Definition: Sequence.h:83
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:33
__sal_NoAcquire
Definition: types.h:384
bool hasElements() const SAL_THROW(())
Tests whether the sequence has elements, i.e.
Definition: Sequence.h:143
Holds a weak reference to a type description.
Definition: typedescription.h:40
This is the binary specification of a SAL sequence.
Definition: types.h:327
Definition: Sequence.h:253
inline::com::sun::star::uno::Sequence< sal_Int8 > toUnoSequence(const ::rtl::ByteSequence &rByteSequence) SAL_THROW(())
Creates a UNO byte sequence from a SAL byte sequence.
Definition: Sequence.hxx:185
Sequence() SAL_THROW(())
Default constructor: Creates an empty sequence.
Definition: Sequence.hxx:48
#define SAL_THROW(x)
Exception specification documentation.
Definition: types.h:361
const ::com::sun::star::uno::Type & getCppuSequenceType(const ::com::sun::star::uno::Type &rElementType) SAL_THROW(())
Gets the meta type of IDL sequence.
Definition: Sequence.hxx:251
bool operator==(const Any &rAny, const C &value) SAL_THROW(())
Template equality operator: compares set value of left side any to right side value.
Definition: Any.hxx:571
const ::com::sun::star::uno::Type & getCppuType(const ::com::sun::star::uno::Sequence< E > *) SAL_THROW(())
Gets the meta type of IDL sequence.
const E * getConstArray() const SAL_THROW(())
Gets a pointer to elements array for reading.
Definition: Sequence.h:152
const ::com::sun::star::uno::Type & getCharSequenceCppuType() SAL_THROW(())
Gets the meta type of IDL sequence< char >.
Definition: Sequence.hxx:266
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:410
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:603
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
Definition: types.h:391