1 #ifndef CFGMGR_ANYPAIR_HXX
2 #define CFGMGR_ANYPAIR_HXX
5 #include <com/sun/star/uno/Any.h>
6 #include <com/sun/star/lang/IllegalArgumentException.hpp>
10 namespace css
= com::sun::star
;
11 namespace uno
= css::uno
;
12 namespace lang
= css::lang
;
14 //==========================================================================
15 //= flags for handling the state of an Anypair
16 //==========================================================================
18 cfgmgr_SELECT_FIRST
= 0x01,
19 cfgmgr_SELECT_SECOND
= 0x02,
20 cfgmgr_SELECT_BOTH
= cfgmgr_SELECT_FIRST
| cfgmgr_SELECT_SECOND
23 //==========================================================================
24 //= data structure for descriptive data for an AnyPair
25 //==========================================================================
26 struct cfgmgr_AnyPair_Desc
28 typelib_TypeDescriptionReference
* pType
;
32 inline bool cfgmgr_AnyPair_isNull(cfgmgr_AnyPair_Desc
const* _pDesc
, sal_uInt8 nSelect
)
33 { return (_pDesc
->nState
& nSelect
) == 0; }
35 inline bool cfgmgr_AnyPair_isEmpty(cfgmgr_AnyPair_Desc
const* _pDesc
)
36 { return (typelib_TypeClass_VOID
== _pDesc
->pType
->eTypeClass
); }
38 //==========================================================================
39 //= cfgmgr_AnyPair Basic (POD) data structure for a nullable pair of Anys
40 //==========================================================================
44 cfgmgr_AnyPair_Desc desc
;
49 // -----------------------------------------------------------------------------
50 //==========================================================================
52 //==========================================================================
53 // this AnyPair holds 2 nullable Any's which have to have the same type.
57 cfgmgr_AnyPair m_aAnyPair
;
62 SELECT_FIRST
= cfgmgr_SELECT_FIRST
,
63 SELECT_SECOND
= cfgmgr_SELECT_SECOND
,
64 SELECT_BOTH
= cfgmgr_SELECT_BOTH
67 explicit AnyPair(uno::Type
const& _aType
); // one Type, any's are null
68 explicit AnyPair(uno::Any
const& _aAny
, SelectMember _select
); // one selected any
70 explicit AnyPair(uno::Any
const& _aAny
, uno::Any
const& _aAny2
) SAL_THROW((lang::IllegalArgumentException
));
73 AnyPair(AnyPair
const& _aAny
);
74 AnyPair
& operator=(AnyPair
const& _aAny
);
79 // elementwise setters
80 sal_Bool
setFirst(uno::Any
const& _aAny
);
81 sal_Bool
setSecond(uno::Any
const& _aAny
);
83 // clear data (but not type)
84 void clear(SelectMember _select
= SELECT_BOTH
);
87 // checking state and availablity of values
88 bool isEmpty() const { return cfgmgr_AnyPair_isEmpty(&m_aAnyPair
.desc
); }
90 bool isNull () const { return ! hasValue(); }
92 bool hasValue(SelectMember _select
= SELECT_BOTH
) const
94 return !cfgmgr_AnyPair_isNull(&m_aAnyPair
.desc
, (sal_uInt8
)_select
);
98 return hasValue(SELECT_FIRST
);
100 bool hasSecond() const
102 return hasValue(SELECT_SECOND
);
105 // elementwise getters
106 uno::Type
getValueType() const;
107 uno::Any
getFirst() const;
108 uno::Any
getSecond() const;
109 uno::Any
getValue(SelectMember _select
) const;