LibreOffice Module comphelper (master) 1
propertyvalue.hxx
Go to the documentation of this file.
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
10#ifndef INCLUDED_COMPHELPER_PROPERTYVALUE_HXX
11#define INCLUDED_COMPHELPER_PROPERTYVALUE_HXX
12
13#include <sal/config.h>
14
15#include <type_traits>
16#include <utility>
17
18#include <com/sun/star/beans/PropertyValue.hpp>
19
20namespace comphelper
21{
29template <typename T, std::enable_if_t<!std::is_arithmetic_v<std::remove_reference_t<T>>, int> = 0>
30css::beans::PropertyValue makePropertyValue(const OUString& rName, T&& rValue)
31{
32 return { rName, 0, css::uno::toAny(std::forward<T>(rValue)),
33 css::beans::PropertyState_DIRECT_VALUE };
34}
35// Allows to pass e.g. bit fields
36template <typename T, std::enable_if_t<std::is_arithmetic_v<T>, int> = 0>
37css::beans::PropertyValue makePropertyValue(const OUString& rName, T aValue)
38{
39 return makePropertyValue(rName, css::uno::toAny(aValue));
40}
41}
42
43#endif // INCLUDED_COMPHELPER_PROPERTYVALUE_HXX
44
45/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Creates a beans::PropertyValue easily, i.e.