xref: /AOO41X/main/connectivity/source/inc/ado/Aolevariant.hxx (revision caf5cd79edad04a48dcaf209068b3b89eae4622e)
1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir #ifndef _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
24cdf0e10cSrcweir #define _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <sal/types.h>
27cdf0e10cSrcweir #ifdef __MINGW32__
28cdf0e10cSrcweir #include <windows.h>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <rtl/ustring.hxx>
31cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "ado_pre_sys_include.h"
34cdf0e10cSrcweir #include <oaidl.h>
35cdf0e10cSrcweir #include "ado_post_sys_include.h"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace com
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 	namespace sun
40cdf0e10cSrcweir 	{
41cdf0e10cSrcweir 		namespace star
42cdf0e10cSrcweir 		{
43cdf0e10cSrcweir 			namespace util
44cdf0e10cSrcweir 			{
45cdf0e10cSrcweir 				struct Date;
46cdf0e10cSrcweir 				struct Time;
47cdf0e10cSrcweir 				struct DateTime;
48cdf0e10cSrcweir 			}
49cdf0e10cSrcweir 		}
50cdf0e10cSrcweir 	}
51cdf0e10cSrcweir }
52cdf0e10cSrcweir namespace connectivity
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	namespace ado
55cdf0e10cSrcweir 	{
56cdf0e10cSrcweir 		class OLEString
57cdf0e10cSrcweir 		{
58cdf0e10cSrcweir 			BSTR m_sStr;
59cdf0e10cSrcweir 		public:
60cdf0e10cSrcweir 			OLEString();
61cdf0e10cSrcweir 			OLEString(const BSTR& _sBStr);
62cdf0e10cSrcweir 			OLEString(const ::rtl::OUString& _sBStr);
OLEString(const OLEString & _rRh)63cdf0e10cSrcweir 			OLEString(const OLEString& _rRh)
64cdf0e10cSrcweir 			{
65cdf0e10cSrcweir 				OLEString::operator=(_rRh);
66cdf0e10cSrcweir 			}
67cdf0e10cSrcweir 			~OLEString();
68cdf0e10cSrcweir 			OLEString& operator=(const ::rtl::OUString& _rSrc);
69cdf0e10cSrcweir 			OLEString& operator=(const BSTR& _rSrc);
70cdf0e10cSrcweir 			OLEString& operator=(const OLEString& _rSrc);
71cdf0e10cSrcweir 			operator ::rtl::OUString() const;
72cdf0e10cSrcweir 			operator BSTR() const;
73cdf0e10cSrcweir 			BSTR* operator &();
74cdf0e10cSrcweir 			sal_Int32 length() const;
75cdf0e10cSrcweir 		};
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 		class OLEVariant	:	public ::tagVARIANT
78cdf0e10cSrcweir 		{
79cdf0e10cSrcweir 		public:
80cdf0e10cSrcweir 			OLEVariant();
81cdf0e10cSrcweir 			OLEVariant(const VARIANT& varSrc);
82cdf0e10cSrcweir 			OLEVariant(const OLEVariant& varSrc)	;
83cdf0e10cSrcweir 			OLEVariant(sal_Bool x)	;
84cdf0e10cSrcweir 			OLEVariant(sal_Int8 n)	;
85cdf0e10cSrcweir 			OLEVariant(sal_Int16 n)	;
86cdf0e10cSrcweir 			OLEVariant(sal_Int32 n)	;
87cdf0e10cSrcweir 			OLEVariant(sal_Int64 x)	;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 			OLEVariant(const rtl::OUString& us)	;
90cdf0e10cSrcweir 			~OLEVariant()					;
91cdf0e10cSrcweir 			OLEVariant(const ::com::sun::star::util::Date& x );
92cdf0e10cSrcweir 			OLEVariant(const ::com::sun::star::util::Time& x );
93cdf0e10cSrcweir 			OLEVariant(const ::com::sun::star::util::DateTime& x );
94cdf0e10cSrcweir 			OLEVariant(const float &x);
95cdf0e10cSrcweir 			OLEVariant(const double &x);
96cdf0e10cSrcweir 			OLEVariant(IDispatch* pDispInterface);
97cdf0e10cSrcweir 			OLEVariant(const ::com::sun::star::uno::Sequence< sal_Int8 >& x);
98cdf0e10cSrcweir 			OLEVariant& operator=(const OLEVariant& varSrc);
99cdf0e10cSrcweir 			// Assign a const VARIANT& (::VariantCopy handles everything)
100cdf0e10cSrcweir 			//
101cdf0e10cSrcweir 			OLEVariant& operator=(const tagVARIANT& varSrc);
102cdf0e10cSrcweir 			// Assign a const VARIANT* (::VariantCopy handles everything)
103cdf0e10cSrcweir 			//
104cdf0e10cSrcweir 			OLEVariant& operator=(const VARIANT* pSrc);
105cdf0e10cSrcweir 			void setByte(sal_uInt8 n)				;
106cdf0e10cSrcweir 			void setInt16(sal_Int16 n)				;
107cdf0e10cSrcweir 			void setInt32(sal_Int32 n)				;
108cdf0e10cSrcweir 			void setFloat(float f)					;
109cdf0e10cSrcweir 			void setDouble(double d)				;
110cdf0e10cSrcweir 			void setDate(DATE d)					;
111cdf0e10cSrcweir 			void setChar(unsigned char a)			;
112cdf0e10cSrcweir 			void setCurrency(double aCur)			;
113cdf0e10cSrcweir 			void setBool(sal_Bool b)				;
114cdf0e10cSrcweir 			void setString(const rtl::OUString& us)	;
115cdf0e10cSrcweir 			void setNoArg()							;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 			void setIDispatch(IDispatch* pDispInterface);
118cdf0e10cSrcweir 			void setNull()	 ;
119cdf0e10cSrcweir 			void setEmpty()	 ;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 			void setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr);
122cdf0e10cSrcweir 			void setArray(SAFEARRAY* pSafeArray, VARTYPE vtType);
123cdf0e10cSrcweir 			sal_Bool isNull() const  ;
124cdf0e10cSrcweir 			sal_Bool isEmpty() const ;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 			VARTYPE getType() const ;
127cdf0e10cSrcweir 			void ChangeType(VARTYPE vartype, const OLEVariant* pSrc);
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 			operator ::rtl::OUString() const;
131cdf0e10cSrcweir 
operator sal_Bool() const132cdf0e10cSrcweir 			operator sal_Bool()		const {	return getBool();	}
operator sal_Int8() const133cdf0e10cSrcweir 			operator sal_Int8()		const {	return getInt8();	}
operator sal_Int16() const134cdf0e10cSrcweir 			operator sal_Int16()	const {	return getInt16();	}
operator sal_Int32() const135cdf0e10cSrcweir 			operator sal_Int32() 	const {	return getInt32();	}
operator float() const136cdf0e10cSrcweir 			operator float()		const {	return getFloat();	}
operator double() const137cdf0e10cSrcweir 			operator double()		const {	return getDouble();	}
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 			operator ::com::sun::star::uno::Sequence< sal_Int8 >() const;
140cdf0e10cSrcweir 			operator ::com::sun::star::util::Date() const ;
141cdf0e10cSrcweir 			operator ::com::sun::star::util::Time()	const ;
142cdf0e10cSrcweir 			operator ::com::sun::star::util::DateTime()const ;
143cdf0e10cSrcweir 			::rtl::OUString getString()		const;
144cdf0e10cSrcweir 			sal_Bool		getBool()		const;
145cdf0e10cSrcweir 			IUnknown*		getIUnknown()	const;
146cdf0e10cSrcweir 			IDispatch*		getIDispatch()	const;
147cdf0e10cSrcweir 			sal_uInt8		getByte()		const;
148cdf0e10cSrcweir 			sal_Int16		getInt16()		const;
149cdf0e10cSrcweir 			sal_Int8		getInt8()		const;
150cdf0e10cSrcweir 			sal_Int32		getInt32()		const;
151cdf0e10cSrcweir 			sal_uInt32		getUInt32()		const;
152cdf0e10cSrcweir 			float			getFloat()		const;
153cdf0e10cSrcweir 			double			getDouble()		const;
154cdf0e10cSrcweir 			double			getDate()		const;
155cdf0e10cSrcweir 			CY				getCurrency()	const;
156cdf0e10cSrcweir 			SAFEARRAY*		getUI1SAFEARRAYPtr() const;
157cdf0e10cSrcweir             ::com::sun::star::uno::Any makeAny() const;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 			static VARIANT_BOOL VariantBool(sal_Bool bEinBoolean);
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 		private:
162cdf0e10cSrcweir 			void CHS();
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 			void set(double n);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 		};
167cdf0e10cSrcweir 	}
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir #endif // _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
171cdf0e10cSrcweir 
172