<commit_before>// test_himo.cpp : AvP[ṼGg |Cg`܂B
//

#include "stdafx.h"
#include "test_himo.h"

#include "../himo.h"
#include <string>

#define MAX_LOADSTRING 100

// ̃R[h W[Ɋ܂܂֐̐錾]܂:
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

	::DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)WndProc);
	return NULL;
}

// value bound to HWND of window control
static himo::BoundData<HWND, std::wstring> bound_string(_T(""));
static himo::BoundData<HWND, BOOL> bound_boolean(TRUE);
// command bound to HWND of button mainly
static himo::BoundCommand<HWND> command_append, command_toggle;
// as a facade for window message handler procedure
static himo::Binder<HWND> binder;

static void init_bindings(HWND hWnd)
{
	// Bind string value to show as window text
	bound_string.AttachWriter(
		[](HWND h, std::wstring str) {
		::SetWindowText(h, str.c_str());
	});
	bound_string.AttachReader(
		[](HWND h) {
		wchar_t buf[256];
		::GetWindowText(h, buf, sizeof(buf));
		return std::wstring(buf);
	});
	bound_string.AttachComparator(
		[](std::wstring a, std::wstring b) {
		return (a == b) ? 0 : 1;
	});
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_EDIT1));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_EDIT2));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_EDIT3));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_EDIT4));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_EDIT5));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_STATIC_1));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_STATIC_2));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_STATIC_3));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_STATIC_4));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_STATIC_5));

	// Bind booleaan value to enable bound controls
	bound_boolean.AttachReader(&::IsWindowEnabled);
	bound_boolean.AttachWriter(&::EnableWindow);
	bound_boolean.AttachComparator([](BOOL a, BOOL b) { return a ^ b; });
	binder.Bind(&bound_boolean, ::GetDlgItem(hWnd, IDC_EDIT1));
	binder.Bind(&bound_boolean, ::GetDlgItem(hWnd, IDC_EDIT2));
	binder.Bind(&bound_boolean, ::GetDlgItem(hWnd, IDC_EDIT3));
	binder.Bind(&bound_boolean, ::GetDlgItem(hWnd, IDC_EDIT4));
	binder.Bind(&bound_boolean, ::GetDlgItem(hWnd, IDC_EDIT5));

	// Asynchronous command
	command_append.AttachEnabler(
		[](HWND h, bool en) { ::EnableWindow(h, (BOOL)en); }
	);
	command_append.AttachAction(
		[](HWND) { ::Sleep(1000); bound_string = (std::wstring)bound_string + _T("1"); },
		true /* async */
	);
	binder.Bind(&command_append, ::GetDlgItem(hWnd, IDC_BUTTON1));

	// Synchronous command
	command_toggle.AttachEnabler(
		[](HWND h, bool en) { ::EnableWindow(h, (BOOL)en); }
	);
	command_toggle.AttachAction(
		[](HWND) { bound_boolean = !bound_boolean; }
	);
	binder.Bind(&command_toggle, ::GetDlgItem(hWnd, IDC_BUTTON2));

}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)<commit_msg>Relace wstring with _TCHAR string in example code<commit_after>// test_himo.cpp : AvP[ṼGg |Cg`܂B
//

#include "stdafx.h"
#include "test_himo.h"

#include "../himo.h"
#include <string>

#define MAX_LOADSTRING 100

// ̃R[h W[Ɋ܂܂֐̐錾]܂:
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

	::DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)WndProc);
	return NULL;
}

typedef std::basic_string<_TCHAR> tstring;
// value bound to HWND of window control
static himo::BoundData<HWND, tstring> bound_string(_T(""));
static himo::BoundData<HWND, BOOL> bound_boolean(TRUE);
// command bound to HWND of button mainly
static himo::BoundCommand<HWND> command_append, command_toggle;
// as a facade for window message handler procedure
static himo::Binder<HWND> binder;

static void init_bindings(HWND hWnd)
{
	// Bind string value to show as window text
	bound_string.AttachWriter(
		[](HWND h, tstring str) {
		::SetWindowText(h, str.c_str());
	});
	bound_string.AttachReader(
		[](HWND h) {
		wchar_t buf[256];
		::GetWindowText(h, buf, sizeof(buf));
		return tstring(buf);
	});
	bound_string.AttachComparator(
		[](tstring a, tstring b) {
		return (a == b) ? 0 : 1;
	});
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_EDIT1));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_EDIT2));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_EDIT3));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_EDIT4));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_EDIT5));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_STATIC_1));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_STATIC_2));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_STATIC_3));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_STATIC_4));
	binder.Bind(&bound_string, ::GetDlgItem(hWnd, IDC_STATIC_5));

	// Bind booleaan value to enable bound controls
	bound_boolean.AttachReader(&::IsWindowEnabled);
	bound_boolean.AttachWriter(&::EnableWindow);
	bound_boolean.AttachComparator([](BOOL a, BOOL b) { return a ^ b; });
	binder.Bind(&bound_boolean, ::GetDlgItem(hWnd, IDC_EDIT1));
	binder.Bind(&bound_boolean, ::GetDlgItem(hWnd, IDC_EDIT2));
	binder.Bind(&bound_boolean, ::GetDlgItem(hWnd, IDC_EDIT3));
	binder.Bind(&bound_boolean, ::GetDlgItem(hWnd, IDC_EDIT4));
	binder.Bind(&bound_boolean, ::GetDlgItem(hWnd, IDC_EDIT5));

	// lambda formula to cast standartd bool into BOOL
	auto func_enwin = [](HWND h, bool en) { ::EnableWindow(h, (BOOL)en); };
	// Asynchronous command
	command_append.AttachEnabler(func_enwin );
	command_append.AttachAction(
		[](HWND) { ::Sleep(1000); bound_string = (tstring)bound_string + _T("1"); },
		true /* async */
	);
	binder.Bind(&command_append, ::GetDlgItem(hWnd, IDC_BUTTON1));

	// Synchronous command
	command_toggle.AttachEnabler(func_enwin );
	command_toggle.AttachAction(
		[](HWND) { bound_boolean = !bound_boolean; }
	);
	binder.Bind(&command_toggle, ::GetDlgItem(hWnd, IDC_BUTTON2));

}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
{'fraction_non_alphanumeric': 0.1492982979994028, 'fraction_numerical': 0.009256494475962974, 'mean_word_length': 5.6, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6852559', 'n_tokens_mistral': 2675, 'n_tokens_neox': 2643, 'n_words': 477}