24 #ifndef INCLUDED_CPPUHELPER_PROPTYPEHLP_HXX
25 #define INCLUDED_CPPUHELPER_PROPTYPEHLP_HXX
28 #include "com/sun/star/lang/IllegalArgumentException.hpp"
29 #include "com/sun/star/uno/TypeClass.hpp"
34 template <
class target >
38 if( !( a >>= value ) ) {
39 throw css::lang::IllegalArgumentException();
46 switch( a.getValueType().getTypeClass() ) {
47 case css::uno::TypeClass_BYTE:
50 case css::uno::TypeClass_SHORT:
51 b = a.get<sal_Int16>() != 0;
53 case css::uno::TypeClass_UNSIGNED_SHORT:
60 case css::uno::TypeClass_LONG:
61 b = a.get<sal_Int32>() != 0;
63 case css::uno::TypeClass_UNSIGNED_LONG:
64 b = a.get<sal_uInt32>() != 0;
66 case css::uno::TypeClass_CHAR:
73 throw css::lang::IllegalArgumentException();
87 switch( a.getValueType().getTypeClass() ) {
88 case css::uno::TypeClass_BOOLEAN:
89 i =
static_cast<sal_Int64
>(a.get<
bool>());
91 case css::uno::TypeClass_CHAR:
94 c = *
static_cast<sal_Unicode const *
>(a.getValue());
95 i =
static_cast<sal_Int64
>(c);
99 throw css::lang::IllegalArgumentException();
108 switch( a.getValueType().getTypeClass() ) {
109 case css::uno::TypeClass_BOOLEAN:
110 i =
static_cast<sal_uInt64
>(a.get<
bool>());
112 case css::uno::TypeClass_CHAR:
115 c = *
static_cast<sal_Unicode const *
>(a.getValue());
116 i =
static_cast<sal_uInt64
>(c);
120 throw css::lang::IllegalArgumentException();
128 switch( a.getValueType().getTypeClass() ) {
129 case css::uno::TypeClass_BOOLEAN:
130 i =
static_cast<sal_Int32
>(a.get<
bool>());
132 case css::uno::TypeClass_CHAR:
135 c = *
static_cast<sal_Unicode const *
>(a.getValue());
136 i =
static_cast<sal_Int32
>(c);
140 throw css::lang::IllegalArgumentException();
148 switch( a.getValueType().getTypeClass() ) {
149 case css::uno::TypeClass_BOOLEAN:
150 i =
static_cast<sal_uInt32
>(a.get<
bool>());
152 case css::uno::TypeClass_CHAR:
155 c = *
static_cast<sal_Unicode const *
>(a.getValue());
156 i =
static_cast<sal_uInt32
>(c);
160 throw css::lang::IllegalArgumentException();
168 switch( a.getValueType().getTypeClass() ) {
169 case css::uno::TypeClass_BOOLEAN:
170 i =
static_cast<sal_Int16
>(a.get<
bool>());
172 case css::uno::TypeClass_CHAR:
175 c = *
static_cast<sal_Unicode const *
>(a.getValue());
176 i =
static_cast<sal_Int16
>(c);
180 throw css::lang::IllegalArgumentException();
188 switch( a.getValueType().getTypeClass() ) {
189 case css::uno::TypeClass_BOOLEAN:
190 i =
static_cast<sal_uInt16
>(a.get<
bool>());
192 case css::uno::TypeClass_CHAR:
195 c = *
static_cast<sal_Unicode const *
>(a.getValue());
196 i =
static_cast<sal_Int16
>(c);
200 throw css::lang::IllegalArgumentException();
208 switch( a.getValueType().getTypeClass() ) {
209 case css::uno::TypeClass_BOOLEAN:
210 i =
static_cast<sal_Int8>(a.get<
bool>());
213 throw css::lang::IllegalArgumentException();
221 switch( a.getValueType().getTypeClass() ) {
222 case css::uno::TypeClass_BOOLEAN:
223 f =
static_cast<float>(a.get<
bool>());
225 case css::uno::TypeClass_LONG:
226 f =
static_cast<float>(a.get<sal_Int32>());
228 case css::uno::TypeClass_UNSIGNED_LONG:
229 f =
static_cast<float>(a.get<sal_uInt32>());
231 case css::uno::TypeClass_HYPER:
232 f =
static_cast<float>(a.get<sal_Int64>());
234 case css::uno::TypeClass_UNSIGNED_HYPER:
235 f =
static_cast<float>(a.get<sal_uInt64>());
237 case css::uno::TypeClass_DOUBLE:
238 f =
static_cast<float>(a.get<
double>());
240 case css::uno::TypeClass_CHAR:
243 c = *
static_cast<sal_Unicode const *
>(a.getValue());
244 f =
static_cast<float>(c);
248 throw css::lang::IllegalArgumentException();
256 switch( a.getValueType().getTypeClass() ) {
257 case css::uno::TypeClass_BOOLEAN:
258 d =
static_cast<double>(a.get<
bool>());
260 case css::uno::TypeClass_HYPER:
261 d =
static_cast<double>(a.get<sal_Int64>());
263 case css::uno::TypeClass_UNSIGNED_HYPER:
264 d =
static_cast<double>(a.get<sal_uInt64>());
266 case css::uno::TypeClass_CHAR:
269 c = *
static_cast<sal_Unicode const *
>(a.getValue());
270 d =
static_cast<double>(c);
274 throw css::lang::IllegalArgumentException();
void convertPropertyValue(target &value, const css::uno::Any &a)
Converts the value stored in an any to a concrete C++ type.
Definition: proptypehlp.hxx:35
signed char sal_Int8
Definition: types.h:43
unsigned char sal_Bool
Definition: types.h:38
sal_uInt16 sal_Unicode
Definition: types.h:123