📄 atldb.h
字号:
{
pPropInfoSet[ulSet].guidPropertySet = *(m_pUPropSet[ulSet].pPropSet);
}
}
else
{
GUID const& guidSet = rgPropertySets[ulSet].guidPropertySet;
if( (InlineIsEqualGUID(guidSet, DBPROPSET_DATASOURCEALL) ||
InlineIsEqualGUID(guidSet, DBPROPSET_DATASOURCEINFOALL) ||
InlineIsEqualGUID(guidSet, DBPROPSET_DBINITALL) ||
InlineIsEqualGUID(guidSet, DBPROPSET_SESSIONALL) ||
InlineIsEqualGUID(guidSet, DBPROPSET_ROWSETALL)) &&
GetPropertySetIndex(&guidSet) == S_OK )
{
for(ul=0; ul<m_cPropSetDex; ul++,ulOutIndex++)
{
pPropInfoSet[ulOutIndex].guidPropertySet = *(m_pUPropSet[m_rgiPropSetDex[ul]].pPropSet);
pPropInfoSet[ulOutIndex].cPropertyInfos = 0;
}
}
else
{
// Handle non-category property sets
// Handle unknown property sets
pPropInfoSet[ulOutIndex].guidPropertySet = guidSet;
pPropInfoSet[ulOutIndex].cPropertyInfos = rgPropertySets[ulSet].cPropertyIDs;
ulOutIndex++;
}
}
}
// Allocate a Description Buffer if needed
if( ppDescBuffer )
{
ULONG cBuffers = CalcDescripBuffers(cSets, pPropInfoSet);
if( cBuffers != 0 )
{
pDescBuffer = (WCHAR*)CoTaskMemAlloc(cBuffers * cchDescBuffSize * sizeof(WCHAR));
if(pDescBuffer == NULL)
{
hr = E_OUTOFMEMORY;
goto EXIT;
}
*ppDescBuffer = pDescBuffer;
memset(pDescBuffer, 0, (cBuffers * cchDescBuffSize * sizeof(WCHAR)));
}
}
// Process requested or derived Property sets
dwStatus = 0;
for(ulSet=0; ulSet<cSets; ulSet++)
{
ulNext=0;
cPropInfos = 0;
pPropInfo = NULL;
dwStatus &= (GETPROPINFO_ERRORSOCCURRED | GETPROPINFO_VALIDPROP);
// Calculate the number of property nodes needed for this
// property set.
if( cPropertySets == 0 )
{
ULONG ulTempSet;
if (pGuid != NULL)
ulTempSet = ulIndex;
else
ulTempSet = ulSet;
cPropInfos = m_pUPropSet[ulTempSet].cUPropInfo;
dwStatus |= GETPROPINFO_ALLPROPIDS;
m_rgiPropSetDex[0] = ulTempSet;
m_cPropSetDex = 1;
}
else
{
// If the count of PROPIDs is 0 (NOTE: the above routine already determined
// if it belonged to a category and if so set the count of properties to 0 for
// each propset in that category.
if( pPropInfoSet[ulSet].cPropertyInfos == 0 )
{
dwStatus |= GETPROPINFO_ALLPROPIDS;
// We have to determine if the property set is supported and if so
// the count of properties in the set.
if( GetPropertySetIndex(&(pPropInfoSet[ulSet].guidPropertySet)) == S_OK)
{
ATLASSERT( m_cPropSetDex == 1 );
cPropInfos += m_pUPropSet[m_rgiPropSetDex[0]].cUPropInfo;
}
else
{
// Not Supported
dwStatus |= GETPROPINFO_ERRORSOCCURRED;
goto NEXT_SET;
}
}
else
{
// We also handle the case here where the user has requested
// a non-initialization group property info set while the
// provider is not initialized. In this case, properties should
// not be set.
cPropInfos = pPropInfoSet[ulSet].cPropertyInfos;
if( (GetPropertySetIndex(&(pPropInfoSet[ulSet].guidPropertySet)) == S_FALSE)
|| (!bInitialized &&
!(InlineIsEqualGUID(pPropInfoSet[ulSet].guidPropertySet, DBPROPSET_DBINIT)) &&
!(InlineIsEqualGUID(pPropInfoSet[ulSet].guidPropertySet, DBPROPSET_DBINITALL))))
{
dwStatus |= GETPROPINFO_NOTSUPPORTED;
dwStatus |= GETPROPINFO_ERRORSOCCURRED;
}
}
}
// Allocate DBPROP array
ATLASSERT( cPropInfos != 0 );
pPropInfo = (DBPROPINFO*)CoTaskMemAlloc(cPropInfos * sizeof(DBPROPINFO));
if( pPropInfo )
{
// Initialize Buffer
memset(pPropInfo, 0, cPropInfos * sizeof(DBPROPINFO));
for(ULONG ulProp=0; ulProp<cPropInfos; ulProp++)
{
VariantInit(&(pPropInfo[ulProp].vValues));
if( dwStatus & GETPROPINFO_NOTSUPPORTED )
{
// Not supported, thus we need to mark all as NOT_SUPPORTED
pPropInfo[ulProp].dwPropertyID = rgPropertySets[ulSet].rgPropertyIDs[ulProp];
pPropInfo[ulProp].dwFlags = DBPROPFLAGS_NOTSUPPORTED;
dwStatus |= GETPROPINFO_ERRORSOCCURRED;
}
}
// Make sure we support the property set
if( dwStatus & GETPROPINFO_NOTSUPPORTED )
{
ulNext = cPropInfos;
goto NEXT_SET;
}
// Retrieve the property information for this property set
for(ul=0; ul<m_cPropSetDex; ul++)
{
pUPropInfo = (m_pUPropSet[m_rgiPropSetDex[ul]].pUPropInfo);
ATLASSERT( pUPropInfo );
// Retrieve current value of properties
if( dwStatus & GETPROPINFO_ALLPROPIDS )
{
for(ulProp=0; ulProp<m_pUPropSet[m_rgiPropSetDex[ul]].cUPropInfo; ulProp++)
{
// Verify property is supported, if not do not return
if( !TESTBIT(&(m_rgdwSupported[m_rgiPropSetDex[ul] * m_cElemPerSupported]), ulProp) )
continue;
pCurPropInfo = &(pPropInfo[ulNext]);
// If the ppDescBuffer pointer was not NULL, then
// we need supply description of the properties
if( ppDescBuffer )
{
// Set Buffer pointer
pCurPropInfo->pwszDescription = pDescBuffer;
// Load the string into temp buffer
cch = LoadDescription(pUPropInfo[ulProp].ulIDS, wszBuff, (sizeof(wszBuff)/sizeof(*wszBuff)));
if( cch )
{
// Adjust for '\0'
cch++;
// Transfer to official buffer if room
memcpy(pDescBuffer, wszBuff, cch * sizeof(WCHAR));
pDescBuffer += cch;
}
else
{
wcscpy(pDescBuffer, L"UNKNOWN");
pDescBuffer += (wcslen(L"UNKNOWN") + 1);
}
}
pCurPropInfo->dwPropertyID = pUPropInfo[ulProp].dwPropId;
pCurPropInfo->dwFlags = pUPropInfo[ulProp].dwFlags;
pCurPropInfo->vtType = pUPropInfo[ulProp].VarType;
pCurPropInfo->vValues.vt = VT_EMPTY;
dwStatus |= GETPROPINFO_VALIDPROP;
// Increment to next available buffer
ulNext++;
}
}
else
{
ATLASSERT( m_cPropSetDex == 1 );
for( ulProp = 0; ulProp < cPropInfos; ulProp++, ulNext++ )
{
pCurPropInfo = &(pPropInfo[ulNext]);
// Process Properties based on Restriction array.
pCurPropInfo->dwPropertyID = rgPropertySets[ulSet].rgPropertyIDs[ulProp];
if( GetUPropInfoPtr(m_rgiPropSetDex[ul], pCurPropInfo->dwPropertyID, &pUPropInfo)
== S_OK )
{
// If the ppDescBuffer pointer was not NULL, then
// we need supply description of the properties
if( ppDescBuffer )
{
// Set Buffer pointer
pCurPropInfo->pwszDescription = pDescBuffer;
// Load the string into temp buffer
cch = LoadDescription(pUPropInfo->ulIDS, wszBuff, (sizeof(wszBuff)/sizeof(*wszBuff)));
if( cch )
{
// Adjust for '\0'
cch++;
// Transfer to official buffer if room
memcpy(pDescBuffer, wszBuff, cch * sizeof(WCHAR));
pDescBuffer += cch;
}
else
{
wcscpy(pDescBuffer, L"UNKNOWN");
pDescBuffer += (wcslen(L"UNKNOWN") + 1);
}
}
pCurPropInfo->dwPropertyID = pUPropInfo->dwPropId;
pCurPropInfo->dwFlags = pUPropInfo->dwFlags;
pCurPropInfo->vtType = pUPropInfo->VarType;
dwStatus |= GETPROPINFO_VALIDPROP;
}
else
{
// Not Supported
pCurPropInfo->dwFlags = DBPROPFLAGS_NOTSUPPORTED;
dwStatus |= GETPROPINFO_ERRORSOCCURRED;
}
}
}
}
}
else
{
hr = E_OUTOFMEMORY;
goto EXIT;
}
NEXT_SET:
pPropInfoSet[ulSet].cPropertyInfos = ulNext;
pPropInfoSet[ulSet].rgPropertyInfos = pPropInfo;
}
// Success, set return values
*pcPropertyInfoSets = cSets;
*prgPropertyInfoSets = pPropInfoSet;
// At least one propid was marked as not S_OK
if( dwStatus & GETPROPINFO_ERRORSOCCURRED )
{
// If at least 1 property was set
if( dwStatus & GETPROPINFO_VALIDPROP )
return DB_S_ERRORSOCCURRED;
else
{
// Do not free any of the rgPropertyInfoSets, but
// do free the ppDescBuffer
if( pDescBuffer )
{
ATLASSERT( ppDescBuffer );
CoTaskMemFree(pDescBuffer);
*ppDescBuffer = NULL;
}
return DB_E_ERRORSOCCURRED;
}
}
return S_OK;
EXIT:
// Check if failure and clean up any allocated memory
if( FAILED(hr) &&
(hr != DB_E_ERRORSOCCURRED) )
{
// Free Description Buffer
if( pDescBuffer )
{
ATLASSERT( ppDescBuffer );
CoTaskMemFree(pDescBuffer);
*ppDescBuffer = NULL;
}
if( pPropInfoSet )
{
// Loop through Property Sets
for(ulSet=0; ulSet<cSets; ulSet++)
{
if( pPropInfoSet[ulSet].rgPropertyInfos )
CoTaskMemFree(pPropInfoSet[ulSet].rgPropertyInfos);
}
CoTaskMemFree(pPropInfoSet);
}
}
return hr;
}
ULONG m_cUPropSet; //count of UPropSet items
UPROPSET* m_pUPropSet; //Pointer to UPropset items
ULONG m_cPropSetDex; //count of UPropSet Indexes
ULONG* m_rgiPropSetDex;//array of UPropSet Index values
ULONG m_cElemPerSupported; //number of DWORDS per UPropSet to indicate supported UPropIds
DWORD* m_rgdwSupported;//array of DWORDs indicating supported UPropIds
HRESULT InitAvailUPropSets(ULONG* pcUPropSet, UPROPSET** ppUPropSet, ULONG* pcElemPerSupported, GUID* pguid)
{
ATLASSERT(pcUPropSet && ppUPropSet);
if (*ppUPropSet != NULL)
{
CoTaskMemFree(*ppUPropSet);
*ppUPropSet = NULL;
}
int cSets = (int)T::_GetPropSet(NULL, pcElemPerSupported);
UPROPSET* pSet = (UPROPSET*)CoTaskMemAlloc(sizeof(UPROPSET) * cSets);
if (pSet == NULL)
return E_OUTOFMEMORY;
*ppUPropSet = T::_GetPropSet(pcUPropSet, pcElemPerSupported, pSet, pguid);
return S_OK;
}
virtual HRESULT InitUPropSetsSupported()
{
ULONG cPropSet = 0, cElemsPerSupported = 0;
int cSets = (int)T::_GetPropSet(NULL, &cElemsPerSupported);
UPROPSET* pSet = (UPROPSET*)CoTaskMemAlloc(sizeof(UPROPSET) * cSets);
if (pSet == NULL)
return E_OUTOFMEMORY;
pSet = T::_GetPropSet(&cPropSet, &cElemsPerSupported, pSet);
memset(m_rgdwSupported, 0xFFFF, cPropSet * cElemsPerSupported * sizeof(DWORD));
CoTaskMemFree(pSet);
return S_OK;
}
//Load a localized description
int LoadDescription(ULONG ids, PWSTR pwszBuff, ULONG cchBuff)
{
USES_CONVERSION;
TCHAR* pszBuf = (TCHAR*)_alloca(cchBuff * sizeof(TCHAR));
if (pszBuf == NULL)
return 0;
int nTemp = LoadString(_pModule->GetResourceInstance(), ids, pszBuf, cchBuff);
wcscpy(pwszBuff, T2W(pszBuf));
return nTemp;
}
};
class ATL_NO_VTABLE CUtlPropsBase : public CBitFieldOps, public CDBIDOps
{
public:
ULONG m_cUPropSet; //count of UPropSet items
UPROPSET* m_pUPropSet; //Pointer to UPropset items
UPROP* m_pUProp;
ULONG m_cUPropSetHidden; //Count of Hidden items
DWORD m_dwFlags; //Configuration flags
ULONG m_cPropSetDex; //count of UPropSet Indexes
ULONG* m_rgiPropSetDex; //pointer to Array of UPropSet Index values
ULONG m_cElemPerSupported;//number of DWORDS per UPropSet to indicate supported UPropIds
DWORD* m_rgdwSupported; //pointer to array of DWORDs indicating supported UPropIds
DWORD* m_rgdwPropsInError;//pointer to array of DWORDs indicating if property is in error
enum EnumUPropSetFlags
{
UPROPSET_HIDDEN = 0x00000001,
UPROPSET_PASSTHROUGH = 0x00000002
};
enum EnumGetProp
{
GETPROP_ALLPROPIDS = 0x0001,
GETPROP_NOTSUPPORTED = 0x0002,
GETPROP_ERRORSOCCURRED = 0x0004,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -