Tag Parser  6.4.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 SIZE_H
2 #define SIZE_H
3 
4 #include "./global.h"
5 
6 #include <c++utilities/conversion/types.h>
7 #include <c++utilities/conversion/stringbuilder.h>
8 
9 #include <string>
10 
11 namespace Media {
12 
17 {
18 public:
19  constexpr Size();
20  constexpr Size(uint32 width, uint32 height);
21 
22  constexpr uint32 width() const;
23  constexpr uint32 height() const;
24  void setWidth(uint32 value);
25  void setHeight(uint32 value);
26  constexpr uint32 resolution() const;
27  const char *abbreviation() const;
28 
29  bool constexpr isNull() const;
30  bool constexpr operator==(const Size &other) const;
31  bool constexpr operator>=(const Size &other) const;
32  std::string toString() const;
33 
34 private:
35  uint32 m_width;
36  uint32 m_height;
37 };
38 
42 constexpr Size::Size() :
43  m_width(0),
44  m_height(0)
45 {}
46 
50 constexpr Size::Size(uint32 width, uint32 height) :
51  m_width(width),
52  m_height(height)
53 {}
54 
58 constexpr uint32 Size::width() const
59 {
60  return m_width;
61 }
62 
66 constexpr uint32 Size::height() const
67 {
68  return m_height;
69 }
70 
74 inline void Size::setWidth(uint32 value)
75 {
76  m_width = value;
77 }
78 
82 inline void Size::setHeight(uint32 value)
83 {
84  m_height = value;
85 }
86 
90 constexpr uint32 Size::resolution() const
91 {
92  return m_width * m_height;
93 }
94 
98 constexpr bool Size::isNull() const
99 {
100  return (m_width == 0) && (m_height == 0);
101 }
102 
106 constexpr bool Size::operator==(const Size &other) const
107 {
108  return (m_width == other.m_width) && (m_height == other.m_height);
109 }
110 
115 constexpr bool Size::operator>=(const Size &other) const
116 {
117  return (m_width >= other.m_width) && (m_height >= other.m_height);
118 }
119 
123 inline std::string Size::toString() const
124 {
125  return ConversionUtilities::argsToString("width: ", m_width, ", height: ", m_height);
126 }
127 
128 }
129 
130 #endif // SIZE_H
constexpr uint32 width() const
Returns the width.
Definition: size.h:58
The Size class defines the size of a two-dimensional object using integer point precision.
Definition: size.h:16
void setWidth(uint32 value)
Sets the width.
Definition: size.h:74
bool constexpr operator>=(const Size &other) const
Returns whether this instance is greather than other.
Definition: size.h:115
constexpr uint32 height() const
Returns the height.
Definition: size.h:66
bool constexpr operator==(const Size &other) const
Returns whether this instance equals other.
Definition: size.h:106
bool constexpr isNull() const
Returns an indication whether both the width and height is 0.
Definition: size.h:98
constexpr Size()
Constructs a new Size.
Definition: size.h:42
void setHeight(uint32 value)
Sets the height.
Definition: size.h:82
constexpr bool operator==(byte lhs, FlacMetaDataBlockType type)
Definition: flacmetadata.h:28
constexpr uint32 resolution() const
Returns the resolution of the current instance (product of with and height).
Definition: size.h:90
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9
std::string toString() const
Returns the string representation of the current size.
Definition: size.h:123
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.