4 #ifndef INCLUDED_CPPUHELPER_PROPTYPEHLP_HXX
5 #define INCLUDED_CPPUHELPER_PROPTYPEHLP_HXX
8 #include "com/sun/star/lang/IllegalArgumentException.hpp"
9 #include "com/sun/star/uno/TypeClass.hpp"
14 template <
class target >
18 if( !( a >>= value ) ) {
19 throw css::lang::IllegalArgumentException();
28 switch( a.getValueType().getTypeClass() ) {
29 case css::uno::TypeClass_BYTE:
32 case css::uno::TypeClass_SHORT:
33 b = a.get<sal_Int16>() != 0;
35 case css::uno::TypeClass_UNSIGNED_SHORT:
42 case css::uno::TypeClass_LONG:
43 b = a.get<sal_Int32>() != 0;
45 case css::uno::TypeClass_UNSIGNED_LONG:
46 b = a.get<sal_uInt32>() != 0;
48 case css::uno::TypeClass_CHAR:
55 throw css::lang::IllegalArgumentException();
68 switch( a.getValueType().getTypeClass() ) {
69 case css::uno::TypeClass_BOOLEAN:
70 i =
static_cast<sal_Int64
>(a.get<
bool>());
72 case css::uno::TypeClass_CHAR:
75 c = *
static_cast<sal_Unicode const *
>(a.getValue());
76 i =
static_cast<sal_Int64
>(c);
80 throw css::lang::IllegalArgumentException();
89 switch( a.getValueType().getTypeClass() ) {
90 case css::uno::TypeClass_BOOLEAN:
91 i =
static_cast<sal_uInt64
>(a.get<
bool>());
93 case css::uno::TypeClass_CHAR:
96 c = *
static_cast<sal_Unicode const *
>(a.getValue());
97 i =
static_cast<sal_uInt64
>(c);
101 throw css::lang::IllegalArgumentException();
109 switch( a.getValueType().getTypeClass() ) {
110 case css::uno::TypeClass_BOOLEAN:
111 i =
static_cast<sal_Int32
>(a.get<
bool>());
113 case css::uno::TypeClass_CHAR:
116 c = *
static_cast<sal_Unicode const *
>(a.getValue());
117 i =
static_cast<sal_Int32
>(c);
121 throw css::lang::IllegalArgumentException();
129 switch( a.getValueType().getTypeClass() ) {
130 case css::uno::TypeClass_BOOLEAN:
131 i =
static_cast<sal_uInt32
>(a.get<
bool>());
133 case css::uno::TypeClass_CHAR:
136 c = *
static_cast<sal_Unicode const *
>(a.getValue());
137 i =
static_cast<sal_uInt32
>(c);
141 throw css::lang::IllegalArgumentException();
149 switch( a.getValueType().getTypeClass() ) {
150 case css::uno::TypeClass_BOOLEAN:
151 i =
static_cast<sal_Int16
>(a.get<
bool>());
153 case css::uno::TypeClass_CHAR:
156 c = *
static_cast<sal_Unicode const *
>(a.getValue());
157 i =
static_cast<sal_Int16
>(c);
161 throw css::lang::IllegalArgumentException();
169 switch( a.getValueType().getTypeClass() ) {
170 case css::uno::TypeClass_BOOLEAN:
171 i =
static_cast<sal_uInt16
>(a.get<
bool>());
173 case css::uno::TypeClass_CHAR:
176 c = *
static_cast<sal_Unicode const *
>(a.getValue());
177 i =
static_cast<sal_Int16
>(c);
181 throw css::lang::IllegalArgumentException();
189 switch( a.getValueType().getTypeClass() ) {
190 case css::uno::TypeClass_BOOLEAN:
191 i =
static_cast<sal_Int8>(a.get<
bool>());
194 throw css::lang::IllegalArgumentException();
204 switch( a.getValueType().getTypeClass() ) {
205 case css::uno::TypeClass_BOOLEAN:
206 f =
static_cast<float>(a.get<
bool>());
208 case css::uno::TypeClass_LONG:
209 f =
static_cast<float>(a.get<sal_Int32>());
211 case css::uno::TypeClass_UNSIGNED_LONG:
212 f =
static_cast<float>(a.get<sal_uInt32>());
214 case css::uno::TypeClass_HYPER:
215 f =
static_cast<float>(a.get<sal_Int64>());
217 case css::uno::TypeClass_UNSIGNED_HYPER:
218 f =
static_cast<float>(a.get<sal_uInt64>());
220 case css::uno::TypeClass_DOUBLE:
221 f =
static_cast<float>(a.get<
double>());
223 case css::uno::TypeClass_CHAR:
226 c = *
static_cast<sal_Unicode const *
>(a.getValue());
227 f =
static_cast<float>(c);
231 throw css::lang::IllegalArgumentException();
240 switch( a.getValueType().getTypeClass() ) {
241 case css::uno::TypeClass_BOOLEAN:
242 d =
static_cast<double>(a.get<
bool>());
244 case css::uno::TypeClass_HYPER:
245 d =
static_cast<double>(a.get<sal_Int64>());
247 case css::uno::TypeClass_UNSIGNED_HYPER:
248 d =
static_cast<double>(a.get<sal_uInt64>());
250 case css::uno::TypeClass_CHAR:
253 c = *
static_cast<sal_Unicode const *
>(a.getValue());
254 d =
static_cast<double>(c);
258 throw css::lang::IllegalArgumentException();
unsigned char sal_Bool
Definition: types.h:18
void convertPropertyValue(target &value, const css::uno::Any &a)
Converts the value stored in an any to a concrete C++ type.
Definition: proptypehlp.hxx:15
sal_uInt16 sal_Unicode
Definition: types.h:103
signed char sal_Int8
Definition: types.h:23