File Index Symbol Index

#ifndef _INC_DPADSA
#define _INC_DPADSA
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma warning(push) #pragma once
#endif
#include <winapifamily.h>
#pragma region Desktop Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#ifndef _HRESULT_DEFINED
#define _HRESULT_DEFINED
typedef _Return_type_success_(return >= 0) long HRESULT;
#endif // !_HRESULT_DEFINED
//
// Define API decoration for direct importing of DLL references.
//
#ifndef WINCOMMCTRLAPI
#if !defined(_COMCTL32_) && defined(_WIN32)
#define WINCOMMCTRLAPI DECLSPEC_IMPORT
#else
#define WINCOMMCTRLAPI
#endif
#endif // WINCOMMCTRLAPI
#ifdef __cplusplus
extern
"C"
{
#endif
#ifndef NO_COMMCTRL_DA
#define __COMMCTRL_DA_DEFINED__
//
//====== Dynamic Array routines ==========================================
//
// Note that the STL and other libraries have similar functionality.
// The routines here are specific to Windows and may not be as convenient
// or fully functional as those in other libraries.
//
#define DA_LAST (0x7FFFFFFF)
#define DA_ERR (-1)
// Dynamic structure array
struct
_DSA
;
typedef
struct
_DSA
*
HDSA
;
#ifdef __cplusplus
{
DSA_DestroyCallback
(
hdsa
, (
PFNDAENUMCALLBACK
)
pfnCB
,
pData
); }
#endif
#ifdef __cplusplus
{
DSA_EnumCallback
(
hdsa
, (
PFNDAENUMCALLBACK
)
pfnCB
,
pData
); }
#endif
#define DSA_GetItemCount(hdsa) (*(int *)(hdsa))
#define DSA_AppendItem(hdsa, pitem) DSA_InsertItem(hdsa, DA_LAST, pitem)
#if (NTDDI_VERSION >= NTDDI_VISTA)
#ifdef __cplusplus
{
return
DSA_Sort
(
hdsa
, (
PFNDACOMPARE
)(
pfnCompare
),
lParam
); }
#endif #endif // NTDDI_VISTA
#define DSA_APPEND DA_LAST
#define DSA_ERR DA_ERR
#define PFNDSAENUMCALLBACK PFNDAENUMCALLBACK
#define PFNDSAENUMCALLBACKCONST PFNDAENUMCALLBACKCONST
#define PFNDSACOMPARE PFNDACOMPARE
#define PFNDSACOMPARECONST PFNDACOMPARECONST
// Dynamic pointer array
struct
_DPA
;
typedef
struct
_DPA
*
HDPA
;
#ifdef __cplusplus
{
DPA_DestroyCallback
(
hdpa
, (
PFNDAENUMCALLBACK
)
pfnCB
,
pData
); }
#endif
#ifdef __cplusplus
{
DPA_EnumCallback
(
hdpa
, (
PFNDAENUMCALLBACK
)
pfnCB
,
pData
); }
#endif
#define DPA_GetPtrCount(hdpa) (*(int *)(hdpa))
#define DPA_SetPtrCount(hdpa, cItems) (*(int *)(hdpa) = (cItems))
#define DPA_FastDeleteLastPtr(hdpa) (--*(int *)(hdpa))
#define DPA_GetPtrPtr(hdpa) (*((void * **)((BYTE *)(hdpa) + sizeof(void *))))
#define DPA_FastGetPtr(hdpa, i) (DPA_GetPtrPtr(hdpa)[i])
#define DPA_AppendPtr(hdpa, pitem) DPA_InsertPtr(hdpa, DA_LAST, pitem)
#if (NTDDI_VERSION >= NTDDI_VISTA)
#ifdef __cplusplus
{
return
DPA_Sort
(
hdpa
, (
PFNDACOMPARE
)(
pfnCompare
),
lParam
); }
#endif
//
// Save to and load from a stream. The stream callback gets a pointer to
// a DPASTREAMINFO structure.
//
// For DPA_SaveStream, the callback is responsible for writing the pvItem
// info to the stream. (It's not necessary to write the iPos to the
// stream.) Return S_OK if the element was saved, S_FALSE if it wasn't
// but continue anyway, or some failure.
//
// For DPA_LoadStream, the callback is responsible for allocating an
// item and setting the pvItem field to the new pointer. Return S_OK
// if the element was loaded, S_FALSE it it wasn't but continue anyway,
// or some failure.
//
typedef
struct
_DPASTREAMINFO
{
int
iPos
;
// Index of item
void
*
pvItem
; }
DPASTREAMINFO
;
struct
IStream
;
// Merge two DPAs. This takes two (optionally) presorted arrays and merges
// the source array into the dest. DPA_Merge uses the provided callbacks
// to perform comparison and merge operations. The merge callback is
// called when two elements (one in each list) match according to the
// compare function. This allows portions of an element in one list to
// be merged with the respective element in the second list.
//
// The first DPA (hdpaDest) is the output array.
//
// Merge options:
//
// DPAM_SORTED The arrays are already sorted; don't sort
// DPAM_UNION The resulting array is the union of all elements
// in both arrays (DPAMM_INSERT may be sent for
// this merge option.)
// DPAM_INTERSECT Only elements in the source array that intersect
// with the dest array are merged. (DPAMM_DELETE
// may be sent for this merge option.)
// DPAM_NORMAL Like DPAM_INTERSECT except the dest array
// also maintains its original, additional elements.
//
#define DPAM_SORTED 0x00000001
#define DPAM_NORMAL 0x00000002
#define DPAM_UNION 0x00000004
#define DPAM_INTERSECT 0x00000008
// The merge callback should merge contents of the two items and return
// the pointer of the merged item. It's okay to simply use pvDest
// as the returned pointer.
//
// Messages for merge callback
#define DPAMM_MERGE 1
#define DPAMM_DELETE 2
#define DPAMM_INSERT 3
#ifdef __cplusplus
{
return
DPA_Merge
(
hdpaDest
,
hdpaSrc
,
dwFlags
, (
PFNDACOMPARE
)
pfnCompare
, (
PFNDPAMERGE
)
pfnMerge
,
lParam
); }
#endif
//
// Search array. If DPAS_SORTED, then array is assumed to be sorted
// according to pfnCompare, and binary search algorithm is used.
// Otherwise, linear search is used.
//
// Searching starts at iStart (0 to start search at beginning).
//
// DPAS_INSERTBEFORE/AFTER govern what happens if an exact match is not
// found. If neither are specified, this function returns -1 if no exact
// match is found. Otherwise, the index of the item before or after the
// closest (including exact) match is returned.
//
// Search option flags
//
#define DPAS_SORTED 0x0001
#define DPAS_INSERTBEFORE 0x0002
#define DPAS_INSERTAFTER 0x0004
#ifdef __cplusplus
{
return
DPA_Search
(
hdpa
,
const_cast
<
void
*>(
pFind
),
iStart
, (
PFNDACOMPARE
)
pfnCompare
,
lParam
,
options
); }
#endif
#define DPA_SortedInsertPtr(hdpa, pFind, iStart, pfnCompare, lParam, options, pitem) \
DPA_InsertPtr(hdpa, DPA_Search(hdpa, pFind, iStart, pfnCompare, lParam, (DPAS_SORTED | (options))), (pitem))
#define DPA_APPEND DA_LAST
#define DPA_ERR DA_ERR
#define PFNDPAENUMCALLBACK PFNDAENUMCALLBACK
#define PFNDPAENUMCALLBACKCONST PFNDAENUMCALLBACKCONST
#define PFNDPACOMPARE PFNDACOMPARE
#define PFNDPACOMPARECONST PFNDACOMPARECONST
#endif // NO_COMMCTRL_DA
#if !defined(RC_INVOKED) /* RC complains about long symbols in #ifs */
#if defined(ISOLATION_AWARE_ENABLED) && (ISOLATION_AWARE_ENABLED != 0)
#include "dpa_dsa.inl" #endif /* ISOLATION_AWARE_ENABLED */ #endif /* RC */
#ifdef __cplusplus
}
#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma warning(pop)
#endif
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
#pragma endregion
#endif /* _INC_DPADSA */