LibreOffice: cppu/Map.hxx Source File

LibreOffice LibreOffice 25.8 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{
35
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.
com::sun::star::uno::cpp_release
void cpp_release(void *pCppI)
Function to release a C++ interface.
Definition genfunc.hxx:50
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
com::sun::star::uno::Environment
C++ wrapper for binary C uno_Environment.
Definition environment.hxx:50
com::sun::star::uno::Environment::getCurrent
static Environment getCurrent(rtl::OUString const &typeName=rtl::OUString(CPPU_CURRENT_LANGUAGE_BINDING_NAME))
Returns the current Environment.
Definition environment.hxx:270
com::sun::star::uno::Mapping
C++ wrapper for C uno_Mapping.
Definition mapping.hxx:58
com::sun::star::uno::Mapping::mapInterface
void * mapInterface(void *pInterface, typelib_InterfaceTypeDescription *pTypeDescr) const
Maps an interface from one environment to another.
Definition mapping.hxx:292
com::sun::star::uno::Mapping::get
uno_Mapping * get() const
Provides a pointer to the C mapping.
Definition mapping.hxx:155
cppu::UnoType::get
static css::uno::Type const & get()
Definition unotype.hxx:292
com::sun::star::uno::Any
C++ class representing an IDL any.
Definition Any.h:58
com::sun::star::uno::Any::getValueTypeRef
typelib_TypeDescriptionReference * getValueTypeRef() const
Gets the type of the set value.
Definition Any.h:165
com::sun::star::uno::Any::getValue
const void * getValue() const
Gets a pointer to the set value.
Definition Any.h:200
mapping.hxx