1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sequence.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef INCLUDED_SHARABLE_SEQUENCE_HXX
32 #define INCLUDED_SHARABLE_SEQUENCE_HXX
34 #include "anydata.hxx"
35 #include <com/sun/star/uno/Sequence.hxx>
39 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
44 sal_uInt8
* allocSequence(sal_uInt8 _aElementType
, ::sal_Sequence
const * _pSeqData
);
45 void freeSequence(sal_uInt8 _aElementType
, sal_uInt8
* _aSeq
);
47 ::sal_Sequence
* readSequence(sal_uInt8 _aElementType
, sal_uInt8
* _aSeq
);
48 ::com::sun::star::uno::Any
readAnySequence(sal_uInt8 _aElementType
, sal_uInt8
* _aSeq
);
49 //-----------------------------------------------------------------------------
51 sal_uInt8
* allocBinary(::com::sun::star::uno::Sequence
<sal_Int8
> const & _aBinaryValue
);
52 void freeBinary(sal_uInt8
* _aSeq
);
54 ::com::sun::star::uno::Sequence
<sal_Int8
> readBinary(sal_uInt8
* _aSeq
);
55 //-----------------------------------------------------------------------------
59 sal_uInt8
getElementTypeCode(::com::sun::star::uno::Sequence
<ET
> const & )
61 ::com::sun::star::uno::Type aElementType
= ::getCppuType( static_cast<ET
const *>(NULL
) );
62 return getTypeCode(aElementType
);
66 sal_uInt8
* allocSequence(::com::sun::star::uno::Sequence
<ET
> const & _aSeq
)
68 sal_uInt8 aTC
= getElementTypeCode(_aSeq
);
69 ::sal_Sequence
const * pSeqData
= _aSeq
.get();
70 return allocSequence(aTC
, pSeqData
);
74 void readSequence(::com::sun::star::uno::Sequence
<ET
> & _rSeq
, sal_uInt8
* _aSeq
)
76 sal_uInt8 aElementType
= getElementTypeCode(_rSeq
);
78 ::sal_Sequence
* pNewSequence
= readSequence(aElementType
, _aSeq
);
80 if (!pNewSequence
) return;
82 ::com::sun::star::uno::Sequence
<ET
> aNewSequence(pNewSequence
, SAL_NO_ACQUIRE
);
88 bool readSequence(::com::sun::star::uno::Sequence
<ET
> & _rSeq
, sal_uInt8 _aElementType
, sal_uInt8
* _aSeq
)
90 if (getElementTypeCode(_rSeq
) != _aElementType
) return false;
92 ::sal_Sequence
* pNewSequence
= readSequence(_aElementType
, _aSeq
);
94 if (!pNewSequence
) return false;
96 ::com::sun::star::uno::Sequence
<ET
> aNewSequence(pNewSequence
, SAL_NO_ACQUIRE
);
102 //-----------------------------------------------------------------------------
104 //-----------------------------------------------------------------------------
108 #endif // INCLUDED_SHARABLE_SEQUENCE_HXX