Branch data Line data Source code
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 : : #include "sal/config.h"
21 : :
22 : : #include <cassert>
23 : :
24 : : #include "typelib/typeclass.h"
25 : : #include "typelib/typedescription.hxx"
26 : : #include "uno/any2.h"
27 : :
28 : : #include "binaryany.hxx"
29 : :
30 : : namespace binaryurp {
31 : :
32 : : namespace {
33 : :
34 : : namespace css = com::sun::star;
35 : :
36 : : }
37 : :
38 : 913441 : BinaryAny::BinaryAny() throw () {
39 : 913441 : uno_any_construct(&data_, 0, 0, 0);
40 : 913446 : }
41 : :
42 : 1500926 : BinaryAny::BinaryAny(css::uno::TypeDescription const & type, void * value)
43 : : throw ()
44 : : {
45 : : assert(type.is());
46 : 1500926 : uno_any_construct(&data_, value, type.get(), 0);
47 : 1500926 : }
48 : :
49 : 35827 : BinaryAny::BinaryAny(uno_Any const & raw) throw () {
50 : : assert(raw.pType != 0);
51 : 35827 : data_.pType = raw.pType;
52 : 35827 : typelib_typedescriptionreference_acquire(data_.pType);
53 [ - + ]: 35827 : data_.pData = raw.pData == &raw.pReserved ? &data_.pReserved : raw.pData;
54 : 35827 : data_.pReserved = raw.pReserved;
55 : 35827 : }
56 : :
57 : 2466518 : BinaryAny::BinaryAny(BinaryAny const & other) throw () {
58 : 2466518 : uno_type_any_construct(&data_, other.data_.pData, other.data_.pType, 0);
59 : 2466518 : }
60 : :
61 : 4916860 : BinaryAny::~BinaryAny() throw () {
62 : 4916860 : uno_any_destruct(&data_, 0);
63 : 4916884 : }
64 : :
65 : 724289 : BinaryAny & BinaryAny::operator =(BinaryAny const & other) throw () {
66 [ + - ]: 724289 : if (&other != this) {
67 : 724289 : uno_type_any_assign(&data_, other.data_.pData, other.data_.pType, 0, 0);
68 : : }
69 : 724289 : return *this;
70 : : }
71 : :
72 : 212 : uno_Any * BinaryAny::get() throw () {
73 : 212 : return &data_;
74 : : }
75 : :
76 : 260 : css::uno::TypeDescription BinaryAny::getType() const throw () {
77 : 260 : return css::uno::TypeDescription(data_.pType);
78 : : }
79 : :
80 : 1596142 : void * BinaryAny::getValue(css::uno::TypeDescription const & type) const
81 : : throw ()
82 : : {
83 : : assert(
84 : : type.is() &&
85 : : (type.get()->eTypeClass == typelib_TypeClass_ANY ||
86 : : type.equals(css::uno::TypeDescription(data_.pType))));
87 : 1596142 : return type.get()->eTypeClass == typelib_TypeClass_ANY
88 [ + + ]: 1596142 : ? &data_ : data_.pData;
89 : : }
90 : :
91 : : }
92 : :
93 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|