Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/comphelper/unwrapargs.hxx
Line
Count
Source
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
20
#ifndef INCLUDED_COMPHELPER_UNWRAPARGS_HXX
21
#define INCLUDED_COMPHELPER_UNWRAPARGS_HXX
22
23
#include <sal/config.h>
24
25
#include <optional>
26
27
#include <com/sun/star/uno/Sequence.hxx>
28
#include <com/sun/star/uno/XInterface.hpp>
29
#include <com/sun/star/lang/IllegalArgumentException.hpp>
30
#include <cppu/unotype.hxx>
31
32
namespace comphelper {
33
34
/// @internal
35
namespace detail {
36
    inline void unwrapArgsError(
37
        const OUString& str, sal_Int32 nArg,
38
        const css::uno::Reference< css::uno::XInterface >& xErrorContext =
39
          css::uno::Reference< css::uno::XInterface >() )
40
0
    {
41
0
        throw css::lang::IllegalArgumentException(
42
0
            str, xErrorContext, static_cast< sal_Int16 >( nArg ) );
43
0
    }
44
45
    template< typename T, typename... Args >
46
    inline void unwrapArgsError( const OUString& str, sal_Int32 nArg, T&, Args&... args )
47
0
    {
48
0
        return unwrapArgsError( str, nArg, args... );
49
0
    }
Unexecuted instantiation: void comphelper::detail::unwrapArgsError<std::__1::optional<rtl::OUString>, std::__1::optional<bool> >(rtl::OUString const&, int, std::__1::optional<rtl::OUString>&, std::__1::optional<bool>&)
Unexecuted instantiation: void comphelper::detail::unwrapArgsError<std::__1::optional<bool>>(rtl::OUString const&, int, std::__1::optional<bool>&)
50
51
    inline void unwrapArgs(
52
        const css::uno::Sequence< css::uno::Any >&,
53
        sal_Int32,
54
        const css::uno::Reference< css::uno::XInterface >& )
55
0
    {
56
0
        return;
57
0
    }
58
59
    inline void unwrapArgs(
60
        const css::uno::Sequence< css::uno::Any >&,
61
        sal_Int32 )
62
0
    {
63
0
        return;
64
0
    }
65
66
    template< typename T, typename... Args >
67
    inline void unwrapArgs(
68
        const css::uno::Sequence< css::uno::Any >& seq,
69
        sal_Int32 nArg, ::std::optional< T >& v, Args&... args );
70
71
    template< typename T, typename... Args >
72
    inline void unwrapArgs(
73
        const css::uno::Sequence< css::uno::Any >& seq,
74
        sal_Int32 nArg, T& v, Args&... args )
75
0
    {
76
0
        if( seq.getLength() <= nArg )
77
0
        {
78
0
            return unwrapArgsError( u"No such argument available!"_ustr,
79
0
                                     nArg, args... );
80
0
        }
81
0
        if( !fromAny( seq[nArg], &v ) )
82
0
        {
83
0
            OUString msg =
84
0
                "Cannot extract ANY { " +
85
0
                seq[nArg].getValueTypeName() +
86
0
                " } to " +
87
0
                ::cppu::UnoType<T>::get().getTypeName() +
88
0
                "!";
89
0
            return unwrapArgsError( msg, nArg, args... );
90
0
        }
91
0
        return unwrapArgs( seq, ++nArg, args... );
92
0
    }
Unexecuted instantiation: void comphelper::detail::unwrapArgs<rtl::OUString, std::__1::optional<rtl::OUString>, std::__1::optional<bool> >(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, int, rtl::OUString&, std::__1::optional<rtl::OUString>&, std::__1::optional<bool>&)
Unexecuted instantiation: void comphelper::detail::unwrapArgs<rtl::OUString, std::__1::optional<bool> >(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, int, rtl::OUString&, std::__1::optional<bool>&)
Unexecuted instantiation: void comphelper::detail::unwrapArgs<bool>(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, int, bool&)
93
94
    template< typename T, typename... Args >
95
    inline void unwrapArgs(
96
        const css::uno::Sequence< css::uno::Any >& seq,
97
        sal_Int32 nArg, ::std::optional< T >& v, Args&... args )
98
0
    {
99
0
        if( nArg < seq.getLength() )
100
0
        {
101
0
            T t;
102
0
            unwrapArgs( seq, nArg, t, args... );
103
0
            v = t;
104
0
        } else {
105
0
            unwrapArgs( seq, ++nArg, args... );
106
0
        }
107
0
    }
Unexecuted instantiation: void comphelper::detail::unwrapArgs<rtl::OUString, std::__1::optional<bool> >(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, int, std::__1::optional<rtl::OUString>&, std::__1::optional<bool>&)
Unexecuted instantiation: void comphelper::detail::unwrapArgs<bool>(com::sun::star::uno::Sequence<com::sun::star::uno::Any> const&, int, std::__1::optional<bool>&)
108
}
109
110
template< typename... Args >
111
inline void unwrapArgs(
112
    const css::uno::Sequence< css::uno::Any >& seq,
113
    Args&... args )
114
0
{
115
0
    return detail::unwrapArgs( seq, 0, args... );
116
0
}
117
118
} // namespace comphelper
119
120
#endif //  ! defined( INCLUDED_COMPHELPER_UNWRAPARGS_HXX)
121
122
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */