Branch data Line data Source code
1 : : #ifndef INCLUDED_COM_SUN_STAR_BEANS_OPTIONAL_HPP
2 : : #define INCLUDED_COM_SUN_STAR_BEANS_OPTIONAL_HPP
3 : :
4 : : #include "sal/config.h"
5 : :
6 : : #include "com/sun/star/beans/Optional.hdl"
7 : :
8 : : #include "com/sun/star/uno/Type.hxx"
9 : : #include "cppu/unotype.hxx"
10 : : #include "rtl/strbuf.hxx"
11 : : #include "rtl/textenc.h"
12 : : #include "rtl/ustring.hxx"
13 : : #include "sal/types.h"
14 : : #include "typelib/typeclass.h"
15 : : #include "typelib/typedescription.h"
16 : :
17 : : namespace com { namespace sun { namespace star { namespace beans {
18 : :
19 : 2670 : template< typename typeparam_T > inline Optional< typeparam_T >::Optional() SAL_THROW(())
20 : : : IsPresent(false)
21 : 2670 : , Value()
22 : : {
23 : 2670 : }
24 : :
25 : 17334 : template< typename typeparam_T > inline Optional< typeparam_T >::Optional(const ::sal_Bool& IsPresent_, typeparam_T const & Value_) SAL_THROW(())
26 : : : IsPresent(IsPresent_)
27 : 17334 : , Value(Value_)
28 : : {
29 : 17334 : }
30 : :
31 : : template< typename typeparam_T >
32 : : inline Optional< typeparam_T >
33 : : make_Optional(const ::sal_Bool& IsPresent_, typeparam_T const & Value_) SAL_THROW(())
34 : : {
35 : : return Optional< typeparam_T >(IsPresent_, Value_);
36 : : }
37 : :
38 : : } } } }
39 : :
40 : : namespace cppu {
41 : :
42 : : template< typename typeparam_T > class UnoType< ::com::sun::star::beans::Optional< typeparam_T > > {
43 : : public:
44 : 1940 : static inline ::com::sun::star::uno::Type const & get() {
45 : : //TODO: On certain platforms with weak memory models, the following code can result in some threads observing that the_type points to garbage
46 : : static ::typelib_TypeDescriptionReference * the_type = 0;
47 [ + + ]: 1940 : if (the_type == 0) {
48 : 478 : ::rtl::OStringBuffer the_buffer("com.sun.star.beans.Optional<");
49 [ + - ][ + - ]: 478 : the_buffer.append(::rtl::OUStringToOString(::cppu::getTypeFavourChar(static_cast< typeparam_T * >(0)).getTypeName(), RTL_TEXTENCODING_UTF8));
50 [ + - ]: 478 : the_buffer.append('>');
51 : 478 : ::typelib_static_type_init(&the_type, typelib_TypeClass_STRUCT, the_buffer.getStr());
52 : : }
53 : 1940 : return *reinterpret_cast< ::com::sun::star::uno::Type * >(&the_type);
54 : : }
55 : :
56 : : private:
57 : : UnoType(UnoType &); // not defined
58 : : ~UnoType(); // not defined
59 : : void operator =(UnoType); // not defined
60 : : };
61 : :
62 : : }
63 : :
64 : : template< typename typeparam_T > inline ::com::sun::star::uno::Type const & SAL_CALL getCppuType(SAL_UNUSED_PARAMETER ::com::sun::star::beans::Optional< typeparam_T > const *) SAL_THROW(()) {
65 : : return ::cppu::UnoType< ::com::sun::star::beans::Optional< typeparam_T > >::get();
66 : : }
67 : :
68 : : #endif // INCLUDED_COM_SUN_STAR_BEANS_OPTIONAL_HPP
|