LibreOffice: cppu/Map.hxx Source File

LibreOffice LibreOffice 7.6 SDK C/C++ API Reference

Loading...
Searching...
No Matches
Map.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 * 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/*
21 * This file is part of LibreOffice published API.
22 */
23
24#ifndef INCLUDED_CPPU_MAP_HXX
25#define INCLUDED_CPPU_MAP_HXX
26
27#include "uno/mapping.hxx"
28
29
30namespace cppu
31{
43 template<class T> inline T * mapOut(T * pT, css::uno::Environment const & outerEnv)
44 {
45 css::uno::Mapping curr2outer(css::uno::Environment::getCurrent(), outerEnv);
46
47 return reinterpret_cast<T *>(curr2outer.mapInterface(pT, cppu::UnoType<T>::get()));
48 }
49
50
58 template<class T> inline T * mapIn(T * pT, css::uno::Environment const & outerEnv)
59 {
60 css::uno::Mapping outer2curr(outerEnv, css::uno::Environment::getCurrent());
61
62 return reinterpret_cast<T *>(outer2curr.mapInterface(pT, cppu::UnoType<T>::get()));
63 }
64
65
73 // Problem: any gets assigned to something, acquire/releases may be called in wrong env.
74 inline void mapOutAny(css::uno::Any const & any, css::uno::Any * res, css::uno::Environment const & outerEnv)
75 {
76 css::uno::Mapping curr2outer(css::uno::Environment::getCurrent(), outerEnv);
77
78 uno_any_destruct(res, css::uno::cpp_release);
79 uno_type_any_constructAndConvert(
80 res,
81 const_cast<void *>(any.getValue()),
82 any.getValueTypeRef(),
83 curr2outer.get());
84 }
85
86
94 inline void mapInAny(css::uno::Any const & any, css::uno::Any * res, css::uno::Environment const & outerEnv)
95 {
96 css::uno::Mapping outer2curr(outerEnv, css::uno::Environment::getCurrent());
97
98 uno_any_destruct(res, css::uno::cpp_release);
99 uno_type_any_constructAndConvert(
100 res,
101 const_cast<void *>(any.getValue()),
102 any.getValueTypeRef(),
103 outer2curr.get());
104 }
105}
106
107#endif
108
109/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
uno_any_destruct
CPPU_DLLPUBLIC void uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Destructs an any.
uno_type_any_constructAndConvert
CPPU_DLLPUBLIC void uno_type_any_constructAndConvert(uno_Any *pDest, void *pSource, struct _typelib_TypeDescriptionReference *pType, struct _uno_Mapping *mapping) SAL_THROW_EXTERN_C()
Constructs an any with a given value and converts/ maps interfaces.
cppu
Definition Enterable.hxx:31
cppu::mapOutAny
void mapOutAny(css::uno::Any const &any, css::uno::Any *res, css::uno::Environment const &outerEnv)
Maps an any from the current to an outer Environment, fills passed any.
Definition Map.hxx:74
cppu::mapIn
T * mapIn(T *pT, css::uno::Environment const &outerEnv)
Maps an object from an outer Environment to the current, returns mapped object.
Definition Map.hxx:58
cppu::mapInAny
void mapInAny(css::uno::Any const &any, css::uno::Any *res, css::uno::Environment const &outerEnv)
Maps an any from an outer Environment to the current, fills passed any.
Definition Map.hxx:94
cppu::mapOut
T * mapOut(T *pT, css::uno::Environment const &outerEnv)
Helpers for mapping objects relative to the current environment.
Definition Map.hxx:43
cppu::UnoType
Get the css::uno::Type instance representing a certain UNO type.
Definition unotype.hxx:290
mapping.hxx