mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-06-02 15:46:39 +08:00
Update release
This commit is contained in:
@@ -96,6 +96,7 @@ Helper Functions
|
||||
case INativeWindowListener::Title:
|
||||
cursor = INativeCursor::SizeAll;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -356,10 +356,96 @@ Mouse Move Events
|
||||
UseEvents().OnIOMouseMoving(MakeMouseInfo());
|
||||
}
|
||||
|
||||
NativePoint GetMousePosition()
|
||||
{
|
||||
#define ERROR_MESSAGE_PREFIX CLASS_PREFIX L"GetMousePosition()#"
|
||||
CHECK_ERROR(mousePosition, CLASS_PREFIX L"The mouse position is not set.");
|
||||
return mousePosition.Value();
|
||||
#undef ERROR_MESSAGE_PREFIX
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
Mouse Wheel Events
|
||||
***********************************************************************/
|
||||
|
||||
void _Wheel(vint up, Nullable<NativePoint> position = {})
|
||||
{
|
||||
if (position) MouseMove(position.Value());
|
||||
auto info = MakeMouseInfo();
|
||||
info.wheel = up;
|
||||
UseEvents().OnIOVWheel(info);
|
||||
}
|
||||
|
||||
void _Wheel(vint up, Nullable<NativePoint> position, bool ctrl, bool shift, bool alt)
|
||||
{
|
||||
if (ctrl) _KeyDown(VKEY::KEY_CONTROL);
|
||||
if (shift) _KeyDown(VKEY::KEY_SHIFT);
|
||||
if (alt) _KeyDown(VKEY::KEY_MENU);
|
||||
_Wheel(up, position);
|
||||
if (alt) _KeyUp(VKEY::KEY_MENU);
|
||||
if (shift) _KeyUp(VKEY::KEY_SHIFT);
|
||||
if (ctrl) _KeyUp(VKEY::KEY_CONTROL);
|
||||
}
|
||||
|
||||
void _HWheel(vint right, Nullable<NativePoint> position = {})
|
||||
{
|
||||
if (position) MouseMove(position.Value());
|
||||
auto info = MakeMouseInfo();
|
||||
info.wheel = right;
|
||||
UseEvents().OnIOHWheel(info);
|
||||
}
|
||||
|
||||
void _HWheel(vint right, Nullable<NativePoint> position, bool ctrl, bool shift, bool alt)
|
||||
{
|
||||
if (ctrl) _KeyDown(VKEY::KEY_CONTROL);
|
||||
if (shift) _KeyDown(VKEY::KEY_SHIFT);
|
||||
if (alt) _KeyDown(VKEY::KEY_MENU);
|
||||
_HWheel(right, position);
|
||||
if (alt) _KeyUp(VKEY::KEY_MENU);
|
||||
if (shift) _KeyUp(VKEY::KEY_SHIFT);
|
||||
if (ctrl) _KeyUp(VKEY::KEY_CONTROL);
|
||||
}
|
||||
|
||||
void WheelDown(vint jumps = 1, Nullable<NativePoint> position = {})
|
||||
{
|
||||
_Wheel(-jumps * 120, position);
|
||||
}
|
||||
|
||||
void WheelDown(vint jumps, Nullable<NativePoint> position, bool ctrl, bool shift, bool alt)
|
||||
{
|
||||
_Wheel(-jumps * 120, position, ctrl, shift, alt);
|
||||
}
|
||||
|
||||
void WheelUp(vint jumps = 1, Nullable<NativePoint> position = {})
|
||||
{
|
||||
_Wheel(jumps * 120, position);
|
||||
}
|
||||
|
||||
void WheelUp(vint jumps, Nullable<NativePoint> position, bool ctrl, bool shift, bool alt)
|
||||
{
|
||||
_Wheel(jumps * 120, position, ctrl, shift, alt);
|
||||
}
|
||||
|
||||
void HWheelLeft(vint jumps = 1, Nullable<NativePoint> position = {})
|
||||
{
|
||||
_HWheel(-jumps * 120, position);
|
||||
}
|
||||
|
||||
void HWheelLeft(vint jumps, Nullable<NativePoint> position, bool ctrl, bool shift, bool alt)
|
||||
{
|
||||
_HWheel(-jumps * 120, position, ctrl, shift, alt);
|
||||
}
|
||||
|
||||
void HWheelRight(vint jumps = 1, Nullable<NativePoint> position = {})
|
||||
{
|
||||
_HWheel(jumps * 120, position);
|
||||
}
|
||||
|
||||
void HWheelRight(vint jumps, Nullable<NativePoint> position, bool ctrl, bool shift, bool alt)
|
||||
{
|
||||
_HWheel(jumps * 120, position, ctrl, shift, alt);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
Mouse Click Events
|
||||
***********************************************************************/
|
||||
|
||||
+27
-11
@@ -345,9 +345,7 @@ GuiApplication
|
||||
|
||||
void GuiApplication::RegisterPopupClosed(GuiPopup* popup)
|
||||
{
|
||||
if(openingPopups.Remove(popup))
|
||||
{
|
||||
}
|
||||
openingPopups.Remove(popup);
|
||||
}
|
||||
|
||||
void GuiApplication::TooltipMouseEnter(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments)
|
||||
@@ -623,18 +621,18 @@ GuiApplicationMain
|
||||
}
|
||||
|
||||
GetCurrentController()->InputService()->StartTimer();
|
||||
{
|
||||
GuiApplication app;
|
||||
application = &app;
|
||||
IAsyncScheduler::RegisterSchedulerForCurrentThread(Ptr(new UIThreadAsyncScheduler));
|
||||
IAsyncScheduler::RegisterDefaultScheduler(Ptr(new OtherThreadAsyncScheduler));
|
||||
GuiInitializeUtilities();
|
||||
{
|
||||
GuiApplication app;
|
||||
application = &app;
|
||||
GuiMain();
|
||||
}
|
||||
application = nullptr;
|
||||
GuiFinalizeUtilities();
|
||||
IAsyncScheduler::UnregisterDefaultScheduler();
|
||||
IAsyncScheduler::UnregisterSchedulerForCurrentThread();
|
||||
application = nullptr;
|
||||
}
|
||||
GetCurrentController()->InputService()->StopTimer();
|
||||
theme::FinalizeTheme();
|
||||
FinalizeGlobalStorage();
|
||||
@@ -673,13 +671,11 @@ GuiApplicationMain
|
||||
}
|
||||
|
||||
GetCurrentController()->InputService()->StartTimer();
|
||||
{
|
||||
IAsyncScheduler::RegisterSchedulerForCurrentThread(Ptr(new UIThreadAsyncScheduler));
|
||||
IAsyncScheduler::RegisterDefaultScheduler(Ptr(new OtherThreadAsyncScheduler));
|
||||
GuiMain();
|
||||
IAsyncScheduler::UnregisterDefaultScheduler();
|
||||
IAsyncScheduler::UnregisterSchedulerForCurrentThread();
|
||||
}
|
||||
GetCurrentController()->InputService()->StopTimer();
|
||||
FinalizeGlobalStorage();
|
||||
|
||||
@@ -825,6 +821,18 @@ GuiControl
|
||||
}
|
||||
}
|
||||
|
||||
void GuiControl::FixingMissingControlTemplateCallback(templates::GuiControlTemplate* value)
|
||||
{
|
||||
}
|
||||
|
||||
void GuiControl::CallFixingMissingControlTemplateCallback()
|
||||
{
|
||||
if (controlTemplateObject)
|
||||
{
|
||||
FixingMissingControlTemplateCallback(controlTemplateObject);
|
||||
}
|
||||
}
|
||||
|
||||
void GuiControl::OnChildInserted(GuiControl* control)
|
||||
{
|
||||
GuiControl* oldParent=control->parent;
|
||||
@@ -2789,6 +2797,9 @@ GuiWindow
|
||||
|
||||
void GuiWindow::Opened()
|
||||
{
|
||||
// Workaround:
|
||||
// Constructor calling SetNativeWindow skips AfterControlTemplateInstalled_ of all sub classes
|
||||
CallFixingMissingControlTemplateCallback();
|
||||
GuiControlHost::Opened();
|
||||
if (auto ct = TypedControlTemplateObject(false))
|
||||
{
|
||||
@@ -6878,7 +6889,7 @@ GuiScrollView
|
||||
{
|
||||
vint position = scroll->GetPosition();
|
||||
vint move = scroll->GetSmallMove();
|
||||
position -= move * arguments.wheel / 60;
|
||||
position = move * arguments.wheel / 60;
|
||||
scroll->SetPosition(position);
|
||||
}
|
||||
}
|
||||
@@ -25834,6 +25845,11 @@ GuiBindableRibbonGalleryList
|
||||
}
|
||||
}
|
||||
|
||||
GuiSelectableListControl* GuiBindableRibbonGalleryList::GetListControlInDropdown()
|
||||
{
|
||||
return itemList;
|
||||
}
|
||||
|
||||
GuiToolstripMenu* GuiBindableRibbonGalleryList::GetSubMenu()
|
||||
{
|
||||
return subMenu;
|
||||
|
||||
+18
-1
@@ -2639,7 +2639,7 @@ INativeWindow
|
||||
T x;
|
||||
/// <summary>The mouse position of y dimension.</summary>
|
||||
T y;
|
||||
/// <summary>The delta of the wheel.</summary>
|
||||
/// <summary>The delta of the wheel. 120 for every tick, position for up/right, negative for down/left</summary>
|
||||
vint wheel;
|
||||
/// <summary>True if the mouse is in the non-client area.</summary>
|
||||
bool nonClient;
|
||||
@@ -10098,6 +10098,8 @@ Basic Construction
|
||||
virtual void CheckAndStoreControlTemplate(templates::GuiControlTemplate* value);
|
||||
virtual void EnsureControlTemplateExists();
|
||||
virtual void RebuildControlTemplate();
|
||||
virtual void FixingMissingControlTemplateCallback(templates::GuiControlTemplate* value);
|
||||
virtual void CallFixingMissingControlTemplateCallback();
|
||||
virtual void OnChildInserted(GuiControl* control);
|
||||
virtual void OnChildRemoved(GuiControl* control);
|
||||
virtual void OnParentChanged(GuiControl* oldParent, GuiControl* newParent);
|
||||
@@ -10390,6 +10392,17 @@ Basic Construction
|
||||
NAME = ct; \
|
||||
BASE_TYPE::CheckAndStoreControlTemplate(value); \
|
||||
} \
|
||||
void FixingMissingControlTemplateCallback(templates::GuiControlTemplate* value)override \
|
||||
{ \
|
||||
BASE_TYPE::FixingMissingControlTemplateCallback(value); \
|
||||
if (!NAME) \
|
||||
{ \
|
||||
auto ct = dynamic_cast<templates::Gui##TEMPLATE*>(value); \
|
||||
CHECK_ERROR(ct, L"The assigned control template is not vl::presentation::templates::Gui" L ## # TEMPLATE L"."); \
|
||||
NAME = ct; \
|
||||
AfterControlTemplateInstalled_(true); \
|
||||
} \
|
||||
} \
|
||||
public: \
|
||||
templates::Gui##TEMPLATE* TypedControlTemplateObject(bool ensureExists) \
|
||||
{ \
|
||||
@@ -21757,6 +21770,10 @@ Ribbon Gallery List
|
||||
/// <param name="value">The minimum items visible in the drop down menu.</param>
|
||||
void SetVisibleItemCount(vint value);
|
||||
|
||||
/// <summary>Get the list control in the dropdown menu.</summary>
|
||||
/// <returns>The list control in the dropdown menu.</returns>
|
||||
GuiSelectableListControl* GetListControlInDropdown();
|
||||
|
||||
/// <summary>Get the dropdown menu.</summary>
|
||||
/// <returns>The dropdown menu.</returns>
|
||||
GuiToolstripMenu* GetSubMenu();
|
||||
|
||||
@@ -2924,6 +2924,7 @@ Type Declaration (Class)
|
||||
CLASS_MEMBER_PROPERTY_EVENT_READONLY_FAST(SelectedIndex, SelectionChanged)
|
||||
CLASS_MEMBER_PROPERTY_EVENT_READONLY_FAST(SelectedItem, SelectionChanged)
|
||||
CLASS_MEMBER_PROPERTY_FAST(VisibleItemCount)
|
||||
CLASS_MEMBER_PROPERTY_READONLY_FAST(ListControlInDropdown)
|
||||
|
||||
CLASS_MEMBER_METHOD(IndexToGalleryPos, { L"index" })
|
||||
CLASS_MEMBER_METHOD(GalleryPosToIndex, { L"pos" })
|
||||
|
||||
+2717
-2937
File diff suppressed because it is too large
Load Diff
+596
-674
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -2332,7 +2332,7 @@ SortedList
|
||||
/// or the least element that greater than the specified value.
|
||||
/// </param>
|
||||
template<typename T>
|
||||
vint BinarySearchLambda2(const T* buffer, vint count, const T& item, vint& index)
|
||||
vint BinarySearchLambda(const T* buffer, vint count, const T& item, vint& index)
|
||||
{
|
||||
return BinarySearchLambda<T, T>(buffer, count, item, index, [](const T& a, const T& b) { return a <=> b; });
|
||||
}
|
||||
|
||||
+2
-390
@@ -255,10 +255,6 @@ Author: Zihan Chen (vczh)
|
||||
Licensed under https://github.com/vczh-libraries/License
|
||||
***********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <wctype.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#ifndef VCZH_GCC
|
||||
static_assert(false, "Do not build this file for Windows applications.");
|
||||
@@ -266,393 +262,9 @@ static_assert(false, "Do not build this file for Windows applications.");
|
||||
|
||||
namespace vl
|
||||
{
|
||||
using namespace collections;
|
||||
|
||||
/***********************************************************************
|
||||
Locale
|
||||
***********************************************************************/
|
||||
|
||||
Locale Locale::Invariant()
|
||||
ILocaleImpl* GetOSLocaleImpl()
|
||||
{
|
||||
return Locale(L"");
|
||||
}
|
||||
|
||||
Locale Locale::SystemDefault()
|
||||
{
|
||||
return Locale(L"en-US");
|
||||
}
|
||||
|
||||
Locale Locale::UserDefault()
|
||||
{
|
||||
return Locale(L"en-US");
|
||||
}
|
||||
|
||||
void Locale::Enumerate(collections::List<Locale>& locales)
|
||||
{
|
||||
locales.Add(Locale(L"en-US"));
|
||||
}
|
||||
|
||||
void Locale::GetShortDateFormats(collections::List<WString>& formats)const
|
||||
{
|
||||
formats.Add(L"MM/dd/yyyy");
|
||||
formats.Add(L"yyyy-MM-dd");
|
||||
}
|
||||
|
||||
void Locale::GetLongDateFormats(collections::List<WString>& formats)const
|
||||
{
|
||||
formats.Add(L"dddd, dd MMMM yyyy");
|
||||
}
|
||||
|
||||
void Locale::GetYearMonthDateFormats(collections::List<WString>& formats)const
|
||||
{
|
||||
formats.Add(L"yyyy MMMM");
|
||||
}
|
||||
|
||||
void Locale::GetLongTimeFormats(collections::List<WString>& formats)const
|
||||
{
|
||||
formats.Add(L"HH:mm:ss");
|
||||
}
|
||||
|
||||
void Locale::GetShortTimeFormats(collections::List<WString>& formats)const
|
||||
{
|
||||
formats.Add(L"HH:mm");
|
||||
formats.Add(L"hh:mm tt");
|
||||
}
|
||||
|
||||
WString Locale::FormatDate(const WString& format, DateTime date)const
|
||||
{
|
||||
/*
|
||||
auto df = L"yyyy,MM,MMM,MMMM,dd,ddd,dddd";
|
||||
auto ds = L"2000,01,Jan,January,02,Sun,Sunday";
|
||||
auto tf = L"hh,HH,mm,ss,tt";
|
||||
auto ts = L"01,13,02,03,PM";
|
||||
*/
|
||||
WString result;
|
||||
const wchar_t* reading = format.Buffer();
|
||||
|
||||
while (*reading)
|
||||
{
|
||||
if (wcsncmp(reading, L"yyyy", 4) == 0)
|
||||
{
|
||||
WString fragment = itow(date.year);
|
||||
while (fragment.Length() < 4) fragment = L"0" + fragment;
|
||||
result += fragment;
|
||||
reading += 4;
|
||||
}
|
||||
else if (wcsncmp(reading, L"MMMM", 4) == 0)
|
||||
{
|
||||
result += GetLongMonthName(date.month);
|
||||
reading += 4;
|
||||
}
|
||||
else if (wcsncmp(reading, L"MMM", 3) == 0)
|
||||
{
|
||||
result += GetShortMonthName(date.month);
|
||||
reading += 3;
|
||||
}
|
||||
else if (wcsncmp(reading, L"MM", 2) == 0)
|
||||
{
|
||||
WString fragment = itow(date.month);
|
||||
while (fragment.Length() < 2) fragment = L"0" + fragment;
|
||||
result += fragment;
|
||||
reading += 2;
|
||||
}
|
||||
else if (wcsncmp(reading, L"dddd", 4) == 0)
|
||||
{
|
||||
result += GetLongDayOfWeekName(date.dayOfWeek);
|
||||
reading += 4;
|
||||
}
|
||||
else if (wcsncmp(reading, L"ddd", 3) == 0)
|
||||
{
|
||||
result += GetShortDayOfWeekName(date.dayOfWeek);
|
||||
reading += 3;
|
||||
}
|
||||
else if (wcsncmp(reading, L"dd", 2) == 0)
|
||||
{
|
||||
WString fragment = itow(date.day);
|
||||
while (fragment.Length() < 2) fragment = L"0" + fragment;
|
||||
result += fragment;
|
||||
reading += 2;
|
||||
}
|
||||
else if (wcsncmp(reading, L"hh", 2) == 0)
|
||||
{
|
||||
WString fragment = itow(date.hour > 12 ? date.hour - 12 : date.hour);
|
||||
while (fragment.Length() < 2) fragment = L"0" + fragment;
|
||||
result += fragment;
|
||||
reading += 2;
|
||||
}
|
||||
else if (wcsncmp(reading, L"HH", 2) == 0)
|
||||
{
|
||||
WString fragment = itow(date.hour);
|
||||
while (fragment.Length() < 2) fragment = L"0" + fragment;
|
||||
result += fragment;
|
||||
reading += 2;
|
||||
}
|
||||
else if (wcsncmp(reading, L"mm", 2) == 0)
|
||||
{
|
||||
WString fragment = itow(date.minute);
|
||||
while (fragment.Length() < 2) fragment = L"0" + fragment;
|
||||
result += fragment;
|
||||
reading += 2;
|
||||
}
|
||||
else if (wcsncmp(reading, L"ss", 2) == 0)
|
||||
{
|
||||
WString fragment = itow(date.second);
|
||||
while (fragment.Length() < 2) fragment = L"0" + fragment;
|
||||
result += fragment;
|
||||
reading += 2;
|
||||
}
|
||||
else if (wcsncmp(reading, L"tt", 2) == 0)
|
||||
{
|
||||
result += date.hour > 12 ? L"PM" : L"AM";
|
||||
reading += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += WString::FromChar(*reading);
|
||||
reading++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
WString Locale::FormatTime(const WString& format, DateTime time)const
|
||||
{
|
||||
return FormatDate(format, time);
|
||||
}
|
||||
|
||||
WString Locale::FormatNumber(const WString& number)const
|
||||
{
|
||||
return number;
|
||||
}
|
||||
|
||||
WString Locale::FormatCurrency(const WString& currency)const
|
||||
{
|
||||
return currency;
|
||||
}
|
||||
|
||||
WString Locale::GetShortDayOfWeekName(vint dayOfWeek)const
|
||||
{
|
||||
switch (dayOfWeek)
|
||||
{
|
||||
case 0: return L"Sun";
|
||||
case 1: return L"Mon";
|
||||
case 2: return L"Tue";
|
||||
case 3: return L"Wed";
|
||||
case 4: return L"Thu";
|
||||
case 5: return L"Fri";
|
||||
case 6: return L"Sat";
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
WString Locale::GetLongDayOfWeekName(vint dayOfWeek)const
|
||||
{
|
||||
switch (dayOfWeek)
|
||||
{
|
||||
case 0: return L"Sunday";
|
||||
case 1: return L"Monday";
|
||||
case 2: return L"Tuesday";
|
||||
case 3: return L"Wednesday";
|
||||
case 4: return L"Thursday";
|
||||
case 5: return L"Friday";
|
||||
case 6: return L"Saturday";
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
WString Locale::GetShortMonthName(vint month)const
|
||||
{
|
||||
switch (month)
|
||||
{
|
||||
case 1: return L"Jan";
|
||||
case 2: return L"Feb";
|
||||
case 3: return L"Mar";
|
||||
case 4: return L"Apr";
|
||||
case 5: return L"May";
|
||||
case 6: return L"Jun";
|
||||
case 7: return L"Jul";
|
||||
case 8: return L"Aug";
|
||||
case 9: return L"Sep";
|
||||
case 10: return L"Oct";
|
||||
case 11: return L"Nov";
|
||||
case 12: return L"Dec";
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
WString Locale::GetLongMonthName(vint month)const
|
||||
{
|
||||
switch (month)
|
||||
{
|
||||
case 1: return L"January";
|
||||
case 2: return L"February";
|
||||
case 3: return L"March";
|
||||
case 4: return L"April";
|
||||
case 5: return L"May";
|
||||
case 6: return L"June";
|
||||
case 7: return L"July";
|
||||
case 8: return L"August";
|
||||
case 9: return L"September";
|
||||
case 10: return L"October";
|
||||
case 11: return L"November";
|
||||
case 12: return L"December";
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
WString Locale::ToLower(const WString& str)const
|
||||
{
|
||||
return wlower(str);
|
||||
}
|
||||
|
||||
WString Locale::ToUpper(const WString& str)const
|
||||
{
|
||||
return wupper(str);
|
||||
}
|
||||
|
||||
WString Locale::ToLinguisticLower(const WString& str)const
|
||||
{
|
||||
return wlower(str);
|
||||
}
|
||||
|
||||
WString Locale::ToLinguisticUpper(const WString& str)const
|
||||
{
|
||||
return wupper(str);
|
||||
}
|
||||
|
||||
vint Locale::Compare(const WString& s1, const WString& s2, Normalization normalization)const
|
||||
{
|
||||
switch (normalization)
|
||||
{
|
||||
case Normalization::None:
|
||||
return wcscmp(s1.Buffer(), s2.Buffer());
|
||||
case Normalization::IgnoreCase:
|
||||
return wcscasecmp(s1.Buffer(), s2.Buffer());
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
vint Locale::CompareOrdinal(const WString& s1, const WString& s2)const
|
||||
{
|
||||
return wcscmp(s1.Buffer(), s2.Buffer());
|
||||
}
|
||||
|
||||
vint Locale::CompareOrdinalIgnoreCase(const WString& s1, const WString& s2)const
|
||||
{
|
||||
return wcscasecmp(s1.Buffer(), s2.Buffer());
|
||||
}
|
||||
|
||||
collections::Pair<vint, vint> Locale::FindFirst(const WString& text, const WString& find, Normalization normalization)const
|
||||
{
|
||||
if (text.Length() < find.Length() || find.Length() == 0)
|
||||
{
|
||||
return Pair<vint, vint>(-1, 0);
|
||||
}
|
||||
const wchar_t* result = 0;
|
||||
switch (normalization)
|
||||
{
|
||||
case Normalization::None:
|
||||
{
|
||||
const wchar_t* reading = text.Buffer();
|
||||
while (*reading)
|
||||
{
|
||||
if (wcsncmp(reading, find.Buffer(), find.Length()) == 0)
|
||||
{
|
||||
result = reading;
|
||||
break;
|
||||
}
|
||||
reading++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Normalization::IgnoreCase:
|
||||
{
|
||||
const wchar_t* reading = text.Buffer();
|
||||
while (*reading)
|
||||
{
|
||||
if (wcsncasecmp(reading, find.Buffer(), find.Length()) == 0)
|
||||
{
|
||||
result = reading;
|
||||
break;
|
||||
}
|
||||
reading++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result == nullptr ? Pair<vint, vint>(-1, 0) : Pair<vint, vint>(result - text.Buffer(), find.Length());
|
||||
}
|
||||
|
||||
collections::Pair<vint, vint> Locale::FindLast(const WString& text, const WString& find, Normalization normalization)const
|
||||
{
|
||||
if (text.Length() < find.Length() || find.Length() == 0)
|
||||
{
|
||||
return Pair<vint, vint>(-1, 0);
|
||||
}
|
||||
const wchar_t* result = 0;
|
||||
switch (normalization)
|
||||
{
|
||||
case Normalization::None:
|
||||
{
|
||||
const wchar_t* reading = text.Buffer();
|
||||
while (*reading)
|
||||
{
|
||||
if (wcsncmp(reading, find.Buffer(), find.Length()) == 0)
|
||||
{
|
||||
result = reading;
|
||||
}
|
||||
reading++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Normalization::IgnoreCase:
|
||||
{
|
||||
const wchar_t* reading = text.Buffer();
|
||||
while (*reading)
|
||||
{
|
||||
if (wcsncasecmp(reading, find.Buffer(), find.Length()) == 0)
|
||||
{
|
||||
result = reading;
|
||||
}
|
||||
reading++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result == nullptr ? Pair<vint, vint>(-1, 0) : Pair<vint, vint>(result - text.Buffer(), find.Length());
|
||||
}
|
||||
|
||||
bool Locale::StartsWith(const WString& text, const WString& find, Normalization normalization)const
|
||||
{
|
||||
if (text.Length() < find.Length() || find.Length() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (normalization)
|
||||
{
|
||||
case Normalization::None:
|
||||
return wcsncmp(text.Buffer(), find.Buffer(), find.Length()) == 0;
|
||||
case Normalization::IgnoreCase:
|
||||
return wcsncasecmp(text.Buffer(), find.Buffer(), find.Length()) == 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Locale::EndsWith(const WString& text, const WString& find, Normalization normalization)const
|
||||
{
|
||||
if (text.Length() < find.Length() || find.Length() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
switch (normalization)
|
||||
{
|
||||
case Normalization::None:
|
||||
return wcsncmp(text.Buffer() + text.Length() - find.Length(), find.Buffer(), find.Length()) == 0;
|
||||
case Normalization::IgnoreCase:
|
||||
return wcsncasecmp(text.Buffer() + text.Length() - find.Length(), find.Buffer(), find.Length()) == 0;
|
||||
}
|
||||
return false;
|
||||
return GetDefaultLocaleImpl();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+117
-98
@@ -625,6 +625,10 @@ namespace vl
|
||||
{
|
||||
using namespace collections;
|
||||
|
||||
/***********************************************************************
|
||||
Locale Helper Functions
|
||||
***********************************************************************/
|
||||
|
||||
SYSTEMTIME DateTimeToSystemTime(const DateTime& dateTime)
|
||||
{
|
||||
SYSTEMTIME systemTime;
|
||||
@@ -691,59 +695,62 @@ namespace vl
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
Locale
|
||||
WindowsLocaleImpl
|
||||
***********************************************************************/
|
||||
|
||||
Locale Locale::Invariant()
|
||||
class WindowsLocaleImpl : public Object, public ILocaleImpl
|
||||
{
|
||||
public:
|
||||
Locale Invariant() const override
|
||||
{
|
||||
return Locale(LOCALE_NAME_INVARIANT);
|
||||
}
|
||||
|
||||
Locale Locale::SystemDefault()
|
||||
Locale SystemDefault() const override
|
||||
{
|
||||
wchar_t buffer[LOCALE_NAME_MAX_LENGTH + 1] = { 0 };
|
||||
GetSystemDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH);
|
||||
return Locale(buffer);
|
||||
}
|
||||
|
||||
Locale Locale::UserDefault()
|
||||
Locale UserDefault() const override
|
||||
{
|
||||
wchar_t buffer[LOCALE_NAME_MAX_LENGTH + 1] = { 0 };
|
||||
GetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH);
|
||||
return Locale(buffer);
|
||||
}
|
||||
|
||||
void Locale::Enumerate(collections::List<Locale>& locales)
|
||||
void Enumerate(collections::List<Locale>& locales) const override
|
||||
{
|
||||
EnumSystemLocalesEx(&Locale_EnumLocalesProcEx, LOCALE_ALL, (LPARAM)&locales, NULL);
|
||||
}
|
||||
|
||||
void Locale::GetShortDateFormats(collections::List<WString>& formats)const
|
||||
void GetShortDateFormats(const WString& localeName, collections::List<WString>& formats) const override
|
||||
{
|
||||
EnumDateFormatsExEx(&Locale_EnumDateFormatsProcExEx, localeName.Buffer(), DATE_SHORTDATE, (LPARAM)&formats);
|
||||
}
|
||||
|
||||
void Locale::GetLongDateFormats(collections::List<WString>& formats)const
|
||||
void GetLongDateFormats(const WString& localeName, collections::List<WString>& formats) const override
|
||||
{
|
||||
EnumDateFormatsExEx(&Locale_EnumDateFormatsProcExEx, localeName.Buffer(), DATE_LONGDATE, (LPARAM)&formats);
|
||||
}
|
||||
|
||||
void Locale::GetYearMonthDateFormats(collections::List<WString>& formats)const
|
||||
void GetYearMonthDateFormats(const WString& localeName, collections::List<WString>& formats) const override
|
||||
{
|
||||
EnumDateFormatsExEx(&Locale_EnumDateFormatsProcExEx, localeName.Buffer(), DATE_YEARMONTH, (LPARAM)&formats);
|
||||
}
|
||||
|
||||
void Locale::GetLongTimeFormats(collections::List<WString>& formats)const
|
||||
void GetLongTimeFormats(const WString& localeName, collections::List<WString>& formats) const override
|
||||
{
|
||||
EnumTimeFormatsEx(&EnumTimeFormatsProcEx, localeName.Buffer(), 0, (LPARAM)&formats);
|
||||
}
|
||||
|
||||
void Locale::GetShortTimeFormats(collections::List<WString>& formats)const
|
||||
void GetShortTimeFormats(const WString& localeName, collections::List<WString>& formats) const override
|
||||
{
|
||||
EnumTimeFormatsEx(&EnumTimeFormatsProcEx, localeName.Buffer(), TIME_NOSECONDS, (LPARAM)&formats);
|
||||
}
|
||||
|
||||
WString Locale::FormatDate(const WString& format, DateTime date)const
|
||||
WString FormatDate(const WString& localeName, const WString& format, DateTime date) const override
|
||||
{
|
||||
SYSTEMTIME st = DateTimeToSystemTime(date);
|
||||
int length = GetDateFormatEx(localeName.Buffer(), 0, &st, format.Buffer(), NULL, 0, NULL);
|
||||
@@ -753,7 +760,7 @@ Locale
|
||||
return &buffer[0];
|
||||
}
|
||||
|
||||
WString Locale::FormatTime(const WString& format, DateTime time)const
|
||||
WString FormatTime(const WString& localeName, const WString& format, DateTime time) const override
|
||||
{
|
||||
SYSTEMTIME st = DateTimeToSystemTime(time);
|
||||
int length = GetTimeFormatEx(localeName.Buffer(), 0, &st, format.Buffer(), NULL, 0);
|
||||
@@ -763,7 +770,7 @@ Locale
|
||||
return &buffer[0];
|
||||
}
|
||||
|
||||
WString Locale::FormatNumber(const WString& number)const
|
||||
WString FormatNumber(const WString& localeName, const WString& number) const override
|
||||
{
|
||||
int length = GetNumberFormatEx(localeName.Buffer(), 0, number.Buffer(), NULL, NULL, 0);
|
||||
if (length == 0) return L"";
|
||||
@@ -772,7 +779,7 @@ Locale
|
||||
return &buffer[0];
|
||||
}
|
||||
|
||||
WString Locale::FormatCurrency(const WString& currency)const
|
||||
WString FormatCurrency(const WString& localeName, const WString& currency) const override
|
||||
{
|
||||
int length = GetCurrencyFormatEx(localeName.Buffer(), 0, currency.Buffer(), NULL, NULL, 0);
|
||||
if (length == 0) return L"";
|
||||
@@ -781,26 +788,114 @@ Locale
|
||||
return &buffer[0];
|
||||
}
|
||||
|
||||
WString Locale::GetShortDayOfWeekName(vint dayOfWeek)const
|
||||
WString GetShortDayOfWeekName(const WString& localeName, vint dayOfWeek) const override
|
||||
{
|
||||
return FormatDate(L"ddd", DateTime::FromDateTime(2000, 1, 2 + dayOfWeek));
|
||||
return FormatDate(localeName, L"ddd", DateTime::FromDateTime(2000, 1, 2 + dayOfWeek));
|
||||
}
|
||||
|
||||
WString Locale::GetLongDayOfWeekName(vint dayOfWeek)const
|
||||
WString GetLongDayOfWeekName(const WString& localeName, vint dayOfWeek) const override
|
||||
{
|
||||
return FormatDate(L"dddd", DateTime::FromDateTime(2000, 1, 2 + dayOfWeek));
|
||||
return FormatDate(localeName, L"dddd", DateTime::FromDateTime(2000, 1, 2 + dayOfWeek));
|
||||
}
|
||||
|
||||
WString Locale::GetShortMonthName(vint month)const
|
||||
WString GetShortMonthName(const WString& localeName, vint month) const override
|
||||
{
|
||||
return FormatDate(L"MMM", DateTime::FromDateTime(2000, month, 1));
|
||||
return FormatDate(localeName, L"MMM", DateTime::FromDateTime(2000, month, 1));
|
||||
}
|
||||
|
||||
WString Locale::GetLongMonthName(vint month)const
|
||||
WString GetLongMonthName(const WString& localeName, vint month) const override
|
||||
{
|
||||
return FormatDate(L"MMMM", DateTime::FromDateTime(2000, month, 1));
|
||||
return FormatDate(localeName, L"MMMM", DateTime::FromDateTime(2000, month, 1));
|
||||
}
|
||||
|
||||
WString ToLower(const WString& localeName, const WString& str) const override
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_LOWERCASE);
|
||||
}
|
||||
|
||||
WString ToUpper(const WString& localeName, const WString& str) const override
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_UPPERCASE);
|
||||
}
|
||||
|
||||
WString ToLinguisticLower(const WString& localeName, const WString& str) const override
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_LOWERCASE | LCMAP_LINGUISTIC_CASING);
|
||||
}
|
||||
|
||||
WString ToLinguisticUpper(const WString& localeName, const WString& str) const override
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_UPPERCASE | LCMAP_LINGUISTIC_CASING);
|
||||
}
|
||||
|
||||
vint Compare(const WString& localeName, const WString& s1, const WString& s2, Locale::Normalization normalization) const override
|
||||
{
|
||||
switch (CompareStringEx(localeName.Buffer(), TranslateNormalization(normalization), s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), NULL, NULL, NULL))
|
||||
{
|
||||
case CSTR_LESS_THAN: return -1;
|
||||
case CSTR_GREATER_THAN: return 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
vint CompareOrdinal(const WString& s1, const WString& s2) const override
|
||||
{
|
||||
switch (CompareStringOrdinal(s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), FALSE))
|
||||
{
|
||||
case CSTR_LESS_THAN: return -1;
|
||||
case CSTR_GREATER_THAN: return 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
vint CompareOrdinalIgnoreCase(const WString& s1, const WString& s2) const override
|
||||
{
|
||||
switch (CompareStringOrdinal(s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), TRUE))
|
||||
{
|
||||
case CSTR_LESS_THAN: return -1;
|
||||
case CSTR_GREATER_THAN: return 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
collections::Pair<vint, vint> FindFirst(const WString& localeName, const WString& text, const WString& find, Locale::Normalization normalization) const override
|
||||
{
|
||||
int length = 0;
|
||||
int result = FindNLSStringEx(localeName.Buffer(), FIND_FROMSTART | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), &length, NULL, NULL, NULL);
|
||||
return result == -1 ? collections::Pair<vint, vint>(-1, 0) : collections::Pair<vint, vint>(result, length);
|
||||
}
|
||||
|
||||
collections::Pair<vint, vint> FindLast(const WString& localeName, const WString& text, const WString& find, Locale::Normalization normalization) const override
|
||||
{
|
||||
int length = 0;
|
||||
int result = FindNLSStringEx(localeName.Buffer(), FIND_FROMEND | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), &length, NULL, NULL, NULL);
|
||||
return result == -1 ? collections::Pair<vint, vint>(-1, 0) : collections::Pair<vint, vint>(result, length);
|
||||
}
|
||||
|
||||
bool StartsWith(const WString& localeName, const WString& text, const WString& find, Locale::Normalization normalization) const override
|
||||
{
|
||||
int result = FindNLSStringEx(localeName.Buffer(), FIND_STARTSWITH | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), NULL, NULL, NULL, NULL);
|
||||
return result != -1;
|
||||
}
|
||||
|
||||
bool EndsWith(const WString& localeName, const WString& text, const WString& find, Locale::Normalization normalization) const override
|
||||
{
|
||||
int result = FindNLSStringEx(localeName.Buffer(), FIND_ENDSWITH | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), NULL, NULL, NULL, NULL);
|
||||
return result != -1;
|
||||
}
|
||||
};
|
||||
|
||||
WindowsLocaleImpl windowsLocaleImpl;
|
||||
|
||||
ILocaleImpl* GetOSLocaleImpl()
|
||||
{
|
||||
return &windowsLocaleImpl;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
Locale (Windows Specific)
|
||||
***********************************************************************/
|
||||
|
||||
WString Locale::ToFullWidth(const WString& str)const
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_FULLWIDTH);
|
||||
@@ -821,26 +916,6 @@ Locale
|
||||
return Transform(localeName, str, LCMAP_KATAKANA);
|
||||
}
|
||||
|
||||
WString Locale::ToLower(const WString& str)const
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_LOWERCASE);
|
||||
}
|
||||
|
||||
WString Locale::ToUpper(const WString& str)const
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_UPPERCASE);
|
||||
}
|
||||
|
||||
WString Locale::ToLinguisticLower(const WString& str)const
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_LOWERCASE | LCMAP_LINGUISTIC_CASING);
|
||||
}
|
||||
|
||||
WString Locale::ToLinguisticUpper(const WString& str)const
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_UPPERCASE | LCMAP_LINGUISTIC_CASING);
|
||||
}
|
||||
|
||||
WString Locale::ToSimplifiedChinese(const WString& str)const
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_SIMPLIFIED_CHINESE);
|
||||
@@ -855,62 +930,6 @@ Locale
|
||||
{
|
||||
return Transform(localeName, str, LCMAP_TITLECASE);
|
||||
}
|
||||
|
||||
vint Locale::Compare(const WString& s1, const WString& s2, Normalization normalization)const
|
||||
{
|
||||
switch (CompareStringEx(localeName.Buffer(), TranslateNormalization(normalization), s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), NULL, NULL, NULL))
|
||||
{
|
||||
case CSTR_LESS_THAN: return -1;
|
||||
case CSTR_GREATER_THAN: return 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
vint Locale::CompareOrdinal(const WString& s1, const WString& s2)const
|
||||
{
|
||||
switch (CompareStringOrdinal(s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), FALSE))
|
||||
{
|
||||
case CSTR_LESS_THAN: return -1;
|
||||
case CSTR_GREATER_THAN: return 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
vint Locale::CompareOrdinalIgnoreCase(const WString& s1, const WString& s2)const
|
||||
{
|
||||
switch (CompareStringOrdinal(s1.Buffer(), (int)s1.Length(), s2.Buffer(), (int)s2.Length(), TRUE))
|
||||
{
|
||||
case CSTR_LESS_THAN: return -1;
|
||||
case CSTR_GREATER_THAN: return 1;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
collections::Pair<vint, vint> Locale::FindFirst(const WString& text, const WString& find, Normalization normalization)const
|
||||
{
|
||||
int length = 0;
|
||||
int result = FindNLSStringEx(localeName.Buffer(), FIND_FROMSTART | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), &length, NULL, NULL, NULL);
|
||||
return result == -1 ? Pair<vint, vint>(-1, 0) : Pair<vint, vint>(result, length);
|
||||
}
|
||||
|
||||
collections::Pair<vint, vint> Locale::FindLast(const WString& text, const WString& find, Normalization normalization)const
|
||||
{
|
||||
int length = 0;
|
||||
int result = FindNLSStringEx(localeName.Buffer(), FIND_FROMEND | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), &length, NULL, NULL, NULL);
|
||||
return result == -1 ? Pair<vint, vint>(-1, 0) : Pair<vint, vint>(result, length);
|
||||
}
|
||||
|
||||
bool Locale::StartsWith(const WString& text, const WString& find, Normalization normalization)const
|
||||
{
|
||||
int result = FindNLSStringEx(localeName.Buffer(), FIND_STARTSWITH | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), NULL, NULL, NULL, NULL);
|
||||
return result != -1;
|
||||
}
|
||||
|
||||
bool Locale::EndsWith(const WString& text, const WString& find, Normalization normalization)const
|
||||
{
|
||||
int result = FindNLSStringEx(localeName.Buffer(), FIND_ENDSWITH | TranslateNormalization(normalization), text.Buffer(), (int)text.Length(), find.Buffer(), (int)find.Length(), NULL, NULL, NULL, NULL);
|
||||
return result != -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -405,6 +405,48 @@ namespace vl
|
||||
};
|
||||
|
||||
#define INVLOC vl::Locale::Invariant()
|
||||
|
||||
/// <summary>Platform-specific locale implementation interface.</summary>
|
||||
class ILocaleImpl : public virtual Interface
|
||||
{
|
||||
public:
|
||||
virtual Locale Invariant() const = 0;
|
||||
virtual Locale SystemDefault() const = 0;
|
||||
virtual Locale UserDefault() const = 0;
|
||||
virtual void Enumerate(collections::List<Locale>& locales) const = 0;
|
||||
|
||||
virtual void GetShortDateFormats(const WString& localeName, collections::List<WString>& formats) const = 0;
|
||||
virtual void GetLongDateFormats(const WString& localeName, collections::List<WString>& formats) const = 0;
|
||||
virtual void GetYearMonthDateFormats(const WString& localeName, collections::List<WString>& formats) const = 0;
|
||||
virtual void GetLongTimeFormats(const WString& localeName, collections::List<WString>& formats) const = 0;
|
||||
virtual void GetShortTimeFormats(const WString& localeName, collections::List<WString>& formats) const = 0;
|
||||
|
||||
virtual WString FormatDate(const WString& localeName, const WString& format, DateTime date) const = 0;
|
||||
virtual WString FormatTime(const WString& localeName, const WString& format, DateTime time) const = 0;
|
||||
virtual WString FormatNumber(const WString& localeName, const WString& number) const = 0;
|
||||
virtual WString FormatCurrency(const WString& localeName, const WString& currency) const = 0;
|
||||
|
||||
virtual WString GetShortDayOfWeekName(const WString& localeName, vint dayOfWeek) const = 0;
|
||||
virtual WString GetLongDayOfWeekName(const WString& localeName, vint dayOfWeek) const = 0;
|
||||
virtual WString GetShortMonthName(const WString& localeName, vint month) const = 0;
|
||||
virtual WString GetLongMonthName(const WString& localeName, vint month) const = 0;
|
||||
|
||||
virtual WString ToLower(const WString& localeName, const WString& str) const = 0;
|
||||
virtual WString ToUpper(const WString& localeName, const WString& str) const = 0;
|
||||
virtual WString ToLinguisticLower(const WString& localeName, const WString& str) const = 0;
|
||||
virtual WString ToLinguisticUpper(const WString& localeName, const WString& str) const = 0;
|
||||
|
||||
virtual vint Compare(const WString& localeName, const WString& s1, const WString& s2, Locale::Normalization normalization) const = 0;
|
||||
virtual vint CompareOrdinal(const WString& s1, const WString& s2) const = 0;
|
||||
virtual vint CompareOrdinalIgnoreCase(const WString& s1, const WString& s2) const = 0;
|
||||
virtual collections::Pair<vint, vint> FindFirst(const WString& localeName, const WString& text, const WString& find, Locale::Normalization normalization) const = 0;
|
||||
virtual collections::Pair<vint, vint> FindLast(const WString& localeName, const WString& text, const WString& find, Locale::Normalization normalization) const = 0;
|
||||
virtual bool StartsWith(const WString& localeName, const WString& text, const WString& find, Locale::Normalization normalization) const = 0;
|
||||
virtual bool EndsWith(const WString& localeName, const WString& text, const WString& find, Locale::Normalization normalization) const = 0;
|
||||
};
|
||||
|
||||
extern ILocaleImpl* GetDefaultLocaleImpl();
|
||||
extern void InjectLocaleImpl(ILocaleImpl* impl);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3172,7 +3172,8 @@ Helper Functions
|
||||
|
||||
IWfDebuggerCallback* GetDebuggerCallback()
|
||||
{
|
||||
return GetDebuggerCallback(GetDebuggerForCurrentThread().Obj());
|
||||
auto debugger = GetDebuggerForCurrentThread();
|
||||
return GetDebuggerCallback(debugger.Obj());
|
||||
}
|
||||
|
||||
IWfDebuggerCallback* GetDebuggerCallback(WfDebugger* debugger)
|
||||
@@ -3182,12 +3183,27 @@ Helper Functions
|
||||
|
||||
Ptr<WfDebugger> GetDebuggerForCurrentThread()
|
||||
{
|
||||
return threadDebugger.HasData() ? threadDebugger.Get() : nullptr;
|
||||
if (threadDebugger.HasData())
|
||||
{
|
||||
return threadDebugger.Get();
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
void SetDebuggerForCurrentThread(Ptr<WfDebugger> debugger)
|
||||
{
|
||||
#define ERROR_PREFIX L"vl::workflow::runtime::SetDebuggerForCurrentThread(Ptr<WfDebugger>)#"
|
||||
CHECK_ERROR(debugger, ERROR_PREFIX L"This function cannot be called with nullptr.");
|
||||
threadDebugger.Set(debugger);
|
||||
#undef ERROR_PREFIX
|
||||
}
|
||||
|
||||
void ResetDebuggerForCurrentThread()
|
||||
{
|
||||
threadDebugger.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1505,6 +1505,8 @@ Debugger
|
||||
/// <summary>Set the debugger for the current thread.</summary>
|
||||
/// <param name="debugger">The debugger.</param>
|
||||
extern void SetDebuggerForCurrentThread(Ptr<WfDebugger> debugger);
|
||||
/// <summary>Reset the debugger for the current thread.</summary>
|
||||
extern void ResetDebuggerForCurrentThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user