1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2010 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 class CBstrSafeVector
{
23 CBstrSafeVector() : controlled( 0 ) {}
24 CBstrSafeVector( ULONG count
);
25 ~CBstrSafeVector() { release(); }
27 const SAFEARRAY
* operator ->() { return controlled
; }
28 operator SAFEARRAY
*() { return controlled
; }
29 operator const SAFEARRAY
*() const { return controlled
; }
31 SAFEARRAY
** operator&();
33 HRESULT
PutElement( LONG index
, const CString
& value
);
36 SAFEARRAY
* controlled
;
41 inline CBstrSafeVector::CBstrSafeVector( ULONG count
)
43 controlled
= SafeArrayCreateVector(VT_BSTR
, 0, count
);
46 inline SAFEARRAY
** CBstrSafeVector::operator&()
52 inline HRESULT
CBstrSafeVector::PutElement( LONG index
, const CString
& value
)
54 ATL::CComBSTR valueBstr
;
55 valueBstr
.Attach( value
.AllocSysString() );
56 return SafeArrayPutElement(controlled
, &index
, valueBstr
);
59 inline void CBstrSafeVector::release()
63 SafeArrayDestroy(controlled
);