20 #ifndef INCLUDED_CPPUHELPER_PROPTYPEHLP_HXX 21 #define INCLUDED_CPPUHELPER_PROPTYPEHLP_HXX 24 #include <com/sun/star/lang/IllegalArgumentException.hpp> 25 #include <com/sun/star/uno/TypeClass.hpp> 30 template <
class target >
34 if( !( a >>= value ) ) {
35 throw css::lang::IllegalArgumentException();
42 switch( a.getValueType().getTypeClass() ) {
43 case css::uno::TypeClass_BYTE:
46 case css::uno::TypeClass_SHORT:
47 b = a.get<sal_Int16>() != 0;
49 case css::uno::TypeClass_UNSIGNED_SHORT:
56 case css::uno::TypeClass_LONG:
57 b = a.get<sal_Int32>() != 0;
59 case css::uno::TypeClass_UNSIGNED_LONG:
60 b = a.get<sal_uInt32>() != 0;
62 case css::uno::TypeClass_CHAR:
69 throw css::lang::IllegalArgumentException();
83 switch( a.getValueType().getTypeClass() ) {
84 case css::uno::TypeClass_BOOLEAN:
85 i =
static_cast<sal_Int64
>(a.get<
bool>());
87 case css::uno::TypeClass_CHAR:
90 c = *
static_cast<sal_Unicode const *
>(a.getValue());
95 throw css::lang::IllegalArgumentException();
104 switch( a.getValueType().getTypeClass() ) {
105 case css::uno::TypeClass_BOOLEAN:
106 i =
static_cast<sal_uInt64
>(a.get<
bool>());
108 case css::uno::TypeClass_CHAR:
111 c = *
static_cast<sal_Unicode const *
>(a.getValue());
112 i = ( sal_uInt64 ) c;
116 throw css::lang::IllegalArgumentException();
124 switch( a.getValueType().getTypeClass() ) {
125 case css::uno::TypeClass_BOOLEAN:
126 i =
static_cast<sal_Int32
>(a.get<
bool>());
128 case css::uno::TypeClass_CHAR:
131 c = *
static_cast<sal_Unicode const *
>(a.getValue());
136 throw css::lang::IllegalArgumentException();
144 switch( a.getValueType().getTypeClass() ) {
145 case css::uno::TypeClass_BOOLEAN:
146 i =
static_cast<sal_uInt32
>(a.get<
bool>());
148 case css::uno::TypeClass_CHAR:
151 c = *
static_cast<sal_Unicode const *
>(a.getValue());
152 i = ( sal_uInt32 ) c;
156 throw css::lang::IllegalArgumentException();
164 switch( a.getValueType().getTypeClass() ) {
165 case css::uno::TypeClass_BOOLEAN:
166 i =
static_cast<sal_Int16
>(a.get<
bool>());
168 case css::uno::TypeClass_CHAR:
171 c = *
static_cast<sal_Unicode const *
>(a.getValue());
176 throw css::lang::IllegalArgumentException();
184 switch( a.getValueType().getTypeClass() ) {
185 case css::uno::TypeClass_BOOLEAN:
186 i =
static_cast<sal_uInt16
>(a.get<
bool>());
188 case css::uno::TypeClass_CHAR:
191 c = *
static_cast<sal_Unicode const *
>(a.getValue());
196 throw css::lang::IllegalArgumentException();
204 switch( a.getValueType().getTypeClass() ) {
205 case css::uno::TypeClass_BOOLEAN:
206 i =
static_cast<sal_Int8>(a.get<
bool>());
209 throw css::lang::IllegalArgumentException();
217 switch( a.getValueType().getTypeClass() ) {
218 case css::uno::TypeClass_BOOLEAN:
219 f =
static_cast<float>(a.get<
bool>());
221 case css::uno::TypeClass_LONG:
222 f =
static_cast<float>(a.get<sal_Int32>());
224 case css::uno::TypeClass_UNSIGNED_LONG:
225 f =
static_cast<float>(a.get<sal_uInt32>());
227 case css::uno::TypeClass_HYPER:
228 f =
static_cast<float>(a.get<sal_Int64>());
230 case css::uno::TypeClass_UNSIGNED_HYPER:
231 f =
static_cast<float>(a.get<sal_uInt64>());
233 case css::uno::TypeClass_DOUBLE:
234 f =
static_cast<float>(a.get<
double>());
236 case css::uno::TypeClass_CHAR:
239 c = *
static_cast<sal_Unicode const *
>(a.getValue());
244 throw css::lang::IllegalArgumentException();
252 switch( a.getValueType().getTypeClass() ) {
253 case css::uno::TypeClass_BOOLEAN:
254 d =
static_cast<double>(a.get<
bool>());
256 case css::uno::TypeClass_HYPER:
257 d =
static_cast<double>(a.get<sal_Int64>());
259 case css::uno::TypeClass_UNSIGNED_HYPER:
260 d =
static_cast<double>(a.get<sal_uInt64>());
262 case css::uno::TypeClass_CHAR:
265 c = *
static_cast<sal_Unicode const *
>(a.getValue());
270 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:31
signed char sal_Int8
Definition: types.h:44
sal_uInt16 sal_Unicode
Definition: types.h:142
unsigned char sal_Bool
Definition: types.h:39
Definition: Enterable.hxx:26