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 #ifndef _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
24 #define _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
25 
26 #include <sal/types.h>
27 #ifdef __MINGW32__
28 #include <windows.h>
29 #endif
30 #include <rtl/ustring.hxx>
31 #include <com/sun/star/uno/Sequence.hxx>
32 
33 #include "ado_pre_sys_include.h"
34 #include <oaidl.h>
35 #include "ado_post_sys_include.h"
36 
37 namespace com
38 {
39 	namespace sun
40 	{
41 		namespace star
42 		{
43 			namespace util
44 			{
45 				struct Date;
46 				struct Time;
47 				struct DateTime;
48 			}
49 		}
50 	}
51 }
52 namespace connectivity
53 {
54 	namespace ado
55 	{
56 		class OLEString
57 		{
58 			BSTR m_sStr;
59 		public:
60 			OLEString();
61 			OLEString(const BSTR& _sBStr);
62 			OLEString(const ::rtl::OUString& _sBStr);
OLEString(const OLEString & _rRh)63 			OLEString(const OLEString& _rRh)
64 			{
65 				OLEString::operator=(_rRh);
66 			}
67 			~OLEString();
68 			OLEString& operator=(const ::rtl::OUString& _rSrc);
69 			OLEString& operator=(const BSTR& _rSrc);
70 			OLEString& operator=(const OLEString& _rSrc);
71 			operator ::rtl::OUString() const;
72 			operator BSTR() const;
73 			BSTR* operator &();
74 			sal_Int32 length() const;
75 		};
76 
77 		class OLEVariant	:	public ::tagVARIANT
78 		{
79 		public:
80 			OLEVariant();
81 			OLEVariant(const VARIANT& varSrc);
82 			OLEVariant(const OLEVariant& varSrc)	;
83 			OLEVariant(sal_Bool x)	;
84 			OLEVariant(sal_Int8 n)	;
85 			OLEVariant(sal_Int16 n)	;
86 			OLEVariant(sal_Int32 n)	;
87 			OLEVariant(sal_Int64 x)	;
88 
89 			OLEVariant(const rtl::OUString& us)	;
90 			~OLEVariant()					;
91 			OLEVariant(const ::com::sun::star::util::Date& x );
92 			OLEVariant(const ::com::sun::star::util::Time& x );
93 			OLEVariant(const ::com::sun::star::util::DateTime& x );
94 			OLEVariant(const float &x);
95 			OLEVariant(const double &x);
96 			OLEVariant(IDispatch* pDispInterface);
97 			OLEVariant(const ::com::sun::star::uno::Sequence< sal_Int8 >& x);
98 			OLEVariant& operator=(const OLEVariant& varSrc);
99 			// Assign a const VARIANT& (::VariantCopy handles everything)
100 			//
101 			OLEVariant& operator=(const tagVARIANT& varSrc);
102 			// Assign a const VARIANT* (::VariantCopy handles everything)
103 			//
104 			OLEVariant& operator=(const VARIANT* pSrc);
105 			void setByte(sal_uInt8 n)				;
106 			void setInt16(sal_Int16 n)				;
107 			void setInt32(sal_Int32 n)				;
108 			void setFloat(float f)					;
109 			void setDouble(double d)				;
110 			void setDate(DATE d)					;
111 			void setChar(unsigned char a)			;
112 			void setCurrency(double aCur)			;
113 			void setBool(sal_Bool b)				;
114 			void setString(const rtl::OUString& us)	;
115 			void setNoArg()							;
116 
117 			void setIDispatch(IDispatch* pDispInterface);
118 			void setNull()	 ;
119 			void setEmpty()	 ;
120 
121 			void setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr);
122 			void setArray(SAFEARRAY* pSafeArray, VARTYPE vtType);
123 			sal_Bool isNull() const  ;
124 			sal_Bool isEmpty() const ;
125 
126 			VARTYPE getType() const ;
127 			void ChangeType(VARTYPE vartype, const OLEVariant* pSrc);
128 
129 
130 			operator ::rtl::OUString() const;
131 
operator sal_Bool() const132 			operator sal_Bool()		const {	return getBool();	}
operator sal_Int8() const133 			operator sal_Int8()		const {	return getInt8();	}
operator sal_Int16() const134 			operator sal_Int16()	const {	return getInt16();	}
operator sal_Int32() const135 			operator sal_Int32() 	const {	return getInt32();	}
136 			operator float()		const {	return getFloat();	}
137 			operator double()		const {	return getDouble();	}
138 
139 			operator ::com::sun::star::uno::Sequence< sal_Int8 >() const;
140 			operator ::com::sun::star::util::Date() const ;
141 			operator ::com::sun::star::util::Time()	const ;
142 			operator ::com::sun::star::util::DateTime()const ;
143 			::rtl::OUString getString()		const;
144 			sal_Bool		getBool()		const;
145 			IUnknown*		getIUnknown()	const;
146 			IDispatch*		getIDispatch()	const;
147 			sal_uInt8		getByte()		const;
148 			sal_Int16		getInt16()		const;
149 			sal_Int8		getInt8()		const;
150 			sal_Int32		getInt32()		const;
151 			sal_uInt32		getUInt32()		const;
152 			float			getFloat()		const;
153 			double			getDouble()		const;
154 			double			getDate()		const;
155 			CY				getCurrency()	const;
156 			SAFEARRAY*		getUI1SAFEARRAYPtr() const;
157             ::com::sun::star::uno::Any makeAny() const;
158 
159 			static VARIANT_BOOL VariantBool(sal_Bool bEinBoolean);
160 
161 		private:
162 			void CHS();
163 
164 			void set(double n);
165 
166 		};
167 	}
168 }
169 
170 #endif // _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
171 
172