mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Add '[[nodiscard]]' in more useful/ambiguous places, fix usages
This commit is contained in:
parent
eb321b3040
commit
5fee1aad7d
@ -128,13 +128,13 @@ public:
|
||||
/// {
|
||||
/// public:
|
||||
///
|
||||
/// static bool check(sf::InputStream& stream)
|
||||
/// [[nodiscard]] static bool check(sf::InputStream& stream)
|
||||
/// {
|
||||
/// // typically, read the first few header bytes and check fields that identify the format
|
||||
/// // return true if the reader can handle the format
|
||||
/// }
|
||||
///
|
||||
/// bool open(sf::InputStream& stream, Info& info) override
|
||||
/// [[nodiscard]] bool open(sf::InputStream& stream, Info& info) override
|
||||
/// {
|
||||
/// // read the sound file header and fill the sound attributes
|
||||
/// // (channel count, sample count and sample rate)
|
||||
|
@ -97,13 +97,13 @@ public:
|
||||
/// {
|
||||
/// public:
|
||||
///
|
||||
/// static bool check(const std::string& filename)
|
||||
/// [[nodiscard]] static bool check(const std::string& filename)
|
||||
/// {
|
||||
/// // typically, check the extension
|
||||
/// // return true if the writer can handle the format
|
||||
/// }
|
||||
///
|
||||
/// bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override
|
||||
/// [[nodiscard]] bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override
|
||||
/// {
|
||||
/// // open the file 'filename' for writing,
|
||||
/// // write the given sample rate and channel count to the file header
|
||||
|
@ -396,7 +396,7 @@ private:
|
||||
/// {
|
||||
/// public:
|
||||
///
|
||||
/// bool open(const std::string& location)
|
||||
/// [[nodiscard]] bool open(const std::string& location)
|
||||
/// {
|
||||
/// // Open the source and get audio settings
|
||||
/// ...
|
||||
@ -405,6 +405,7 @@ private:
|
||||
///
|
||||
/// // Initialize the stream -- important!
|
||||
/// initialize(channelCount, sampleRate);
|
||||
/// return true;
|
||||
/// }
|
||||
///
|
||||
/// private:
|
||||
@ -414,9 +415,9 @@ private:
|
||||
/// // Fill the chunk with audio data from the stream source
|
||||
/// // (note: must not be empty if you want to continue playing)
|
||||
/// data.samples = ...;
|
||||
/// data.sampleCount = ...;
|
||||
///
|
||||
/// // Return true to continue playing
|
||||
/// data.sampleCount = ...;
|
||||
/// return true;
|
||||
/// }
|
||||
///
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
/// \return True if the file is supported by this reader
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool check(InputStream& stream);
|
||||
[[nodiscard]] static bool check(InputStream& stream);
|
||||
|
||||
public:
|
||||
|
||||
@ -76,7 +76,7 @@ public:
|
||||
/// \param info Structure to fill with the attributes of the loaded sound
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(sf::InputStream& stream, Info& info) override;
|
||||
[[nodiscard]] bool open(sf::InputStream& stream, Info& info) override;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current read position to the given sample offset
|
||||
@ -102,7 +102,7 @@ public:
|
||||
/// \return Number of samples actually read (may be less than \a maxCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
[[nodiscard]] Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
/// \return True if the file is supported by this reader
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool check(InputStream& stream);
|
||||
[[nodiscard]] static bool check(InputStream& stream);
|
||||
|
||||
public:
|
||||
|
||||
@ -96,7 +96,7 @@ public:
|
||||
/// \return True if the file was successfully opened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(InputStream& stream, Info& info) override;
|
||||
[[nodiscard]] bool open(InputStream& stream, Info& info) override;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current read position to the given sample offset
|
||||
@ -122,7 +122,7 @@ public:
|
||||
/// \return Number of samples actually read (may be less than \a maxCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
[[nodiscard]] Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
/// \return True if the file is supported by this reader
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool check(InputStream& stream);
|
||||
[[nodiscard]] static bool check(InputStream& stream);
|
||||
|
||||
public:
|
||||
|
||||
@ -77,7 +77,7 @@ public:
|
||||
/// \return True if the file was successfully opened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(InputStream& stream, Info& info) override;
|
||||
[[nodiscard]] bool open(InputStream& stream, Info& info) override;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current read position to the given sample offset
|
||||
@ -103,7 +103,7 @@ public:
|
||||
/// \return Number of samples actually read (may be less than \a maxCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
[[nodiscard]] Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
/// \return True if the file is supported by this reader
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool check(InputStream& stream);
|
||||
[[nodiscard]] static bool check(InputStream& stream);
|
||||
|
||||
public:
|
||||
|
||||
@ -68,7 +68,7 @@ public:
|
||||
/// \param info Structure to fill with the attributes of the loaded sound
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(sf::InputStream& stream, Info& info) override;
|
||||
[[nodiscard]] bool open(sf::InputStream& stream, Info& info) override;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Change the current read position to the given sample offset
|
||||
@ -94,7 +94,7 @@ public:
|
||||
/// \return Number of samples actually read (may be less than \a maxCount)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
[[nodiscard]] Uint64 read(Int16* samples, Uint64 maxCount) override;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
/// \return True if the file can be written by this writer
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool check(const std::string& filename);
|
||||
[[nodiscard]] static bool check(const std::string& filename);
|
||||
|
||||
public:
|
||||
|
||||
@ -79,7 +79,7 @@ public:
|
||||
/// \return True if the file was successfully opened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
||||
[[nodiscard]] bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Write audio samples to the open file
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
/// \return True if the file can be written by this writer
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool check(const std::string& filename);
|
||||
[[nodiscard]] static bool check(const std::string& filename);
|
||||
|
||||
public:
|
||||
|
||||
@ -79,7 +79,7 @@ public:
|
||||
/// \return True if the file was successfully opened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
||||
[[nodiscard]] bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Write audio samples to the open file
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
/// \return True if the file can be written by this writer
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool check(const std::string& filename);
|
||||
[[nodiscard]] static bool check(const std::string& filename);
|
||||
|
||||
public:
|
||||
|
||||
@ -79,7 +79,7 @@ public:
|
||||
/// \return True if the file was successfully opened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
||||
[[nodiscard]] bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Write audio samples to the open file
|
||||
@ -101,7 +101,7 @@ private:
|
||||
/// \return True on success, false on error
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool writeHeader(unsigned int sampleRate, unsigned int channelCount);
|
||||
[[nodiscard]] bool writeHeader(unsigned int sampleRate, unsigned int channelCount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the file
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(unsigned int index);
|
||||
[[nodiscard]] bool open(unsigned int index);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the joystick
|
||||
@ -98,7 +98,7 @@ public:
|
||||
/// \return Joystick state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
JoystickState update();
|
||||
[[nodiscard]] JoystickState update();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(Sensor::Type sensor);
|
||||
[[nodiscard]] bool open(Sensor::Type sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the sensor
|
||||
@ -88,7 +88,7 @@ public:
|
||||
/// \return Sensor value
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f update();
|
||||
[[nodiscard]] Vector3f update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the sensor
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(unsigned int index);
|
||||
[[nodiscard]] bool open(unsigned int index);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the joystick
|
||||
@ -105,7 +105,7 @@ public:
|
||||
/// \return Joystick state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
JoystickState update();
|
||||
[[nodiscard]] JoystickState update();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(unsigned int index);
|
||||
[[nodiscard]] bool open(unsigned int index);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the joystick
|
||||
@ -106,7 +106,7 @@ public:
|
||||
/// \return Joystick state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
JoystickState update();
|
||||
[[nodiscard]] JoystickState update();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(unsigned int index);
|
||||
[[nodiscard]] bool open(unsigned int index);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the joystick
|
||||
@ -108,7 +108,7 @@ public:
|
||||
/// \return Joystick state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
JoystickState update();
|
||||
[[nodiscard]] JoystickState update();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(Sensor::Type sensor);
|
||||
[[nodiscard]] bool open(Sensor::Type sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the sensor
|
||||
@ -82,7 +82,7 @@ public:
|
||||
/// \return Sensor value
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f update();
|
||||
[[nodiscard]] Vector3f update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the sensor
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(unsigned int index);
|
||||
[[nodiscard]] bool open(unsigned int index);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the joystick
|
||||
@ -98,7 +98,7 @@ public:
|
||||
/// \return Joystick state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
JoystickState update();
|
||||
[[nodiscard]] JoystickState update();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -105,8 +105,15 @@ SensorManager::SensorManager()
|
||||
// Open the available sensors
|
||||
if (m_sensors[i].available)
|
||||
{
|
||||
m_sensors[i].sensor.open(static_cast<Sensor::Type>(i));
|
||||
m_sensors[i].sensor.setEnabled(false);
|
||||
if (m_sensors[i].sensor.open(static_cast<Sensor::Type>(i)))
|
||||
{
|
||||
m_sensors[i].sensor.setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sensors[i].available = false;
|
||||
err() << "Warning: sensor " << i << " failed to open, will not be available" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(unsigned int index);
|
||||
[[nodiscard]] bool open(unsigned int index);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the joystick
|
||||
@ -110,7 +110,7 @@ public:
|
||||
/// \return Joystick state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
JoystickState update();
|
||||
[[nodiscard]] JoystickState update();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(Sensor::Type sensor);
|
||||
[[nodiscard]] bool open(Sensor::Type sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the sensor
|
||||
@ -82,7 +82,7 @@ public:
|
||||
/// \return Sensor value
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f update();
|
||||
[[nodiscard]] Vector3f update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the sensor
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(unsigned int index);
|
||||
[[nodiscard]] bool open(unsigned int index);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the joystick
|
||||
@ -121,7 +121,7 @@ public:
|
||||
/// \return Joystick state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
JoystickState update();
|
||||
[[nodiscard]] JoystickState update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global initialization of the joystick module (DInput)
|
||||
@ -159,7 +159,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool openDInput(unsigned int index);
|
||||
[[nodiscard]] bool openDInput(unsigned int index);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the joystick (DInput)
|
||||
@ -181,7 +181,7 @@ public:
|
||||
/// \return Joystick state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
JoystickState updateDInputBuffered();
|
||||
[[nodiscard]] JoystickState updateDInputBuffered();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the joystick and get its new state (DInput, Polled)
|
||||
@ -189,7 +189,7 @@ public:
|
||||
/// \return Joystick state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
JoystickState updateDInputPolled();
|
||||
[[nodiscard]] JoystickState updateDInputPolled();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(Sensor::Type sensor);
|
||||
[[nodiscard]] bool open(Sensor::Type sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the sensor
|
||||
@ -82,7 +82,7 @@ public:
|
||||
/// \return Sensor value
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f update();
|
||||
[[nodiscard]] Vector3f update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the sensor
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(unsigned int index);
|
||||
[[nodiscard]] bool open(unsigned int index);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the joystick
|
||||
@ -103,7 +103,7 @@ public:
|
||||
/// \return Joystick state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
JoystickState update();
|
||||
[[nodiscard]] JoystickState update();
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
/// \return True on success, false on failure
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool open(Sensor::Type sensor);
|
||||
[[nodiscard]] bool open(Sensor::Type sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the sensor
|
||||
@ -87,7 +87,7 @@ public:
|
||||
/// \return Sensor value
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f update();
|
||||
[[nodiscard]] Vector3f update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the sensor
|
||||
|
Loading…
Reference in New Issue
Block a user