libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
fourcc.h
Go to the documentation of this file.
1
8#pragma once
9#include <cstdint>
10#include <string>
12#include <promeki/core/list.h>
13
15
25class FourCC {
26 public:
34 constexpr FourCC(char c0, char c1, char c2, char c3)
35 : d((static_cast<uint32_t>(c0) << 24) |
36 (static_cast<uint32_t>(c1) << 16) |
37 (static_cast<uint32_t>(c2) << 8) |
39
45 template <size_t N> constexpr FourCC(const char (&str)[N])
46 : FourCC(str[0], str[1], str[2], str[3]) {
47 static_assert(N == 5, "FourCC string must have exactly 4 characters");
48 }
49
54 constexpr uint32_t value() const { return d; }
55
57 friend constexpr bool operator==(const FourCC &a, const FourCC &b) {
58 return a.d == b.d;
59 }
60
62 friend constexpr bool operator!=(const FourCC &a, const FourCC &b) {
63 return a.d != b.d;
64 }
65
67 friend constexpr bool operator<(const FourCC &a, const FourCC &b) {
68 return a.d < b.d;
69 }
70
72 friend constexpr bool operator>(const FourCC &a, const FourCC &b) {
73 return a.d > b.d;
74 }
75
77 friend constexpr bool operator<=(const FourCC &a, const FourCC &b) {
78 return a.d <= b.d;
79 }
80
82 friend constexpr bool operator>=(const FourCC &a, const FourCC &b) {
83 return a.d >= b.d;
84 }
85
86 private:
87 uint32_t d;
88};
89
92
94
A four-character code (FourCC) identifier.
Definition fourcc.h:25
friend constexpr bool operator<=(const FourCC &a, const FourCC &b)
Less-than-or-equal comparison by numeric value.
Definition fourcc.h:77
constexpr FourCC(char c0, char c1, char c2, char c3)
Constructs a FourCC from four individual characters.
Definition fourcc.h:34
constexpr uint32_t value() const
Returns the packed 32-bit integer value.
Definition fourcc.h:54
friend constexpr bool operator>=(const FourCC &a, const FourCC &b)
Greater-than-or-equal comparison by numeric value.
Definition fourcc.h:82
constexpr FourCC(const char(&str)[N])
Constructs a FourCC from a string literal.
Definition fourcc.h:45
friend constexpr bool operator!=(const FourCC &a, const FourCC &b)
Returns true if the FourCC values are not equal.
Definition fourcc.h:62
friend constexpr bool operator==(const FourCC &a, const FourCC &b)
Returns true if both FourCC values are equal.
Definition fourcc.h:57
friend constexpr bool operator<(const FourCC &a, const FourCC &b)
Less-than comparison by numeric value.
Definition fourcc.h:67
friend constexpr bool operator>(const FourCC &a, const FourCC &b)
Greater-than comparison by numeric value.
Definition fourcc.h:72
Dynamic array container wrapping std::vector.
Definition list.h:40
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19