-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathaspectratio.h
73 lines (60 loc) · 1.71 KB
/
aspectratio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef TAG_PARSER_ASPECTRATIO_H
#define TAG_PARSER_ASPECTRATIO_H
#include "./global.h"
#include <c++utilities/conversion/stringbuilder.h>
#include <cstdint>
#include <string>
namespace TagParser {
struct TAG_PARSER_EXPORT AspectRatio {
constexpr explicit AspectRatio();
explicit AspectRatio(std::uint8_t aspectRatioType);
constexpr explicit AspectRatio(std::uint16_t numerator, std::uint16_t denominator);
constexpr bool isValid() const;
constexpr bool isExtended() const;
std::string toString() const;
std::uint8_t type;
std::uint16_t numerator;
std::uint16_t denominator;
};
/*!
* \brief Constructs an invalid aspect ratio.
*/
constexpr AspectRatio::AspectRatio()
: type(0)
, numerator(0)
, denominator(0)
{
}
/*!
* \brief Constructs a aspect ratio with the specified \a numerator and \a denominator.
* \remarks Allows defining a custom aspect ratio, hence counts as "extended" (see isExtended()).
*/
constexpr AspectRatio::AspectRatio(std::uint16_t numerator, std::uint16_t denominator)
: type(0xFF)
, numerator(numerator)
, denominator(denominator)
{
}
/*!
* \brief Returns an indication whether the aspect ratio is present and valid.
*/
constexpr bool AspectRatio::isValid() const
{
return type && numerator && denominator;
}
/*!
* \brief Returns whether numerator and denominator must be read from extended SAR header.
*/
constexpr bool AspectRatio::isExtended() const
{
return type == 0xFF;
}
/*!
* \brief Returns the string representation "numerator : denominator".
*/
inline std::string AspectRatio::toString() const
{
return CppUtilities::argsToString(numerator, " : ", denominator);
}
} // namespace TagParser
#endif // TAG_PARSER_ASPECTRATIO_H