working on win32 uwp! and libremidi update
This commit is contained in:
+46
-71
@@ -1,82 +1,37 @@
|
||||
#pragma once
|
||||
#include <libremidi/config.hpp>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#include <libremidi/system_error2.hpp>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
#include <string_view>
|
||||
#include <version>
|
||||
|
||||
#if __has_include(<source_location>) && (__cpp_lib_source_location >= 201907L)
|
||||
#include <source_location>
|
||||
namespace libremidi { using source_location = std::source_location; }
|
||||
#else
|
||||
namespace libremidi {
|
||||
struct source_location {
|
||||
static source_location current() noexcept { return {}; }
|
||||
int line() const noexcept { return -1; }
|
||||
int offset() const noexcept { return -1; }
|
||||
const char* function_name() const noexcept { return "(unknown)"; }
|
||||
const char* file_name() const noexcept { return "(unknown)"; }
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace libremidi
|
||||
{
|
||||
//! Defines various error types.
|
||||
enum midi_error
|
||||
inline auto from_errc(int ret) noexcept
|
||||
{
|
||||
WARNING, /*!< A non-critical error. */
|
||||
UNSPECIFIED, /*!< The default, unspecified error type. */
|
||||
NO_DEVICES_FOUND, /*!< No devices found on system. */
|
||||
INVALID_DEVICE, /*!< An invalid device ID was specified. */
|
||||
MEMORY_ERROR, /*!< An error occured during memory allocation. */
|
||||
INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
|
||||
INVALID_USE, /*!< The function was called incorrectly. */
|
||||
DRIVER_ERROR, /*!< A system driver error occured. */
|
||||
SYSTEM_ERROR, /*!< A system error occured. */
|
||||
THREAD_ERROR /*!< A thread error occured. */
|
||||
};
|
||||
|
||||
//! Base exception class for MIDI problems
|
||||
struct LIBREMIDI_EXPORT midi_exception : public std::runtime_error
|
||||
{
|
||||
using std::runtime_error::runtime_error;
|
||||
~midi_exception() override;
|
||||
};
|
||||
|
||||
struct LIBREMIDI_EXPORT no_devices_found_error final : public midi_exception
|
||||
{
|
||||
static constexpr auto code = midi_error::NO_DEVICES_FOUND;
|
||||
using midi_exception::midi_exception;
|
||||
~no_devices_found_error() override;
|
||||
};
|
||||
struct LIBREMIDI_EXPORT invalid_device_error final : public midi_exception
|
||||
{
|
||||
static constexpr auto code = midi_error::INVALID_DEVICE;
|
||||
using midi_exception::midi_exception;
|
||||
~invalid_device_error() override;
|
||||
};
|
||||
struct LIBREMIDI_EXPORT memory_error final : public midi_exception
|
||||
{
|
||||
static constexpr auto code = midi_error::MEMORY_ERROR;
|
||||
using midi_exception::midi_exception;
|
||||
~memory_error() override;
|
||||
};
|
||||
struct LIBREMIDI_EXPORT invalid_parameter_error final : public midi_exception
|
||||
{
|
||||
static constexpr auto code = midi_error::INVALID_PARAMETER;
|
||||
using midi_exception::midi_exception;
|
||||
~invalid_parameter_error() override;
|
||||
};
|
||||
struct LIBREMIDI_EXPORT invalid_use_error final : public midi_exception
|
||||
{
|
||||
static constexpr auto code = midi_error::INVALID_USE;
|
||||
using midi_exception::midi_exception;
|
||||
~invalid_use_error() override;
|
||||
};
|
||||
struct LIBREMIDI_EXPORT driver_error final : public midi_exception
|
||||
{
|
||||
static constexpr auto code = midi_error::DRIVER_ERROR;
|
||||
using midi_exception::midi_exception;
|
||||
~driver_error() override;
|
||||
};
|
||||
struct LIBREMIDI_EXPORT system_error final : public midi_exception
|
||||
{
|
||||
static constexpr auto code = midi_error::SYSTEM_ERROR;
|
||||
using midi_exception::midi_exception;
|
||||
~system_error() override;
|
||||
};
|
||||
struct LIBREMIDI_EXPORT thread_error final : public midi_exception
|
||||
{
|
||||
static constexpr auto code = midi_error::THREAD_ERROR;
|
||||
using midi_exception::midi_exception;
|
||||
~thread_error() override;
|
||||
};
|
||||
return static_cast<std::errc>(-ret);
|
||||
}
|
||||
|
||||
/*! \brief Error callback function
|
||||
\param type Type of error.
|
||||
@@ -85,5 +40,25 @@ struct LIBREMIDI_EXPORT thread_error final : public midi_exception
|
||||
Note that class behaviour is undefined after a critical error (not
|
||||
a warning) is reported.
|
||||
*/
|
||||
using midi_error_callback = std::function<void(midi_error type, std::string_view errorText)>;
|
||||
using midi_error_callback = std::function<void(std::string_view errorText, const source_location&)>;
|
||||
using midi_warning_callback = std::function<void(std::string_view errorText, const source_location&)>;
|
||||
}
|
||||
|
||||
#if !defined(LIBREMIDI_LOG)
|
||||
#if !defined(__LIBREMIDI_DEBUG__)
|
||||
#define LIBREMIDI_LOG(...) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#else
|
||||
#include <iostream>
|
||||
#define LIBREMIDI_LOG(...) \
|
||||
do \
|
||||
{ \
|
||||
[](auto&&... args) { \
|
||||
(std::cerr << ... << args); \
|
||||
std::cerr << std::endl; \
|
||||
}(__VA_ARGS__); \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user