xref: /aoo42x/main/xmlscript/source/inc/misc.hxx (revision 05236b1a)
1*05236b1aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*05236b1aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*05236b1aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*05236b1aSAndrew Rist  * distributed with this work for additional information
6*05236b1aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*05236b1aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*05236b1aSAndrew Rist  * "License"); you may not use this file except in compliance
9*05236b1aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*05236b1aSAndrew Rist  *
11*05236b1aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*05236b1aSAndrew Rist  *
13*05236b1aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*05236b1aSAndrew Rist  * software distributed under the License is distributed on an
15*05236b1aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*05236b1aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*05236b1aSAndrew Rist  * specific language governing permissions and limitations
18*05236b1aSAndrew Rist  * under the License.
19*05236b1aSAndrew Rist  *
20*05236b1aSAndrew Rist  *************************************************************/
21*05236b1aSAndrew Rist 
22*05236b1aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #if ! defined INCLUDED_XMLSCRIPT_MISC_HXX
25cdf0e10cSrcweir #define INCLUDED_XMLSCRIPT_MISC_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "com/sun/star/uno/Any.hxx"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir namespace xmlscript
33cdf0e10cSrcweir {
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //==============================================================================
36cdf0e10cSrcweir template< typename T >
extract_throw(T * p,::com::sun::star::uno::Any const & a)37cdf0e10cSrcweir inline void extract_throw( T * p, ::com::sun::star::uno::Any const & a )
38cdf0e10cSrcweir {
39cdf0e10cSrcweir     if (! (a >>= *p))
40cdf0e10cSrcweir     {
41cdf0e10cSrcweir         throw ::com::sun::star::uno::RuntimeException(
42cdf0e10cSrcweir             OUSTR("expected ") + ::getCppuType( p ).getTypeName(),
43cdf0e10cSrcweir             ::com::sun::star::uno::Reference<
44cdf0e10cSrcweir             ::com::sun::star::uno::XInterface>() );
45cdf0e10cSrcweir     }
46cdf0e10cSrcweir }
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //==============================================================================
49cdf0e10cSrcweir template< typename T >
extract_throw(::com::sun::star::uno::Any const & a)50cdf0e10cSrcweir inline T extract_throw( ::com::sun::star::uno::Any const & a )
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     T v = T();
53cdf0e10cSrcweir     extract_throw<T>( &v, a );
54cdf0e10cSrcweir     return v;
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir }
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #endif
60