1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 #pragma once 20 21 #include <sal/types.h> 22 #include <rtl/ustring.hxx> 23 #include <com/sun/star/uno/Sequence.hxx> 24 25 #include <oaidl.h> 26 27 namespace com::sun::star::util 28 { 29 struct Date; 30 struct Time; 31 struct DateTime; 32 } 33 34 namespace connectivity::ado 35 { 36 class OLEString 37 { 38 BSTR m_sStr; 39 public: 40 OLEString(); 41 OLEString(const BSTR& _sBStr); 42 OLEString(std::u16string_view _sBStr); OLEString(const OLEString & _rRh)43 OLEString(const OLEString& _rRh) 44 { 45 OLEString::operator=(_rRh); 46 } 47 ~OLEString(); 48 OLEString& operator=(std::u16string_view _rSrc); 49 OLEString& operator=(const BSTR& _rSrc); 50 OLEString& operator=(const OLEString& _rSrc); 51 OUString asOUString() const; 52 BSTR asBSTR() const; 53 BSTR* getAddress(); 54 sal_Int32 length() const; 55 }; 56 57 class OLEVariant : public ::tagVARIANT 58 { 59 public: 60 OLEVariant(); 61 OLEVariant(const VARIANT& varSrc); 62 OLEVariant(const OLEVariant& varSrc) ; 63 OLEVariant(bool x) ; 64 OLEVariant(sal_Bool) = delete; 65 OLEVariant(sal_Int8 n) ; 66 OLEVariant(sal_Int16 n) ; 67 OLEVariant(sal_Int32 n) ; 68 OLEVariant(sal_Int64 x) ; 69 70 OLEVariant(std::u16string_view us); OLEVariant(const OUString & us)71 OLEVariant(const OUString& us) 72 : OLEVariant(std::u16string_view(us)) 73 { 74 } 75 ~OLEVariant() ; 76 OLEVariant(const css::util::Date& x ); 77 OLEVariant(const css::util::Time& x ); 78 OLEVariant(const css::util::DateTime& x ); 79 OLEVariant(float x); 80 OLEVariant(const double &x); 81 OLEVariant(IDispatch* pDispInterface); 82 OLEVariant(const css::uno::Sequence< sal_Int8 >& x); 83 OLEVariant& operator=(const OLEVariant& varSrc); 84 // Assign a const VARIANT& (::VariantCopy handles everything) 85 86 OLEVariant& operator=(const tagVARIANT& varSrc); 87 // Assign a const VARIANT* (::VariantCopy handles everything) 88 89 OLEVariant& operator=(const VARIANT* pSrc); 90 void setByte(sal_uInt8 n) ; 91 void setInt16(sal_Int16 n) ; 92 void setInt32(sal_Int32 n) ; 93 void setFloat(float f) ; 94 void setDouble(double d) ; 95 void setDate(DATE d) ; 96 void setChar(unsigned char a) ; 97 void setCurrency(double aCur) ; 98 void setBool(bool b) ; 99 void setString(std::u16string_view us); 100 void setNoArg() ; 101 102 void setIDispatch(IDispatch* pDispInterface); 103 void setNull() ; 104 void setEmpty() ; 105 106 void setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr); 107 void setArray(SAFEARRAY* pSafeArray, VARTYPE vtType); 108 bool isNull() const ; 109 bool isEmpty() const ; 110 111 VARTYPE getType() const ; 112 void ChangeType(VARTYPE vartype, const OLEVariant* pSrc); 113 114 OUString getString() const; 115 bool getBool() const; 116 IUnknown* getIUnknown() const; 117 IDispatch* getIDispatch() const; 118 sal_uInt8 getByte() const; 119 sal_Int16 getInt16() const; 120 sal_Int8 getInt8() const; 121 sal_Int32 getInt32() const; 122 sal_uInt32 getUInt32() const; 123 float getFloat() const; 124 double getDouble() const; 125 double getDateAsDouble() const; 126 CY getCurrency() const; 127 css::util::Date getDate() const; 128 css::util::Time getTime() const; 129 css::util::DateTime getDateTime() const; 130 css::uno::Sequence<sal_Int8> getByteSequence() const; 131 SAFEARRAY* getUI1SAFEARRAYPtr() const; 132 css::uno::Any makeAny() const; 133 134 static VARIANT_BOOL VariantBool(bool bEinBoolean); 135 136 private: 137 void CHS(); 138 139 void set(double n); 140 141 }; 142 } 143 144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 145