LibreOffice
LibreOffice 4.2 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 #ifndef INCLUDED_cppu_Map_hxx
21 #define INCLUDED_cppu_Map_hxx
22 
23 #include <uno/mapping.hxx>
24 
25 
26 namespace cssu = com::sun::star::uno;
27 
28 namespace cppu
29 {
41  template<class T> inline T * mapOut(T * pT, cssu::Environment const & outerEnv)
42  {
43  cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv);
44 
45  return reinterpret_cast<T *>(curr2outer.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL)));
46  }
47 
48 
56  template<class T> inline T * mapIn(T * pT, cssu::Environment const & outerEnv)
57  {
58  cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent());
59 
60  return reinterpret_cast<T *>(outer2curr.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL)));
61  }
62 
63 
71  // Problem: any gets assigned to something, acquire/releases may be called in wrong env.
72  inline void mapOutAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv)
73  {
74  cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv);
75 
78  res,
79  const_cast<void *>(any.getValue()),
80  any.getValueTypeRef(),
81  curr2outer.get());
82  }
83 
84 
92  inline void mapInAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv)
93  {
94  cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent());
95 
98  res,
99  const_cast<void *>(any.getValue()),
100  any.getValueTypeRef(),
101  outer2curr.get());
102  }
103 }
104 
105 #endif
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void * mapInterface(void *pInterface, typelib_InterfaceTypeDescription *pTypeDescr) const
Maps an interface from one environment to another.
Definition: mapping.hxx:274
T * mapIn(T *pT, cssu::Environment const &outerEnv)
Maps an object from an outer Environment to the current, returns mapped object.
Definition: Map.hxx:56
void mapInAny(cssu::Any const &any, cssu::Any *res, cssu::Environment const &outerEnv)
Maps an any from an outer Environment to the current, fills passed any.
Definition: Map.hxx:92
void cpp_release(void *pCppI)
Function to release a C++ interface.
Definition: genfunc.hxx:42
typelib_TypeDescriptionReference * getValueTypeRef() const
Gets the type of the set value.
Definition: Any.h:122
void(* uno_ReleaseFunc)(void *pInterface)
Generic function pointer declaration to release an interface.
Definition: data.h:52
uno_Mapping * get() const
Provides a pointer to the C mapping.
Definition: mapping.hxx:133
void mapOutAny(cssu::Any const &any, cssu::Any *res, cssu::Environment const &outerEnv)
Maps an any from the current to an outer Environment, fills passed any.
Definition: Map.hxx:72
static Environment getCurrent(rtl::OUString const &typeName=rtl::OUString(CPPU_STRINGIFY(CPPU_ENV)))
Returns the current Environment.
Definition: environment.hxx:250
const void * getValue() const
Gets a pointer to the set value.
Definition: Any.h:157
C++ wrapper for C uno_Mapping.
Definition: mapping.hxx:48
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:32
C++ class representing an IDL any.
Definition: Any.h:46
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_DLLPUBLIC void uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Destructs an any.
T * mapOut(T *pT, cssu::Environment const &outerEnv)
Helpers for mapping objects relative to the current environment.
Definition: Map.hxx:41
C++ wrapper for binary C uno_Environment.
Definition: environment.hxx:45
const ::com::sun::star::uno::Type & getCppuType(SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Any *)
Gets the meta type of IDL type any.
Definition: Any.h:364