1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #ifndef BASE_WIN_SCOPED_BSTR_H_
- #define BASE_WIN_SCOPED_BSTR_H_
- #include <windows.h>
- #include <oleauto.h>
- #include <stddef.h>
- #include "base/base_export.h"
- #include "base/check.h"
- #include "base/macros.h"
- #include "base/strings/string_piece.h"
- namespace base {
- namespace win {
- class BASE_EXPORT ScopedBstr {
- public:
- ScopedBstr() = default;
-
-
-
-
- explicit ScopedBstr(WStringPiece non_bstr);
- ~ScopedBstr();
- BSTR Get() const { return bstr_; }
-
-
- void Reset(BSTR bstr = nullptr);
-
- BSTR Release();
-
-
-
-
-
-
- BSTR Allocate(WStringPiece str);
-
-
- BSTR AllocateBytes(size_t bytes);
-
-
-
-
-
-
-
-
-
-
-
- void SetByteLen(size_t bytes);
-
- void Swap(ScopedBstr& bstr2);
-
-
-
-
- BSTR* Receive();
-
- size_t Length() const;
-
- size_t ByteLength() const;
-
-
- bool operator==(const ScopedBstr& bstr2) const = delete;
- bool operator!=(const ScopedBstr& bstr2) const = delete;
- protected:
- BSTR bstr_ = nullptr;
- private:
- DISALLOW_COPY_AND_ASSIGN(ScopedBstr);
- };
- }
- }
- #endif
|