xref: /aoo4110/main/cppu/source/cppu/cppu_opt.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cppu.hxx"
26 
27 #include "typelib/typedescription.h"
28 #include "uno/any2.h"
29 #include "rtl/ustrbuf.hxx"
30 
31 
32 using namespace ::rtl;
33 
34 //##################################################################################################
cppu_unsatisfied_iquery_msg(typelib_TypeDescriptionReference * pType)35 extern "C" rtl_uString * SAL_CALL cppu_unsatisfied_iquery_msg(
36     typelib_TypeDescriptionReference * pType )
37     SAL_THROW_EXTERN_C()
38 {
39     OUStringBuffer buf( 64 );
40     buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("unsatisfied query for interface of type ") );
41     buf.append( OUString::unacquired( &pType->pTypeName ) );
42     buf.append( (sal_Unicode) '!' );
43     OUString ret( buf.makeStringAndClear() );
44     rtl_uString_acquire( ret.pData );
45     return ret.pData;
46 }
47 
48 //##################################################################################################
cppu_unsatisfied_iset_msg(typelib_TypeDescriptionReference * pType)49 extern "C" rtl_uString * SAL_CALL cppu_unsatisfied_iset_msg(
50     typelib_TypeDescriptionReference * pType )
51     SAL_THROW_EXTERN_C()
52 {
53     OUStringBuffer buf( 64 );
54     buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("invalid attempt to assign an empty interface of type ") );
55     buf.append( OUString::unacquired( &pType->pTypeName ) );
56     buf.append( (sal_Unicode) '!' );
57     OUString ret( buf.makeStringAndClear() );
58     rtl_uString_acquire( ret.pData );
59     return ret.pData;
60 }
61 
62 //##############################################################################
cppu_Any_extraction_failure_msg(uno_Any * pAny,typelib_TypeDescriptionReference * pType)63 extern "C" rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg(
64     uno_Any * pAny, typelib_TypeDescriptionReference * pType )
65     SAL_THROW_EXTERN_C()
66 {
67     OUStringBuffer buf;
68     buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
69                          "Cannot extract an Any(") );
70     buf.append( OUString::unacquired(&pAny->pType->pTypeName) );
71     buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(") to ") );
72     buf.append( OUString::unacquired(&pType->pTypeName) );
73     buf.append( static_cast<sal_Unicode>('!') );
74     const OUString ret( buf.makeStringAndClear() );
75     rtl_uString_acquire( ret.pData );
76     return ret.pData;
77 }
78