fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / comphelper / makesequence.hxx
blobbc35657db9a896f0bf5945d08a8388aa438a5a7b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef COMPHELPER_MAKESEQUENCE_HXX_INCLUDED
21 #define COMPHELPER_MAKESEQUENCE_HXX_INCLUDED
23 #include "com/sun/star/uno/Sequence.hxx"
24 #include "boost/preprocessor/cat.hpp"
25 #include "boost/preprocessor/repetition.hpp"
26 #include "boost/preprocessor/arithmetic/add.hpp"
28 namespace comphelper {
30 /** Creates a uno::Sequence out of one parameter.
32 template <typename T>
33 inline ::com::sun::star::uno::Sequence<T> makeSequence( T const& element )
35 return ::com::sun::star::uno::Sequence<T>( &element, 1 );
38 #define COMPHELPER_MAKESEQUENCE_assign(z_, n_, unused_) \
39 p[n_] = BOOST_PP_CAT(element, n_);
41 /** The following preprocessor repetitions generate functions like
43 <pre>
44 template <typename T>
45 inline ::com::sun::star::uno::Sequence<T> makeSequence(
46 T const& element0, T const& element1, ... );
47 </pre>
49 which make a sequence out of the passed elements.
51 The maximum number of elements can be set by defining
52 COMPHELPER_MAKESEQUENCE_MAX_ARGS; its default is 12.
54 #define COMPHELPER_MAKESEQUENCE_make(z_, n_, unused_) \
55 template <typename T> \
56 inline ::com::sun::star::uno::Sequence<T> makeSequence( \
57 BOOST_PP_ENUM_PARAMS(n_, T const& element) ) \
58 { \
59 ::com::sun::star::uno::Sequence<T> seq( n_ ); \
60 T * p = seq.getArray(); \
61 BOOST_PP_REPEAT(n_, COMPHELPER_MAKESEQUENCE_assign, ~) \
62 return seq; \
65 #ifndef COMPHELPER_MAKESEQUENCE_MAX_ARGS
66 #define COMPHELPER_MAKESEQUENCE_MAX_ARGS 12
67 #endif
69 BOOST_PP_REPEAT_FROM_TO(2, BOOST_PP_ADD(COMPHELPER_MAKESEQUENCE_MAX_ARGS, 1),
70 COMPHELPER_MAKESEQUENCE_make, ~)
72 #undef COMPHELPER_MAKESEQUENCE_MAX_ARGS
73 #undef COMPHELPER_MAKESEQUENCE_make
74 #undef COMPHELPER_MAKESEQUENCE_assign
76 } // namespace comphelper
78 #endif // ! defined(COMPHELPER_MAKESEQUENCE_HXX_INCLUDED)
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */