Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
base::win::ScopedBstr Class Reference

#include <scoped_bstr.h>

Public Member Functions

 ScopedBstr ()=default
 
 ScopedBstr (std::wstring_view non_bstr)
 
 ~ScopedBstr ()
 
BSTR Get () const
 
void Reset (BSTR bstr=nullptr)
 
BSTR Release ()
 
BSTR Allocate (std::wstring_view 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
 

Detailed Description

Definition at line 22 of file scoped_bstr.h.

Constructor & Destructor Documentation

◆ ScopedBstr() [1/2]

base::win::ScopedBstr::ScopedBstr ( )
default

◆ ScopedBstr() [2/2]

base::win::ScopedBstr::ScopedBstr ( std::wstring_view  non_bstr)
explicit

Definition at line 34 of file scoped_bstr.cc.

35 : bstr_(AllocBstrOrDie(non_bstr)) {}

◆ ~ScopedBstr()

base::win::ScopedBstr::~ScopedBstr ( )

Definition at line 37 of file scoped_bstr.cc.

37 {
38 static_assert(sizeof(ScopedBstr) == sizeof(BSTR), "ScopedBstrSize");
39 ::SysFreeString(bstr_);
40}

Member Function Documentation

◆ Allocate()

BSTR base::win::ScopedBstr::Allocate ( std::wstring_view  str)

Definition at line 67 of file scoped_bstr.cc.

67 {
68 Reset(AllocBstrOrDie(str));
69 return bstr_;
70}
void Reset(BSTR bstr=nullptr)

◆ AllocateBytes()

BSTR base::win::ScopedBstr::AllocateBytes ( size_t  bytes)

Definition at line 72 of file scoped_bstr.cc.

72 {
73 Reset(AllocBstrBytesOrDie(bytes));
74 return bstr_;
75}

◆ ByteLength()

size_t base::win::ScopedBstr::ByteLength ( ) const

Definition at line 87 of file scoped_bstr.cc.

87 {
88 return ::SysStringByteLen(bstr_);
89}

◆ Get()

BSTR base::win::ScopedBstr::Get ( ) const
inline

Definition at line 33 of file scoped_bstr.h.

33{ return bstr_; }

◆ Length()

size_t base::win::ScopedBstr::Length ( ) const

Definition at line 83 of file scoped_bstr.cc.

83 {
84 return ::SysStringLen(bstr_);
85}

◆ operator!=()

bool base::win::ScopedBstr::operator!= ( const ScopedBstr bstr2) const
delete

◆ operator==()

bool base::win::ScopedBstr::operator== ( const ScopedBstr bstr2) const
delete

◆ Receive()

BSTR * base::win::ScopedBstr::Receive ( )

Definition at line 62 of file scoped_bstr.cc.

62 {
63 BASE_DCHECK(!bstr_) << "BSTR leak.";
64 return &bstr_;
65}
#define BASE_DCHECK(condition)
Definition logging.h:63

◆ Release()

BSTR base::win::ScopedBstr::Release ( )

Definition at line 50 of file scoped_bstr.cc.

50 {
51 BSTR bstr = bstr_;
52 bstr_ = nullptr;
53 return bstr;
54}

◆ Reset()

void base::win::ScopedBstr::Reset ( BSTR  bstr = nullptr)

Definition at line 42 of file scoped_bstr.cc.

42 {
43 if (bstr != bstr_) {
44 // SysFreeString handles null properly.
45 ::SysFreeString(bstr_);
46 bstr_ = bstr;
47 }
48}

◆ SetByteLen()

void base::win::ScopedBstr::SetByteLen ( size_t  bytes)

Definition at line 77 of file scoped_bstr.cc.

77 {
78 BASE_DCHECK(bstr_);
79 uint32_t* data = reinterpret_cast<uint32_t*>(bstr_);
80 data[-1] = checked_cast<uint32_t>(bytes);
81}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ Swap()

void base::win::ScopedBstr::Swap ( ScopedBstr bstr2)

Definition at line 56 of file scoped_bstr.cc.

56 {
57 BSTR tmp = bstr_;
58 bstr_ = bstr2.bstr_;
59 bstr2.bstr_ = tmp;
60}

The documentation for this class was generated from the following files: