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 "osl/mutex.hxx"
11 : #include "rtl/string.h"
12 : #include "rtl/ustrbuf.hxx"
13 : #include "rtl/ustring.h"
14 : #include "rtl/ustring.hxx"
15 : #include "rtl/instance.hxx"
16 : #include "sal/types.h"
17 : #include "typelib/typeclass.h"
18 : #include "typelib/typedescription.h"
19 :
20 : namespace com { namespace sun { namespace star { namespace beans {
21 :
22 : template< typename typeparam_T > inline Optional< typeparam_T >::Optional() SAL_THROW(())
23 : : IsPresent(false)
24 : , Value()
25 : {
26 : }
27 :
28 : template< typename typeparam_T > inline Optional< typeparam_T >::Optional(const ::sal_Bool& IsPresent_, typeparam_T const & Value_) SAL_THROW(())
29 : : IsPresent(IsPresent_)
30 : , Value(Value_)
31 : {
32 : }
33 :
34 : template< typename typeparam_T >
35 : inline Optional< typeparam_T >
36 : make_Optional(const ::sal_Bool& IsPresent_, typeparam_T const & Value_) SAL_THROW(())
37 : {
38 : return Optional< typeparam_T >(IsPresent_, Value_);
39 : }
40 :
41 : } } } }
42 :
43 : namespace cppu { namespace detail {
44 :
45 : template< typename typeparam_T > struct theOptionalType : public rtl::StaticWithInit< ::com::sun::star::uno::Type *, theOptionalType< typeparam_T > >
46 : {
47 1 : ::com::sun::star::uno::Type * operator()() const
48 : {
49 1 : ::rtl::OUStringBuffer the_buffer;
50 1 : the_buffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("com.sun.star.beans.Optional<"));
51 1 : the_buffer.append(::cppu::getTypeFavourChar(static_cast< typeparam_T * >(0)).getTypeName());
52 1 : the_buffer.append(static_cast< ::sal_Unicode >('>'));
53 1 : ::rtl::OUString the_name(the_buffer.makeStringAndClear());
54 1 : ::rtl::OUString the_tname0( "boolean" );
55 1 : ::rtl::OUString the_name0( "IsPresent" );
56 1 : ::com::sun::star::uno::Type const & the_ptype0 = ::cppu::getTypeFavourChar(static_cast< typeparam_T * >(0));
57 1 : ::typelib_TypeClass the_pclass0 = (::typelib_TypeClass) the_ptype0.getTypeClass();
58 1 : ::rtl::OUString the_pname0(the_ptype0.getTypeName());
59 1 : ::rtl::OUString the_name1( "Value" );
60 : ::typelib_StructMember_Init the_members[] = {
61 : { { typelib_TypeClass_BOOLEAN, the_tname0.pData, the_name0.pData }, false },
62 1 : { { the_pclass0, the_pname0.pData, the_name1.pData }, true } };
63 1 : ::typelib_TypeDescription * the_newType = 0;
64 1 : ::typelib_typedescription_newStruct(&the_newType, the_name.pData, 0, 2, the_members);
65 1 : ::typelib_typedescription_register(&the_newType);
66 1 : ::typelib_typedescription_release(the_newType);
67 1 : return new ::com::sun::star::uno::Type(::com::sun::star::uno::TypeClass_STRUCT, the_name); // leaked
68 : }
69 : };
70 : } }
71 :
72 : namespace cppu {
73 :
74 : template< typename typeparam_T > class UnoType< css::beans::Optional< typeparam_T > > {
75 : public:
76 9 : static inline ::com::sun::star::uno::Type const & get() {
77 9 : return *detail::theOptionalType< typeparam_T >::get();
78 : }
79 :
80 : private:
81 : UnoType(UnoType &); // not defined
82 : ~UnoType(); // not defined
83 : void operator =(UnoType); // not defined
84 : };
85 :
86 : }
87 :
88 1 : template< typename typeparam_T > inline ::com::sun::star::uno::Type const & SAL_CALL getCppuType(SAL_UNUSED_PARAMETER css::beans::Optional< typeparam_T > const *) SAL_THROW(()) {
89 1 : return ::cppu::UnoType< css::beans::Optional< typeparam_T > >::get();
90 : }
91 :
92 : #endif // INCLUDED_COM_SUN_STAR_BEANS_OPTIONAL_HPP
|