1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
7 #ifndef _StringCopyHolder_h_
8 #define _StringCopyHolder_h_
11 //-----------------------------------------------------------------------------
12 // Simple holder to keep a copy of a string.
13 // Implements IStringHolder so we can pass instances through IDacDbiInterface
14 // and have it fill in the contents.
15 //-----------------------------------------------------------------------------
16 class StringCopyHolder : public IDacDbiInterface::IStringHolder
21 // Free the memory allocated for the string contents
24 // Make a copy of the provided null-terminated unicode string
25 virtual HRESULT AssignCopy(const WCHAR * pCopy);
27 // Reset the string to NULL and free memory
30 // Returns true if the string has been set to a non-NULL value
33 return (m_szData != NULL);
36 // Returns true if an empty string is stored. IsSet must be true to call this.
39 _ASSERTE(m_szData != NULL);
40 return m_szData[0] == W('\0');
43 // Returns the pointer to the string contents
44 operator WCHAR* () const
50 // Disallow copying (to prevent double-free) - no implementation
51 StringCopyHolder( const StringCopyHolder& rhs );
52 StringCopyHolder& operator=( const StringCopyHolder& rhs );
59 #endif // StringCopyHolder