2018-03-06 23:09:15 +01:00
|
|
|
#ifndef TAG_PARSER_SIZE_H
|
|
|
|
#define TAG_PARSER_SIZE_H
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2016-08-29 15:43:05 +02:00
|
|
|
#include "./global.h"
|
|
|
|
|
2017-01-27 21:27:24 +01:00
|
|
|
#include <c++utilities/conversion/stringbuilder.h>
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2019-03-13 19:06:42 +01:00
|
|
|
#include <cstdint>
|
2015-04-22 19:22:01 +02:00
|
|
|
#include <string>
|
2021-01-30 21:53:06 +01:00
|
|
|
#include <string_view>
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
namespace TagParser {
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief The Size class defines the size of a two-dimensional object using integer point precision.
|
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
class TAG_PARSER_EXPORT Size {
|
2015-04-22 19:22:01 +02:00
|
|
|
public:
|
|
|
|
constexpr Size();
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr Size(std::uint32_t width, std::uint32_t height);
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t width() const;
|
|
|
|
constexpr std::uint32_t height() const;
|
|
|
|
void setWidth(std::uint32_t value);
|
|
|
|
void setHeight(std::uint32_t value);
|
|
|
|
constexpr std::uint32_t resolution() const;
|
2021-01-30 21:53:06 +01:00
|
|
|
std::string_view abbreviation() const;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
bool constexpr isNull() const;
|
2016-05-14 00:24:01 +02:00
|
|
|
bool constexpr operator==(const Size &other) const;
|
2017-08-17 18:18:10 +02:00
|
|
|
bool constexpr operator>=(const Size &other) const;
|
2015-04-22 19:22:01 +02:00
|
|
|
std::string toString() const;
|
|
|
|
|
|
|
|
private:
|
2019-03-13 19:06:42 +01:00
|
|
|
std::uint32_t m_width;
|
|
|
|
std::uint32_t m_height;
|
2015-04-22 19:22:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructs a new Size.
|
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
constexpr Size::Size()
|
|
|
|
: m_width(0)
|
|
|
|
, m_height(0)
|
|
|
|
{
|
|
|
|
}
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructs a new Size of the specified \a width and \a height.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr Size::Size(std::uint32_t width, std::uint32_t height)
|
2018-03-07 01:17:50 +01:00
|
|
|
: m_width(width)
|
|
|
|
, m_height(height)
|
|
|
|
{
|
|
|
|
}
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the width.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t Size::width() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return m_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the height.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t Size::height() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return m_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets the width.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
inline void Size::setWidth(std::uint32_t value)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
m_width = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets the height.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
inline void Size::setHeight(std::uint32_t value)
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
m_height = value;
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:18:10 +02:00
|
|
|
/*!
|
|
|
|
* \brief Returns the resolution of the current instance (product of with and height).
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t Size::resolution() const
|
2017-08-17 18:18:10 +02:00
|
|
|
{
|
|
|
|
return m_width * m_height;
|
|
|
|
}
|
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
/*!
|
|
|
|
* \brief Returns an indication whether both the width and height is 0.
|
|
|
|
*/
|
2017-08-17 18:15:03 +02:00
|
|
|
constexpr bool Size::isNull() const
|
2015-04-22 19:22:01 +02:00
|
|
|
{
|
|
|
|
return (m_width == 0) && (m_height == 0);
|
|
|
|
}
|
|
|
|
|
2016-03-13 18:17:41 +01:00
|
|
|
/*!
|
|
|
|
* \brief Returns whether this instance equals \a other.
|
|
|
|
*/
|
2017-08-17 18:15:03 +02:00
|
|
|
constexpr bool Size::operator==(const Size &other) const
|
2016-03-13 18:17:41 +01:00
|
|
|
{
|
|
|
|
return (m_width == other.m_width) && (m_height == other.m_height);
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:18:10 +02:00
|
|
|
/*!
|
2021-07-02 03:00:50 +02:00
|
|
|
* \brief Returns whether this instance is greater than \a other.
|
|
|
|
* \remarks Both dimensions must be greater. This operator does *not* take the resolution() into account.
|
2017-08-17 18:18:10 +02:00
|
|
|
*/
|
|
|
|
constexpr bool Size::operator>=(const Size &other) const
|
|
|
|
{
|
|
|
|
return (m_width >= other.m_width) && (m_height >= other.m_height);
|
|
|
|
}
|
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
/*!
|
|
|
|
* \brief Returns the string representation of the current size.
|
|
|
|
*/
|
|
|
|
inline std::string Size::toString() const
|
|
|
|
{
|
2019-06-10 22:49:11 +02:00
|
|
|
return CppUtilities::argsToString("width: ", m_width, ", height: ", m_height);
|
2015-04-22 19:22:01 +02:00
|
|
|
}
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace TagParser
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
#endif // TAG_PARSER_SIZE_H
|