Populate a date log handle with dates from file or generate date range with optional merge operations
LoadDateLogHandle is the primary function for populating date collections with data. It supports three modes of operation: loading from file (for DateLog and Holidays), generating date ranges (for DateRange), and automatic merging with conflict resolution. The function handles multi-threaded parsing, validation, and automatic date range generation to extend collections beyond file data.
This is a comprehensive loader that serves multiple purposes:
HRESULT _Must_inspect_result_ _Success_(SUCCEEDED(return)) LoadDateLogHandle(
_In_opt_ PFILE_INFO pFileInfo,
_In_opt_ _When_(pFileInfo == NULL, _Notnull_) DATE_ITEM_HANDLE hStartDate,
_In_opt_ _When_(pFileInfo == NULL, _Notnull_) DATE_ITEM_HANDLE hEndDate,
_In_ DATE_LOG_HANDLE hDateLogHandle,
_In_opt_ PDATE_COLLECTION_PROGRESS pProgData,
_In_ DWORD dwFlags
);
Standard C calling convention with SAL annotations for parameter validation and return value inspection.
[In, Optional] PFILE_INFO
File to parse for date data. Mutually exclusive with hStartDate/hEndDate.
[In, Optional] DATE_ITEM_HANDLE
Start date for range generation. Required when pFileInfo is NULL.
[In, Optional] DATE_ITEM_HANDLE
End date for range generation. Required when pFileInfo is NULL for DateRange.
[In] DATE_LOG_HANDLE
Target handle to populate. Type determines loading behavior.
InitializeDateLogHandle()[In, Optional] PDATE_COLLECTION_PROGRESS
Progress callback structure for reporting parsing progress.
[In] DWORD
Behavior flags controlling merge and generation options.
| Flag | Value | Behavior |
|---|---|---|
DATE_RANGE_MERGE_FAVOR_SOURCE |
0x08 | When extending log, use source UUIDs for overlapping dates |
DATE_RANGE_MERGE_FAVOR_DEST |
0x04 | When extending log, keep destination UUIDs for overlapping dates |
PARSE_VERIFY_ENABLE_FLAG |
0x40 | Verify consecutive market days during parsing |
Handle successfully populated with date data.
Invalid parameter combination or NULL handle.
The provided hDateLogHandle is invalid or corrupted.
The holidays handle within the datelog is invalid.
End date is not covered by holidays (is a holiday itself).
Date range gap exceeds available capacity or DATE_LOG_MAX limit.
Start and end dates are same or have zero market days between them.
Date records in file are malformed or unreadable.
Error reading file data or insufficient data in file.
Insufficient memory for parsing or range generation.
// Create date log and holidays
HOLIDAYS_HANDLE hHolidays = NULL;
InitializeDateLogHandle(NULL, 0, NULL, &hHolidays, HandleIsForHolidays);
PFILE_INFO pHolidaysFile = /* load holidays file */;
LoadDateLogHandle(pHolidaysFile, NULL, NULL, hHolidays, NULL, 0);
// Create and load date log from file
DATE_LOG_HANDLE hDateLog = NULL;
InitializeDateLogHandle(NULL, 0, hHolidays, &hDateLog, HandleIsForDatelog);
PFILE_INFO pDateFile = /* load date log file */;
HRESULT hr = LoadDateLogHandle(
pDateFile, // File with date data
NULL,
NULL,
hDateLog,
NULL,
0
);
if (SUCCEEDED(hr)) {
DWORD count = GetDateCollectionLength(hDateLog);
printf("Loaded %d dates from file\n", count);
}
// Create range handle
DATE_RANGE_HANDLE hRange = NULL;
InitializeDateLogHandle(NULL, 10000, hHolidays, &hRange, HandleIsForRange);
// Generate dates from start to end
DATE_ITEM_HANDLE hStart = /* ... */;
DATE_ITEM_HANDLE hEnd = /* ... */;
HRESULT hr = LoadDateLogHandle(
NULL, // No file
hStart, // Start date for generation
hEnd, // End date for generation
hRange, // Target range
NULL,
0
);
if (SUCCEEDED(hr)) {
hr = MergeDateLogHandle(hMainLog, hRange,
DATE_RANGE_MERGE_FAVOR_SOURCE);
}
FreeDateCollectionHandle(hRange);
GUID:YYYY-MM-DD,. Malformed records cause parsing to fail.
InitializeDateLogHandle() - Create handle before loadingMergeDateLogHandle() - Merge loaded rangesDuplicateDateLogHandle() - Create concurrent access handle