xref: /AOO41X/main/connectivity/source/inc/ado/Aolevariant.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
28*cdf0e10cSrcweir #define _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <sal/types.h>
31*cdf0e10cSrcweir #ifdef __MINGW32__
32*cdf0e10cSrcweir #include <windows.h>
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir #include <rtl/ustring.hxx>
35*cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include "ado_pre_sys_include.h"
38*cdf0e10cSrcweir #include <oaidl.h>
39*cdf0e10cSrcweir #include "ado_post_sys_include.h"
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir namespace com
42*cdf0e10cSrcweir {
43*cdf0e10cSrcweir 	namespace sun
44*cdf0e10cSrcweir 	{
45*cdf0e10cSrcweir 		namespace star
46*cdf0e10cSrcweir 		{
47*cdf0e10cSrcweir 			namespace util
48*cdf0e10cSrcweir 			{
49*cdf0e10cSrcweir 				struct Date;
50*cdf0e10cSrcweir 				struct Time;
51*cdf0e10cSrcweir 				struct DateTime;
52*cdf0e10cSrcweir 			}
53*cdf0e10cSrcweir 		}
54*cdf0e10cSrcweir 	}
55*cdf0e10cSrcweir }
56*cdf0e10cSrcweir namespace connectivity
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir 	namespace ado
59*cdf0e10cSrcweir 	{
60*cdf0e10cSrcweir 		class OLEString
61*cdf0e10cSrcweir 		{
62*cdf0e10cSrcweir 			BSTR m_sStr;
63*cdf0e10cSrcweir 		public:
64*cdf0e10cSrcweir 			OLEString();
65*cdf0e10cSrcweir 			OLEString(const BSTR& _sBStr);
66*cdf0e10cSrcweir 			OLEString(const ::rtl::OUString& _sBStr);
67*cdf0e10cSrcweir 			OLEString(const OLEString& _rRh)
68*cdf0e10cSrcweir 			{
69*cdf0e10cSrcweir 				OLEString::operator=(_rRh);
70*cdf0e10cSrcweir 			}
71*cdf0e10cSrcweir 			~OLEString();
72*cdf0e10cSrcweir 			OLEString& operator=(const ::rtl::OUString& _rSrc);
73*cdf0e10cSrcweir 			OLEString& operator=(const BSTR& _rSrc);
74*cdf0e10cSrcweir 			OLEString& operator=(const OLEString& _rSrc);
75*cdf0e10cSrcweir 			operator ::rtl::OUString() const;
76*cdf0e10cSrcweir 			operator BSTR() const;
77*cdf0e10cSrcweir 			BSTR* operator &();
78*cdf0e10cSrcweir 			sal_Int32 length() const;
79*cdf0e10cSrcweir 		};
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 		class OLEVariant	:	public ::tagVARIANT
82*cdf0e10cSrcweir 		{
83*cdf0e10cSrcweir 		public:
84*cdf0e10cSrcweir 			OLEVariant();
85*cdf0e10cSrcweir 			OLEVariant(const VARIANT& varSrc);
86*cdf0e10cSrcweir 			OLEVariant(const OLEVariant& varSrc)	;
87*cdf0e10cSrcweir 			OLEVariant(sal_Bool x)	;
88*cdf0e10cSrcweir 			OLEVariant(sal_Int8 n)	;
89*cdf0e10cSrcweir 			OLEVariant(sal_Int16 n)	;
90*cdf0e10cSrcweir 			OLEVariant(sal_Int32 n)	;
91*cdf0e10cSrcweir 			OLEVariant(sal_Int64 x)	;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 			OLEVariant(const rtl::OUString& us)	;
94*cdf0e10cSrcweir 			~OLEVariant()					;
95*cdf0e10cSrcweir 			OLEVariant(const ::com::sun::star::util::Date& x );
96*cdf0e10cSrcweir 			OLEVariant(const ::com::sun::star::util::Time& x );
97*cdf0e10cSrcweir 			OLEVariant(const ::com::sun::star::util::DateTime& x );
98*cdf0e10cSrcweir 			OLEVariant(const float &x);
99*cdf0e10cSrcweir 			OLEVariant(const double &x);
100*cdf0e10cSrcweir 			OLEVariant(IDispatch* pDispInterface);
101*cdf0e10cSrcweir 			OLEVariant(const ::com::sun::star::uno::Sequence< sal_Int8 >& x);
102*cdf0e10cSrcweir 			OLEVariant& operator=(const OLEVariant& varSrc);
103*cdf0e10cSrcweir 			// Assign a const VARIANT& (::VariantCopy handles everything)
104*cdf0e10cSrcweir 			//
105*cdf0e10cSrcweir 			OLEVariant& operator=(const tagVARIANT& varSrc);
106*cdf0e10cSrcweir 			// Assign a const VARIANT* (::VariantCopy handles everything)
107*cdf0e10cSrcweir 			//
108*cdf0e10cSrcweir 			OLEVariant& operator=(const VARIANT* pSrc);
109*cdf0e10cSrcweir 			void setByte(sal_uInt8 n)				;
110*cdf0e10cSrcweir 			void setInt16(sal_Int16 n)				;
111*cdf0e10cSrcweir 			void setInt32(sal_Int32 n)				;
112*cdf0e10cSrcweir 			void setFloat(float f)					;
113*cdf0e10cSrcweir 			void setDouble(double d)				;
114*cdf0e10cSrcweir 			void setDate(DATE d)					;
115*cdf0e10cSrcweir 			void setChar(unsigned char a)			;
116*cdf0e10cSrcweir 			void setCurrency(double aCur)			;
117*cdf0e10cSrcweir 			void setBool(sal_Bool b)				;
118*cdf0e10cSrcweir 			void setString(const rtl::OUString& us)	;
119*cdf0e10cSrcweir 			void setNoArg()							;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 			void setIDispatch(IDispatch* pDispInterface);
122*cdf0e10cSrcweir 			void setNull()	 ;
123*cdf0e10cSrcweir 			void setEmpty()	 ;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 			void setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr);
126*cdf0e10cSrcweir 			void setArray(SAFEARRAY* pSafeArray, VARTYPE vtType);
127*cdf0e10cSrcweir 			sal_Bool isNull() const  ;
128*cdf0e10cSrcweir 			sal_Bool isEmpty() const ;
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 			VARTYPE getType() const ;
131*cdf0e10cSrcweir 			void ChangeType(VARTYPE vartype, const OLEVariant* pSrc);
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 			operator ::rtl::OUString() const;
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 			operator sal_Bool()		const {	return getBool();	}
137*cdf0e10cSrcweir 			operator sal_Int8()		const {	return getInt8();	}
138*cdf0e10cSrcweir 			operator sal_Int16()	const {	return getInt16();	}
139*cdf0e10cSrcweir 			operator sal_Int32() 	const {	return getInt32();	}
140*cdf0e10cSrcweir 			operator float()		const {	return getFloat();	}
141*cdf0e10cSrcweir 			operator double()		const {	return getDouble();	}
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 			operator ::com::sun::star::uno::Sequence< sal_Int8 >() const;
144*cdf0e10cSrcweir 			operator ::com::sun::star::util::Date() const ;
145*cdf0e10cSrcweir 			operator ::com::sun::star::util::Time()	const ;
146*cdf0e10cSrcweir 			operator ::com::sun::star::util::DateTime()const ;
147*cdf0e10cSrcweir 			::rtl::OUString getString()		const;
148*cdf0e10cSrcweir 			sal_Bool		getBool()		const;
149*cdf0e10cSrcweir 			IUnknown*		getIUnknown()	const;
150*cdf0e10cSrcweir 			IDispatch*		getIDispatch()	const;
151*cdf0e10cSrcweir 			sal_uInt8		getByte()		const;
152*cdf0e10cSrcweir 			sal_Int16		getInt16()		const;
153*cdf0e10cSrcweir 			sal_Int8		getInt8()		const;
154*cdf0e10cSrcweir 			sal_Int32		getInt32()		const;
155*cdf0e10cSrcweir 			sal_uInt32		getUInt32()		const;
156*cdf0e10cSrcweir 			float			getFloat()		const;
157*cdf0e10cSrcweir 			double			getDouble()		const;
158*cdf0e10cSrcweir 			double			getDate()		const;
159*cdf0e10cSrcweir 			CY				getCurrency()	const;
160*cdf0e10cSrcweir 			SAFEARRAY*		getUI1SAFEARRAYPtr() const;
161*cdf0e10cSrcweir             ::com::sun::star::uno::Any makeAny() const;
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 			static VARIANT_BOOL VariantBool(sal_Bool bEinBoolean);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 		private:
166*cdf0e10cSrcweir 			void CHS();
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 			void set(double n);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 		};
171*cdf0e10cSrcweir 	}
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir #endif // _CONNECTIVITY_ADO_AOLEVARIANT_HXX_
175*cdf0e10cSrcweir 
176