Add nodiscard annotation

This commit is contained in:
2020-12-26 00:26:11 +01:00
parent b14f691466
commit 265003ebb9
2 changed files with 8 additions and 10 deletions

View File

@@ -7,7 +7,6 @@
#pragma once
#include "Base/Utils.hpp"
#include <inttypes.h>
#include <string>
#include <sstream>
#include <iomanip>
@@ -36,7 +35,7 @@ namespace openVulkanoCpp
width(width), height(height), maxValue(maxValue), color(color), littleEndian(littleEndian)
{}
std::string ToString() const
[[nodiscard]] std::string ToString() const
{
std::stringstream headerStream;
headerStream << *this;
@@ -73,14 +72,14 @@ namespace openVulkanoCpp
return inStream;
}
constexpr size_t GetElementCount() const
[[nodiscard]] constexpr size_t GetElementCount() const
{
size_t size = height * width;
if (color) size *= 3;
return size;
}
constexpr size_t GetImageSize() const
[[nodiscard]] constexpr size_t GetImageSize() const
{
return GetElementCount() * sizeof(float);
}

View File

@@ -6,7 +6,6 @@
#pragma once
#include <inttypes.h>
#include <string>
#include <sstream>
#include <memory>
@@ -40,24 +39,24 @@ namespace openVulkanoCpp
width(width), height(height), maxValue(maxValue), color(color), ascii(ascii)
{}
constexpr std::string_view GetFileType() const
[[nodiscard]] constexpr std::string_view GetFileType() const
{
return FILE_TYPES[static_cast<uint8_t>(color) - 1];
}
constexpr std::string_view GetFileExtension() const
[[nodiscard]] constexpr std::string_view GetFileExtension() const
{
return FILE_EXT[static_cast<uint8_t>(color) - 1];
}
std::string ToString() const
[[nodiscard]] std::string ToString() const
{
std::stringstream headerStream;
headerStream << *this;
return headerStream.str();
}
constexpr uint8_t GetMagicNumberValue() const
[[nodiscard]] constexpr uint8_t GetMagicNumberValue() const
{
uint8_t value = static_cast<uint8_t>(color);
if (!ascii) value += 3;
@@ -88,7 +87,7 @@ namespace openVulkanoCpp
return inStream;
}
constexpr size_t GetImageSize() const
[[nodiscard]] constexpr size_t GetImageSize() const
{
size_t size = height * width;
if (color == ColorMode::COLOR)