Tag Parser  9.3.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
size.h
Go to the documentation of this file.
1 #ifndef TAG_PARSER_SIZE_H
2 #define TAG_PARSER_SIZE_H
3 
4 #include "./global.h"
5 
6 #include <c++utilities/conversion/stringbuilder.h>
7 
8 #include <cstdint>
9 #include <string>
10 
11 namespace TagParser {
12 
17 public:
18  constexpr Size();
19  constexpr Size(std::uint32_t width, std::uint32_t height);
20 
21  constexpr std::uint32_t width() const;
22  constexpr std::uint32_t height() const;
23  void setWidth(std::uint32_t value);
24  void setHeight(std::uint32_t value);
25  constexpr std::uint32_t resolution() const;
26  const char *abbreviation() const;
27 
28  bool constexpr isNull() const;
29  bool constexpr operator==(const Size &other) const;
30  bool constexpr operator>=(const Size &other) const;
31  std::string toString() const;
32 
33 private:
34  std::uint32_t m_width;
35  std::uint32_t m_height;
36 };
37 
41 constexpr Size::Size()
42  : m_width(0)
43  , m_height(0)
44 {
45 }
46 
50 constexpr Size::Size(std::uint32_t width, std::uint32_t height)
51  : m_width(width)
52  , m_height(height)
53 {
54 }
55 
59 constexpr std::uint32_t Size::width() const
60 {
61  return m_width;
62 }
63 
67 constexpr std::uint32_t Size::height() const
68 {
69  return m_height;
70 }
71 
75 inline void Size::setWidth(std::uint32_t value)
76 {
77  m_width = value;
78 }
79 
83 inline void Size::setHeight(std::uint32_t value)
84 {
85  m_height = value;
86 }
87 
91 constexpr std::uint32_t Size::resolution() const
92 {
93  return m_width * m_height;
94 }
95 
99 constexpr bool Size::isNull() const
100 {
101  return (m_width == 0) && (m_height == 0);
102 }
103 
107 constexpr bool Size::operator==(const Size &other) const
108 {
109  return (m_width == other.m_width) && (m_height == other.m_height);
110 }
111 
116 constexpr bool Size::operator>=(const Size &other) const
117 {
118  return (m_width >= other.m_width) && (m_height >= other.m_height);
119 }
120 
124 inline std::string Size::toString() const
125 {
126  return CppUtilities::argsToString("width: ", m_width, ", height: ", m_height);
127 }
128 
129 } // namespace TagParser
130 
131 #endif // TAG_PARSER_SIZE_H
global.h
TagParser
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagParser::Size::setWidth
void setWidth(std::uint32_t value)
Sets the width.
Definition: size.h:75
TagParser::operator==
constexpr bool operator==(std::uint8_t lhs, FlacMetaDataBlockType type)
Definition: flacmetadata.h:18
TagParser::Size::isNull
constexpr bool isNull() const
Returns an indication whether both the width and height is 0.
Definition: size.h:99
TagParser::Size::operator>=
constexpr bool operator>=(const Size &other) const
Returns whether this instance is greather than other.
Definition: size.h:116
TagParser::Size::resolution
constexpr std::uint32_t resolution() const
Returns the resolution of the current instance (product of with and height).
Definition: size.h:91
TagParser::Size::operator==
constexpr bool operator==(const Size &other) const
Returns whether this instance equals other.
Definition: size.h:107
TagParser::Size
The Size class defines the size of a two-dimensional object using integer point precision.
Definition: size.h:16
TagParser::operator>=
constexpr bool operator>=(MatroskaElementLevel lhs, MatroskaElementLevel rhs)
Definition: matroskaid.h:439
TagParser::Size::Size
constexpr Size()
Constructs a new Size.
Definition: size.h:41
TagParser::Size::setHeight
void setHeight(std::uint32_t value)
Sets the height.
Definition: size.h:83
TagParser::Size::height
constexpr std::uint32_t height() const
Returns the height.
Definition: size.h:67
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
TagParser::Size::width
constexpr std::uint32_t width() const
Returns the width.
Definition: size.h:59
TagParser::Size::toString
std::string toString() const
Returns the string representation of the current size.
Definition: size.h:124