blob: ab51febaa614103cb361483c40ccc9b476aee4f5 (
plain) (
blame)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#ifndef FOURCC_HPP
#define FOURCC_HPP
#include <iosfwd>
#include <cstring>
#if defined(__POWERPC__) || defined(__APPLE__) || defined(__MERKS__)
using namespace std;
#endif
class FourCC
{
public:
FourCC();
FourCC(const char*);
explicit FourCC(unsigned long);
bool operator==(const FourCC&) const;
bool operator!=(const FourCC&) const;
bool operator==(const char*) const;
bool operator!=(const char*) const;
operator unsigned long() const;
unsigned long asLong() const;
FourCC& operator=(unsigned long);
char operator[](int) const;
std::ostream& put(std::ostream&) const;
bool printable() const;
private:
union
{
char code[4];
unsigned long codeAsLong;
};
};
inline FourCC::FourCC()
{
}
inline FourCC::FourCC(unsigned long x)
: codeAsLong(x)
{
}
inline FourCC::FourCC(const char* str)
{
memcpy(code, str, 4);
}
inline bool FourCC::operator==(const FourCC& rhs) const
{
return codeAsLong == rhs.codeAsLong;
}
inline bool FourCC::operator!=(const FourCC& rhs) const
{
return !operator==(rhs);
}
inline bool FourCC::operator==(const char* rhs) const
{
return (memcmp(code, rhs, 4) == 0);
}
inline bool FourCC::operator!=(const char* rhs) const
{
return !operator==(rhs);
}
inline FourCC::operator unsigned long() const
{
return codeAsLong;
}
inline unsigned long FourCC::asLong() const
{
return codeAsLong;
}
inline char FourCC::operator[](int i) const
{
return code[i];
}
inline FourCC& FourCC::operator=(unsigned long val)
{
codeAsLong = val;
return *this;
}
inline std::ostream& operator<<(std::ostream& os, const FourCC& rhs)
{
return rhs.put(os);
}
#endif
|