Skip to content

Commit

Permalink
[api] Add nodiscard annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jul 18, 2023
1 parent e359c2b commit 4c30c3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions include/libremidi/detail/midi_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ class midi_api
midi_api& operator=(const midi_api&) = delete;
midi_api& operator=(midi_api&&) = delete;

virtual libremidi::API get_current_api() const noexcept = 0;
[[nodiscard]] virtual libremidi::API get_current_api() const noexcept = 0;
virtual void open_port(unsigned int portNumber, std::string_view portName) = 0;
virtual void open_virtual_port(std::string_view) = 0;
virtual void close_port() = 0;
virtual void set_client_name(std::string_view) = 0;
virtual void set_port_name(std::string_view) = 0;

virtual unsigned int get_port_count() const = 0;
virtual std::string get_port_name(unsigned int portNumber) const = 0;
[[nodiscard]] virtual unsigned int get_port_count() const = 0;

[[nodiscard]] virtual std::string get_port_name(unsigned int portNumber) const = 0;

bool is_port_open() const noexcept { return bool(connected_); }

Expand Down
14 changes: 7 additions & 7 deletions include/libremidi/libremidi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class LIBREMIDI_EXPORT midi_in
~midi_in();

//! Returns the MIDI API specifier for the current instance of midi_in.
libremidi::API get_current_api() const noexcept;
[[nodiscard]] libremidi::API get_current_api() const noexcept;

//! Open a MIDI input connection given by enumeration number.
/*!
Expand Down Expand Up @@ -300,21 +300,21 @@ class LIBREMIDI_EXPORT midi_in
Note that this only applies to connections made with the openPort()
function, not to virtual ports.
*/
bool is_port_open() const noexcept;
[[nodiscard]] bool is_port_open() const noexcept;

//! Return the number of available MIDI input ports.
/*!
\return This function returns the number of MIDI ports of the selected API.
*/
unsigned int get_port_count();
[[nodiscard]] unsigned int get_port_count();

//! Return a string identifier for the specified MIDI input port number.
/*!
\return The name of the port with the given Id is returned.
An empty string is returned if an invalid port specifier
is provided. User code should assume a UTF-8 encoding.
*/
std::string get_port_name(unsigned int portNumber = 0);
[[nodiscard]] std::string get_port_name(unsigned int portNumber = 0);

//! Specify whether certain MIDI message types should be queued or ignored
//! during input.
Expand Down Expand Up @@ -406,7 +406,7 @@ class LIBREMIDI_EXPORT midi_out
Note that this only applies to connections made with the openPort()
function, not to virtual ports.
*/
bool is_port_open() const noexcept;
[[nodiscard]] bool is_port_open() const noexcept;

//! Create a virtual output port, with optional name, to allow software
//! connections (OS X, JACK and ALSA only).
Expand All @@ -422,15 +422,15 @@ class LIBREMIDI_EXPORT midi_out
void open_virtual_port() { open_virtual_port("libremidi virtual port"); }

//! Return the number of available MIDI output ports.
unsigned int get_port_count();
[[nodiscard]] unsigned int get_port_count();

//! Return a string identifier for the specified MIDI port type and number.
/*!
\return The name of the port with the given Id is returned.
An empty string is returned if an invalid port specifier
is provided. User code should assume a UTF-8 encoding.
*/
std::string get_port_name(unsigned int portNumber = 0);
[[nodiscard]] std::string get_port_name(unsigned int portNumber = 0);

//! Immediately send a single message out an open MIDI output port.
/*!
Expand Down

0 comments on commit 4c30c3b

Please sign in to comment.