123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- #ifndef BASE_WIN_SCOPED_VARIANT_H_
- #define BASE_WIN_SCOPED_VARIANT_H_
- #include <windows.h>
- #include <oleauto.h>
- #include <stdint.h>
- #include "base/base_export.h"
- #include "base/macros.h"
- namespace base {
- namespace win {
- class BASE_EXPORT ScopedVariant {
- public:
-
- static const VARIANT kEmptyVariant;
-
- ScopedVariant() {
-
- var_.vt = VT_EMPTY;
- }
-
-
-
- explicit ScopedVariant(const wchar_t* str);
-
- ScopedVariant(const wchar_t* str, UINT length);
-
-
- explicit ScopedVariant(long value, VARTYPE vt = VT_I4);
-
-
- explicit ScopedVariant(int value);
-
-
- explicit ScopedVariant(bool value);
-
-
- explicit ScopedVariant(double value, VARTYPE vt = VT_R8);
-
- explicit ScopedVariant(IDispatch* dispatch);
-
- explicit ScopedVariant(IUnknown* unknown);
-
- explicit ScopedVariant(SAFEARRAY* safearray);
-
- explicit ScopedVariant(const VARIANT& var);
-
- ScopedVariant(ScopedVariant&& var);
- ~ScopedVariant();
- inline VARTYPE type() const { return var_.vt; }
-
- void Reset(const VARIANT& var = kEmptyVariant);
-
- VARIANT Release();
-
- void Swap(ScopedVariant& var);
-
- VARIANT Copy() const;
-
-
-
-
-
-
-
-
-
-
-
-
-
- int Compare(const VARIANT& other, bool ignore_case = false) const;
-
-
-
-
- VARIANT* Receive();
- void Set(const wchar_t* str);
-
- void Set(int8_t i8);
- void Set(uint8_t ui8);
- void Set(int16_t i16);
- void Set(uint16_t ui16);
- void Set(int32_t i32);
- void Set(uint32_t ui32);
- void Set(int64_t i64);
- void Set(uint64_t ui64);
- void Set(float r32);
- void Set(double r64);
- void Set(bool b);
-
-
-
- void Set(const VARIANT& var);
-
- void Set(IDispatch* disp);
- void Set(IUnknown* unk);
-
- void Set(SAFEARRAY* array);
-
-
- void SetDate(DATE date);
-
-
-
-
- const VARIANT* ptr() const { return &var_; }
-
- ScopedVariant& operator=(ScopedVariant&& var);
-
-
-
- ScopedVariant& operator=(const VARIANT& var);
-
-
-
-
- VARIANT* AsInput() const {
-
-
- return const_cast<VARIANT*>(&var_);
- }
-
-
- operator const VARIANT&() const { return var_; }
-
- static bool IsLeakableVarType(VARTYPE vt);
- protected:
- VARIANT var_;
- private:
-
-
- bool operator==(const ScopedVariant& var) const;
- bool operator!=(const ScopedVariant& var) const;
- DISALLOW_COPY_AND_ASSIGN(ScopedVariant);
- };
- }
- }
- #endif
|