<commit_before>//..............................................................................
//
//  This file is part of the AXL library.
//
//  AXL is distributed under the MIT license.
//  For details see accompanying license.txt file,
//  the public copy of which is also available at:
//  http://tibbo.com/downloads/archive/axl/license.txt
//
//..............................................................................

#pragma once

#define _AXL_IO_USBTRANSFER_H

#include "axl_io_UsbPch.h"

namespace axl {
namespace io {

//..............................................................................

const char*
getUsbTransferStatusString (libusb_transfer_status status);

//..............................................................................

class FreeUsbTransfer
{
public:
	void
	operator () (libusb_transfer* h)
	{
		libusb_free_transfer (h);
	}
};

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

class UsbTransfer: public sl::Handle <libusb_transfer*, FreeUsbTransfer>
{
public:
	bool
	create (size_t isochronousPacketCount = 0);

	bool
	submit ();

	bool
	cancel ();

	void
	fillBulkTransfer (
		libusb_device_handle* deviceOpenHandle,
		uint_t endpointId,
		void* buffer,
		size_t size,
		libusb_transfer_cb_fn callback,
		void* context,
		uint_t timeout = -1
		)
	{
		ASSERT (m_h);

		libusb_fill_bulk_transfer (
			m_h,
			deviceOpenHandle,
			endpointId,
			(uchar_t*) buffer,
			size,
			callback,
			context,
			timeout != -1 ? timeout : 0
			);
	}

	void
	fillInterruptTransfer (
		libusb_device_handle* deviceOpenHandle,
		uint_t endpointId,
		void* buffer,
		size_t size,
		libusb_transfer_cb_fn callback,
		void* context,
		uint_t timeout = -1
		)
	{
		ASSERT (m_h);

		libusb_fill_interrupt_transfer (
			m_h,
			deviceOpenHandle,
			endpointId,
			(uchar_t*) buffer,
			size,
			callback,
			context,
			timeout != -1 ? timeout : 0
			);
	}
};

//..............................................................................

} // namespace io
} // namespace axl
<commit_msg>[axl_io] added support for async control transfers -- for completeness<commit_after>//..............................................................................
//
//  This file is part of the AXL library.
//
//  AXL is distributed under the MIT license.
//  For details see accompanying license.txt file,
//  the public copy of which is also available at:
//  http://tibbo.com/downloads/archive/axl/license.txt
//
//..............................................................................

#pragma once

#define _AXL_IO_USBTRANSFER_H

#include "axl_io_UsbPch.h"

namespace axl {
namespace io {

//..............................................................................

const char*
getUsbTransferStatusString (libusb_transfer_status status);

//..............................................................................

class FreeUsbTransfer
{
public:
	void
	operator () (libusb_transfer* h)
	{
		libusb_free_transfer (h);
	}
};

// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

class UsbTransfer: public sl::Handle <libusb_transfer*, FreeUsbTransfer>
{
public:
	bool
	create (size_t isochronousPacketCount = 0);

	bool
	submit ();

	bool
	cancel ();

	static
	void
	fillControlSetup (
		libusb_control_setup* setup,
		uint_t requestType, 
		uint_t requestId, 
		uint_t value, 
		uint_t index,
		size_t size
		)
	{
		libusb_fill_control_setup ((uchar_t*) setup, requestType, requestId, value, index, size);
	}

	void
	fillControlTransfer (
		libusb_device_handle* deviceOpenHandle,
		libusb_control_setup* setup,
		libusb_transfer_cb_fn callback,
		void* context,
		uint_t timeout = -1
		)
	{
		ASSERT (m_h);

		libusb_fill_control_transfer (
			m_h,
			deviceOpenHandle,
			(uchar_t*) setup,
			callback,
			context,
			timeout != -1 ? timeout : 0
			);
	}

	void
	fillBulkTransfer (
		libusb_device_handle* deviceOpenHandle,
		uint_t endpointId,
		void* buffer,
		size_t size,
		libusb_transfer_cb_fn callback,
		void* context,
		uint_t timeout = -1
		)
	{
		ASSERT (m_h);

		libusb_fill_bulk_transfer (
			m_h,
			deviceOpenHandle,
			endpointId,
			(uchar_t*) buffer,
			size,
			callback,
			context,
			timeout != -1 ? timeout : 0
			);
	}

	void
	fillInterruptTransfer (
		libusb_device_handle* deviceOpenHandle,
		uint_t endpointId,
		void* buffer,
		size_t size,
		libusb_transfer_cb_fn callback,
		void* context,
		uint_t timeout = -1
		)
	{
		ASSERT (m_h);

		libusb_fill_interrupt_transfer (
			m_h,
			deviceOpenHandle,
			endpointId,
			(uchar_t*) buffer,
			size,
			callback,
			context,
			timeout != -1 ? timeout : 0
			);
	}
};

//..............................................................................

} // namespace io
} // namespace axl

{'fraction_non_alphanumeric': 0.26244249268088665, 'fraction_numerical': 0.0035549979088247597, 'mean_word_length': 1.6150902132312739, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5610724', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1512, 'n_words': 337}