Tag Parser  8.0.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 #include <c++utilities/conversion/types.h>
8 
9 #include <string>
10 
11 namespace TagParser {
12 
17 public:
18  constexpr Size();
19  constexpr Size(uint32 width, uint32 height);
20 
21  constexpr uint32 width() const;
22  constexpr uint32 height() const;
23  void setWidth(uint32 value);
24  void setHeight(uint32 value);
25  constexpr uint32 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  uint32 m_width;
35  uint32 m_height;
36 };
37 
41 constexpr Size::Size()
42  : m_width(0)
43  , m_height(0)
44 {
45 }
46 
50 constexpr Size::Size(uint32 width, uint32 height)
51  : m_width(width)
52  , m_height(height)
53 {
54 }
55 
59 constexpr uint32 Size::width() const
60 {
61  return m_width;
62 }
63 
67 constexpr uint32 Size::height() const
68 {
69  return m_height;
70 }
71 
75 inline void Size::setWidth(uint32 value)
76 {
77  m_width = value;
78 }
79 
83 inline void Size::setHeight(uint32 value)
84 {
85  m_height = value;
86 }
87 
91 constexpr uint32 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 ConversionUtilities::argsToString("width: ", m_width, ", height: ", m_height);
127 }
128 
129 } // namespace TagParser
130 
131 #endif // TAG_PARSER_SIZE_H
constexpr uint32 resolution() const
Returns the resolution of the current instance (product of with and height).
Definition: size.h:91
void setWidth(uint32 value)
Sets the width.
Definition: size.h:75
constexpr bool operator>=(MatroskaElementLevel lhs, MatroskaElementLevel rhs)
Definition: matroskaid.h:436
constexpr bool operator==(byte lhs, FlacMetaDataBlockType type)
Definition: flacmetadata.h:19
void setHeight(uint32 value)
Sets the height.
Definition: size.h:83
The Size class defines the size of a two-dimensional object using integer point precision.
Definition: size.h:16
constexpr uint32 height() const
Returns the height.
Definition: size.h:67
bool constexpr operator>=(const Size &other) const
Returns whether this instance is greather than other.
Definition: size.h:116
constexpr Size()
Constructs a new Size.
Definition: size.h:41
bool constexpr isNull() const
Returns an indication whether both the width and height is 0.
Definition: size.h:99
bool constexpr operator==(const Size &other) const
Returns whether this instance equals other.
Definition: size.h:107
std::string toString() const
Returns the string representation of the current size.
Definition: size.h:124
constexpr uint32 width() const
Returns the width.
Definition: size.h:59
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:9
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.