LibreOffice
LibreOffice 4.2 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 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 sal_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 sal_Bool SAL_CALL operator == ( const Sequence< E > & rSeq ) const
221  SAL_THROW(());
222 
228  inline sal_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 
256 inline ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL toUnoSequence(
257  const ::rtl::ByteSequence & rByteSequence ) SAL_THROW(());
258 
259 }
260 }
261 }
262 }
263 
274 template< class E >
275 inline const ::com::sun::star::uno::Type &
276 SAL_CALL getCppuType( const ::com::sun::star::uno::Sequence< E > * )
277  SAL_THROW(());
278 
290 template< class E >
291 inline const ::com::sun::star::uno::Type &
292 SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType )
293  SAL_THROW(());
294 
302 inline const ::com::sun::star::uno::Type &
303 SAL_CALL getCharSequenceCppuType() SAL_THROW(());
304 
305 #endif
306 
307 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const ::com::sun::star::uno::Type & getCharSequenceCppuType()
Gets the meta type of IDL sequence< char >.
Definition: Sequence.hxx:268
sal_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:565
Holds a weak reference to a type description.
Definition: typedescription.h:40
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:183
SAL_DLLPUBLIC void * rtl_allocateMemory(sal_Size Bytes) SAL_THROW_EXTERN_C()
Allocate memory.
sal_Bool hasElements() const
Tests whether the sequence has elements, i.e.
Definition: Sequence.h:143
const ::com::sun::star::uno::Type & getCppuSequenceType(const ::com::sun::star::uno::Type &rElementType)
Gets the meta type of IDL sequence.
Definition: Sequence.hxx:249
E ElementType
typedefs the element type of the sequence
Definition: Sequence.h:83
#define SAL_WARN_UNUSED
Annotate classes where a compiler should warn if an instance is unused.
Definition: types.h:591
This is the binary specification of a SAL sequence.
Definition: types.h:325
const E * getConstArray() const
Gets a pointer to elements array for reading.
Definition: Sequence.h:152
unsigned char sal_Bool
Definition: types.h:46
__sal_NoAcquire
Definition: types.h:372
sal_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:554
SAL_DLLPUBLIC void rtl_freeMemory(void *Ptr) SAL_THROW_EXTERN_C()
Free memory.
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:33
const ::com::sun::star::uno::Type & getCppuType(const ::com::sun::star::uno::Sequence< E > *)
Gets the meta type of IDL sequence.
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:358