namespace com
{ namespace sun
{ namespace star
{ namespace uno
{
/// @cond INTERNAL template< class E >
typelib_TypeDescriptionReference * Sequence< E >::s_pType = NULL; /// @endcond
template< class E > inline Sequence< E >::Sequence()
{ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
::uno_type_sequence_construct(
&_pSequence, rType.getTypeLibType(),
NULL, 0, cpp_acquire ); // no bad_alloc, because empty sequence is statically allocated in cppu
}
template< class E > inline Sequence< E >::Sequence( const Sequence & rSeq )
{
osl_atomic_increment( &rSeq._pSequence->nRefCount );
_pSequence = rSeq._pSequence;
}
template< class E > inline Sequence< E >::Sequence(
uno_Sequence * pSequence, __sal_NoAcquire )
: _pSequence( pSequence )
{
}
template< class E > inline Sequence< E >::Sequence( const E * pElements, sal_Int32 len )
{ const Type & rType = ::cppu::getTypeFavourUnsigned( this );
template< class E > inlinebool Sequence< E >::operator == ( const Sequence & rSeq ) const
{ if (_pSequence == rSeq._pSequence) returntrue; if (_pSequence->nElements != rSeq._pSequence->nElements) returnfalse; const Type & rType = ::cppu::getTypeFavourUnsigned( this ); return ::uno_type_equalData( const_cast< Sequence * >( this ), rType.getTypeLibType(), const_cast< Sequence * >( &rSeq ), rType.getTypeLibType(),
cpp_queryInterface,
cpp_release );
}
template< class E > inlinebool Sequence< E >::operator != ( const Sequence & rSeq ) const
{ return (! operator == ( rSeq ));
}
template< class E > inline E * Sequence< E >::getArray()
{ const Type & rType = ::cppu::getTypeFavourUnsigned( this ); bool success =
::uno_type_sequence_reference2One(
&_pSequence, rType.getTypeLibType(),
cpp_acquire, cpp_release ); if (! success) throw ::std::bad_alloc(); returnreinterpret_cast< E * >( _pSequence->elements );
}
template <class E> inlineauto asNonConstRange(css::uno::Sequence<E>& s)
{ // Two iterators [begin, end] representing the non-const range of the Sequence. // It only calls Sequence::getArray once, to avoid the second COW overhead when // Sequence::begin() and Sequence::end() are called in pairs. // Inheriting from pair allows to use std::tie to unpack the two iterators. struct SequenceRange : public std::pair<E*, E*>
{
SequenceRange(E* ptr, sal_Int32 len) : std::pair<E*, E*>(ptr, ptr + len) {} // These allow to pass it as range-expression to range-based for loops
E* begin() { return std::pair<E*, E*>::first; }
E* end() { return std::pair<E*, E*>::second; }
E& operator[](sal_Int32 i) { assert(i >= 0 && i < end() - begin()); return begin()[i]; }
}; return SequenceRange(s.getLength() ? s.getArray() : nullptr, s.getLength());
};
/// @endcond
#endif
}
}
}
}
namespace cppu {
template< typename T > inline ::com::sun::star::uno::Type const &
getTypeFavourUnsigned(
SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
{ if (::com::sun::star::uno::Sequence< T >::s_pType == NULL) {
::typelib_static_sequence_type_init(
&::com::sun::star::uno::Sequence< T >::s_pType,
(::cppu::getTypeFavourUnsigned( static_cast< typename ::com::sun::star::uno::Sequence< T >::ElementType * >(
NULL)).
getTypeLibType()));
} return detail::getTypeFromTypeDescriptionReference(
&::com::sun::star::uno::Sequence< T >::s_pType);
}
template< typename T > inline ::com::sun::star::uno::Type const &
getTypeFavourChar(
SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
{ //TODO On certain platforms with weak memory models, the following code can // result in some threads observing that td points to garbage: static typelib_TypeDescriptionReference * td = NULL; if (td == NULL) {
::typelib_static_sequence_type_init(
&td,
(::cppu::getTypeFavourChar( static_cast< typename ::com::sun::star::uno::Sequence< T >::ElementType * >(
NULL)).
getTypeLibType()));
} return detail::getTypeFromTypeDescriptionReference(&td);
}
}
// generic sequence template template< class E > inlineconst ::com::sun::star::uno::Type &
SAL_CALL getCppuType(
SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Sequence< E > * )
{ return ::cppu::getTypeFavourUnsigned( static_cast< ::com::sun::star::uno::Sequence< E > * >(0));
}
// generic sequence template for given element type (e.g. C++ arrays) template< class E > inlineconst ::com::sun::star::uno::Type &
SAL_CALL getCppuSequenceType( const ::com::sun::star::uno::Type & rElementType )
{ if (! ::com::sun::star::uno::Sequence< E >::s_pType)
{
::typelib_static_sequence_type_init(
& ::com::sun::star::uno::Sequence< E >::s_pType,
rElementType.getTypeLibType() );
} return * reinterpret_cast< const ::com::sun::star::uno::Type * >(
& ::com::sun::star::uno::Sequence< E >::s_pType );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.