OLD | NEW |
(Empty) | |
| 1 #pragma once |
| 2 //------------------------------------------------------------------------------
------------------- |
| 3 // <copyright file="strutil.h" company="Outercurve Foundation"> |
| 4 // Copyright (c) 2004, Outercurve Foundation. |
| 5 // This software is released under Microsoft Reciprocal License (MS-RL). |
| 6 // The license and further copyright text can be found in the file |
| 7 // LICENSE.TXT at the root directory of the distribution. |
| 8 // </copyright> |
| 9 // |
| 10 // <summary> |
| 11 // Header for string helper functions. |
| 12 // </summary> |
| 13 //------------------------------------------------------------------------------
------------------- |
| 14 |
| 15 #ifdef __cplusplus |
| 16 extern "C" { |
| 17 #endif |
| 18 |
| 19 #define ReleaseStr(pwz) if (pwz) { StrFree(pwz); } |
| 20 #define ReleaseNullStr(pwz) if (pwz) { StrFree(pwz); pwz = NULL; } |
| 21 #define ReleaseBSTR(bstr) if (bstr) { ::SysFreeString(bstr); } |
| 22 #define ReleaseNullBSTR(bstr) if (bstr) { ::SysFreeString(bstr); bstr = NULL; } |
| 23 #define ReleaseStrArray(rg, c) { if (rg) { StrArrayFree(rg, c); } } |
| 24 #define ReleaseNullStrArray(rg, c) { if (rg) { StrArrayFree(rg, c); c = 0; rg =
NULL; } } |
| 25 |
| 26 #define DeclareConstBSTR(bstr_const, wz) const WCHAR bstr_const[] = { 0x00, 0x00
, sizeof(wz)-sizeof(WCHAR), 0x00, wz } |
| 27 #define UseConstBSTR(bstr_const) const_cast<BSTR>(bstr_const + 4) |
| 28 |
| 29 HRESULT DAPI StrAlloc( |
| 30 __deref_out_ecount_part(cch, 0) LPWSTR* ppwz, |
| 31 __in DWORD_PTR cch |
| 32 ); |
| 33 HRESULT DAPI StrTrimCapacity( |
| 34 __deref_out_z LPWSTR* ppwz |
| 35 ); |
| 36 HRESULT DAPI StrTrimWhitespace( |
| 37 __deref_out_z LPWSTR* ppwz, |
| 38 __in_z LPCWSTR wzSource |
| 39 ); |
| 40 |
| 41 HRESULT DAPI StrAllocString( |
| 42 __deref_out_ecount_z(cchSource+1) LPWSTR* ppwz, |
| 43 __in_z LPCWSTR wzSource, |
| 44 __in DWORD_PTR cchSource |
| 45 ); |
| 46 |
| 47 |
| 48 HRESULT DAPI StrAllocConcat( |
| 49 __deref_out_z LPWSTR* ppwz, |
| 50 __in_z LPCWSTR wzSource, |
| 51 __in DWORD_PTR cchSource |
| 52 ); |
| 53 HRESULT __cdecl StrAllocFormatted( |
| 54 __deref_out_z LPWSTR* ppwz, |
| 55 __in __format_string LPCWSTR wzFormat, |
| 56 ... |
| 57 ); |
| 58 HRESULT DAPI StrAllocFormattedArgs( |
| 59 __deref_out_z LPWSTR* ppwz, |
| 60 __in __format_string LPCWSTR wzFormat, |
| 61 __in va_list args |
| 62 ); |
| 63 |
| 64 HRESULT DAPI StrMaxLength( |
| 65 __in LPCVOID p, |
| 66 __out DWORD_PTR* pcch |
| 67 ); |
| 68 HRESULT DAPI StrSize( |
| 69 __in LPCVOID p, |
| 70 __out DWORD_PTR* pcb |
| 71 ); |
| 72 |
| 73 HRESULT DAPI StrFree( |
| 74 __in LPVOID p |
| 75 ); |
| 76 |
| 77 |
| 78 LPCWSTR wcsistr( |
| 79 __in_z LPCWSTR wzString, |
| 80 __in_z LPCWSTR wzCharSet |
| 81 ); |
| 82 |
| 83 HRESULT DAPI StrStringToInt16( |
| 84 __in_z LPCWSTR wzIn, |
| 85 __in DWORD cchIn, |
| 86 __out SHORT* psOut |
| 87 ); |
| 88 HRESULT DAPI StrStringToUInt16( |
| 89 __in_z LPCWSTR wzIn, |
| 90 __in DWORD cchIn, |
| 91 __out USHORT* pusOut |
| 92 ); |
| 93 HRESULT DAPI StrStringToInt32( |
| 94 __in_z LPCWSTR wzIn, |
| 95 __in DWORD cchIn, |
| 96 __out INT* piOut |
| 97 ); |
| 98 HRESULT DAPI StrStringToUInt32( |
| 99 __in_z LPCWSTR wzIn, |
| 100 __in DWORD cchIn, |
| 101 __out UINT* puiOut |
| 102 ); |
| 103 HRESULT DAPI StrStringToInt64( |
| 104 __in_z LPCWSTR wzIn, |
| 105 __in DWORD cchIn, |
| 106 __out LONGLONG* pllOut |
| 107 ); |
| 108 HRESULT DAPI StrStringToUInt64( |
| 109 __in_z LPCWSTR wzIn, |
| 110 __in DWORD cchIn, |
| 111 __out ULONGLONG* pullOut |
| 112 ); |
| 113 void DAPI StrStringToUpper( |
| 114 __inout_z LPWSTR wzIn |
| 115 ); |
| 116 void DAPI StrStringToLower( |
| 117 __inout_z LPWSTR wzIn |
| 118 ); |
| 119 |
| 120 |
| 121 #ifdef __cplusplus |
| 122 } |
| 123 #endif |
OLD | NEW |