update emoji autocorrect entries from po-files
[LibreOffice.git] / include / comphelper / optional.hxx
bloba1ffba09cdf9493ca7a2d04fa2b273cdb555de3a
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 .
19 #ifndef INCLUDED_COMPHELPER_OPTIONAL_HXX
20 #define INCLUDED_COMPHELPER_OPTIONAL_HXX
22 #include <com/sun/star/beans/Optional.hpp>
23 #include <boost/optional.hpp>
25 namespace comphelper {
27 /// Object generators for boost::optional<T>, beans::Optional<T>:
29 template <typename T>
30 inline ::boost::optional<T> make_optional( T const& v )
32 return ::boost::optional<T>(v);
35 template <typename T>
36 inline ::boost::optional<T> make_optional(
37 ::com::sun::star::beans::Optional<T> const& o )
39 if (o.IsPresent)
40 return ::boost::optional<T>(o.Value);
41 else
42 return ::boost::optional<T>();
45 template <typename T>
46 inline ::com::sun::star::beans::Optional<T> makeOptional( T const& v )
48 // CPPU_IS_CPP_MAPPING_OF_NON_VOID_UNO_TYPE(T);
49 return ::com::sun::star::beans::Optional<T>(true, v);
52 template <typename T>
53 inline ::com::sun::star::beans::Optional<T> makeOptional(
54 ::boost::optional<T> const& o )
56 // CPPU_IS_CPP_MAPPING_OF_NON_VOID_UNO_TYPE(T);
57 if (o)
58 return ::com::sun::star::beans::Optional<T>(true, *o);
59 else
60 return ::com::sun::star::beans::Optional<T>();
63 inline ::com::sun::star::beans::Optional<sal_Bool> makeOptional(
64 ::boost::optional<bool> const& o )
66 if (o)
67 return ::com::sun::star::beans::Optional<sal_Bool>(true, *o);
68 else
69 return ::com::sun::star::beans::Optional<sal_Bool>();
72 inline ::com::sun::star::beans::Optional<sal_Bool> makeOptional( bool v )
74 return ::com::sun::star::beans::Optional<sal_Bool>(true, v);
77 } // namespace comphelper
79 #endif // ! defined(INCLUDED_COMPHELPER_OPTIONAL_HXX)
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */