20#ifndef INCLUDED_COMPHELPER_SEQUENCE_HXX
21#define INCLUDED_COMPHELPER_SEQUENCE_HXX
23#include <com/sun/star/uno/Sequence.hxx>
24#include <osl/diagnose.h>
34 template <
class T1,
class T2>
35 inline sal_Int32
findValue(
const css::uno::Sequence<T1>& _rList,
const T2& _rValue)
38 for (sal_Int32
i = 0;
i < _rList.getLength(); ++
i)
40 if (_rList[
i] == _rValue)
48 template <
class T,
class... Ss>
49 inline css::uno::Sequence<T>
concatSequences(
const css::uno::Sequence<T>& rS1,
const Ss&... rSn)
52 css::uno::Sequence<T> aReturn(std::size(rS1) + (... + std::size(rSn)));
53 T* pReturn = std::copy(std::begin(rS1), std::end(rS1), aReturn.getArray());
54 (..., (pReturn = std::copy(std::begin(rSn), std::end(rSn), pReturn)));
62 css::uno::Sequence<T>
const & left, css::uno::Sequence<T>
const & right)
64 sal_Int32
n1 =
left.getLength();
65 css::uno::Sequence<T> ret(
n1 +
right.getLength());
67 auto pRet = ret.getArray();
68 std::copy_n(
left.getConstArray(),
n1, pRet);
70 for (sal_Int32
i = 0;
i !=
right.getLength(); ++
i) {
72 for (sal_Int32 j = 0; j !=
n1; ++j) {
90 sal_Int32
nLength = _rSeq.getLength();
94 T* pPos = _rSeq.getArray() +
_nPos;
121 template <
typename DstType,
typename SrcType >
122 inline css::uno::Sequence< DstType >
arrayToSequence(
const SrcType* i_pArray, sal_Int32 nNum )
124 if constexpr (std::is_same_v< DstType, SrcType >)
126 return css::uno::Sequence< DstType >( i_pArray, nNum );
130 css::uno::Sequence< DstType >
result( nNum );
131 ::std::copy( i_pArray, i_pArray+nNum,
result.getArray() );
159 template <
typename DstType,
typename SrcType >
160 inline DstType*
sequenceToArray( DstType* io_pArray,
const css::uno::Sequence< SrcType >& i_Sequence )
162 ::std::copy( i_Sequence.begin(), i_Sequence.end(), io_pArray );
189 template <
typename DstElementType,
typename SrcType >
192 using ::std::size, ::std::begin, ::std::end;
193 css::uno::Sequence< DstElementType >
result(
size(i_Container) );
194 ::std::copy(
begin(i_Container),
end(i_Container),
result.getArray() );
199 template <
typename SrcType >
200 inline css::uno::Sequence< typename SrcType::value_type >
containerToSequence(
const SrcType& i_Container )
202 return containerToSequence<typename SrcType::value_type, SrcType>(i_Container);
206 template<
typename ElementType, std::
size_t SrcSize>
209 return css::uno::Sequence< ElementType >( i_Array, SrcSize );
212 template <
typename T>
214 ::std::vector<T>
const& v )
216 return css::uno::Sequence<T>(
217 v.data(),
static_cast<sal_Int32
>(
v.size()) );
242 template <
typename DstType,
typename SrcType >
245 return DstType(i_Sequence.begin(), i_Sequence.end());
249 template <
typename DstType >
250 inline DstType
sequenceToContainer(
const css::uno::Sequence< typename DstType::value_type >& i_Sequence )
252 return DstType(i_Sequence.begin(), i_Sequence.end());
285 template <
typename DstType,
typename SrcType >
288 o_Output.resize( i_Sequence.getLength() );
289 ::std::copy( i_Sequence.begin(), i_Sequence.end(), o_Output.begin() );
299 template <
typename M >
302 css::uno::Sequence< typename M::key_type > ret(
static_cast<sal_Int32
>(
map.size()) );
303 std::transform(
map.begin(),
map.end(), ret.getArray(),
304 [](
const auto&
i) { return i.first; });
308 template <
typename M >
311 css::uno::Sequence< typename M::mapped_type > ret(
static_cast<sal_Int32
>(
map.size()) );
312 std::transform(
map.begin(),
map.end(), ret.getArray(),
313 [](
const auto&
i) { return i.second; });
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
Search the given value within the given sequence, return the position of the first occurrence.
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
concat several sequences
DstType * sequenceToArray(DstType *io_pArray, const css::uno::Sequence< SrcType > &i_Sequence)
Copy from a Sequence into a plain C/C++ array.
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
Copy from a Sequence into a container.
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
Copy (keys or values) from an associate container into a Sequence.
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Copy from a container into a Sequence.
css::uno::Sequence< typename M::mapped_type > mapValuesToSequence(M const &map)
css::uno::Sequence< DstType > arrayToSequence(const SrcType *i_pArray, sal_Int32 nNum)
Copy from a plain C/C++ array into a Sequence.
void removeElementAt(css::uno::Sequence< T > &_rSeq, sal_Int32 _nPos)
remove a specified element from a sequences
css::uno::Sequence< T > combineSequences(css::uno::Sequence< T > const &left, css::uno::Sequence< T > const &right)
concat additional elements from right sequence to left sequence
enumrange< T >::Iterator begin(enumrange< T >)
std::map< OUString, rtl::Reference< Entity > > map