Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
fourcc.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
12
#include "
core/types.h
"
13
#include "
util/string.h
"
14
15
//------------------------------------------------------------------------------
16
namespace
Util
17
{
18
class
FourCC
19
{
20
public
:
22
FourCC
();
24
constexpr
FourCC
(
uint
f);
26
FourCC
(
const
String
& s);
28
bool
operator==
(
const
FourCC
& rhs)
const
;
30
bool
operator!=
(
const
FourCC
& rhs)
const
;
32
bool
operator<
(
const
FourCC
& rhs)
const
;
34
bool
operator<=
(
const
FourCC
& rhs)
const
;
36
bool
operator>
(
const
FourCC
& rhs)
const
;
38
bool
operator>=
(
const
FourCC
& rhs)
const
;
40
bool
IsValid
()
const
;
42
void
SetFromUInt
(
uint
f);
44
uint
AsUInt
()
const
;
46
void
SetFromString
(
const
String
& s);
48
String
AsString
()
const
;
50
static
String
ToString
(
const
FourCC
& f);
52
static
FourCC
FromString
(
const
String
& s);
54
uint32_t
HashCode
()
const
;
55
56
private
:
57
uint
fourCC
;
58
};
59
60
//------------------------------------------------------------------------------
63
inline
64
FourCC::FourCC
() :
65
fourCC
(0)
66
{
67
// empty
68
}
69
70
//------------------------------------------------------------------------------
73
constexpr
74
FourCC::FourCC
(
uint
f) :
75
fourCC
(f)
76
{
77
// empty
78
}
79
80
//------------------------------------------------------------------------------
83
inline
84
FourCC::FourCC
(
const
String
& s)
85
{
86
this->
SetFromString
(s);
87
}
88
89
//------------------------------------------------------------------------------
92
inline
bool
93
FourCC::operator==
(
const
FourCC
& rhs)
const
94
{
95
return
(this->
fourCC
== rhs.
fourCC
);
96
}
97
98
//------------------------------------------------------------------------------
101
inline
bool
102
FourCC::operator!=
(
const
FourCC
& rhs)
const
103
{
104
return
(this->
fourCC
!= rhs.
fourCC
);
105
}
106
107
//------------------------------------------------------------------------------
110
inline
bool
111
FourCC::operator>
(
const
FourCC
& rhs)
const
112
{
113
return
(this->
fourCC
> rhs.
fourCC
);
114
}
115
116
//------------------------------------------------------------------------------
119
inline
bool
120
FourCC::operator>=
(
const
FourCC
& rhs)
const
121
{
122
return
(this->
fourCC
>= rhs.
fourCC
);
123
}
124
125
//------------------------------------------------------------------------------
128
inline
bool
129
FourCC::operator<
(
const
FourCC
& rhs)
const
130
{
131
return
(this->
fourCC
< rhs.
fourCC
);
132
}
133
134
//------------------------------------------------------------------------------
137
inline
bool
138
FourCC::operator<=
(
const
FourCC
& rhs)
const
139
{
140
return
(this->
fourCC
<= rhs.
fourCC
);
141
}
142
143
//------------------------------------------------------------------------------
146
inline
bool
147
FourCC::IsValid
()
const
148
{
149
return
(0 != this->
fourCC
);
150
}
151
152
//------------------------------------------------------------------------------
155
inline
void
156
FourCC::SetFromUInt
(
uint
f)
157
{
158
n_assert
(0 != f);
159
this->
fourCC
= f;
160
}
161
162
//------------------------------------------------------------------------------
165
inline
uint
166
FourCC::AsUInt
()
const
167
{
168
return
this->
fourCC
;
169
}
170
171
//------------------------------------------------------------------------------
174
inline
void
175
FourCC::SetFromString
(
const
String
& s)
176
{
177
*
this
=
FromString
(s);
178
}
179
180
//------------------------------------------------------------------------------
183
inline
String
184
FourCC::AsString
()
const
185
{
186
return
ToString
(*
this
);
187
}
188
189
//------------------------------------------------------------------------------
192
inline
String
193
FourCC::ToString
(
const
FourCC
& f)
194
{
195
n_assert
(f.
IsValid
());
196
String
str(
"xzyw"
);
197
str[0] = (char) ((f.
fourCC
& 0xFF000000) >> 24);
198
str[1] = (char) ((f.
fourCC
& 0x00FF0000) >> 16);
199
str[2] = (char) ((f.
fourCC
& 0x0000FF00) >> 8);
200
str[3] = (char) (f.
fourCC
& 0x000000FF);
201
return
str;
202
}
203
204
//------------------------------------------------------------------------------
207
inline
FourCC
208
FourCC::FromString
(
const
String
& s)
209
{
210
n_assert
(s.
IsValid
() && (s.
Length
() == 4));
211
#if (__WIN32__ || __LINUX__ )
212
return
FourCC
(
uint
(s[3] | s[2]<<8 | s[1]<<16 | s[0]<<24));
213
#else
214
return
FourCC
(
uint
(s[0] | s[1]<<8 | s[2]<<16 | s[3]<<24));
215
#endif
216
}
217
218
//------------------------------------------------------------------------------
221
inline
uint32_t
222
FourCC::HashCode
()
const
223
{
224
return
this->
fourCC
;
225
}
226
227
}
// namespace Util
228
//------------------------------------------------------------------------------
Util::FourCC
A four-character-code is a quasi-human-readable 32-bit-id.
Definition
fourcc.h:19
Util::FourCC::SetFromUInt
void SetFromUInt(uint f)
set from 32-bit-value
Definition
fourcc.h:156
Util::FourCC::AsUInt
uint AsUInt() const
get as 32-bit-value
Definition
fourcc.h:166
Util::FourCC::operator!=
bool operator!=(const FourCC &rhs) const
inequality operator
Definition
fourcc.h:102
Util::FourCC::operator==
bool operator==(const FourCC &rhs) const
equality operator
Definition
fourcc.h:93
Util::FourCC::FourCC
FourCC()
default constructor
Definition
fourcc.h:64
Util::FourCC::operator<
bool operator<(const FourCC &rhs) const
less-then operator
Definition
fourcc.h:129
Util::FourCC::fourCC
uint fourCC
Definition
fourcc.h:57
Util::FourCC::AsString
String AsString() const
get as string
Definition
fourcc.h:184
Util::FourCC::operator>
bool operator>(const FourCC &rhs) const
greater-then operator
Definition
fourcc.h:111
Util::FourCC::SetFromString
void SetFromString(const String &s)
set as string
Definition
fourcc.h:175
Util::FourCC::FromString
static FourCC FromString(const String &s)
convert string to fourcc
Definition
fourcc.h:208
Util::FourCC::ToString
static String ToString(const FourCC &f)
convert fourcc to string
Definition
fourcc.h:193
Util::FourCC::IsValid
bool IsValid() const
return true if valid
Definition
fourcc.h:147
Util::FourCC::operator>=
bool operator>=(const FourCC &rhs) const
greater-or-equal operator
Definition
fourcc.h:120
Util::FourCC::HashCode
uint32_t HashCode() const
return a hashcode (just returns the fourcc)
Definition
fourcc.h:222
Util::FourCC::operator<=
bool operator<=(const FourCC &rhs) const
less-or-equal operator
Definition
fourcc.h:138
n_assert
#define n_assert(exp)
Definition
debug.h:50
Util
A quad tree designed to return regions of free 2D space.
Definition
String.cs:6
string.h
Util.String
Nebula's universal string class.
Definition
String.cs:8
Util.String::IsValid
bool IsValid() const
return true if string object is not empty
Definition
string.h:714
Util.String::Length
SizeT Length() const
return length of string
Definition
string.h:687
types.h
uint
unsigned int uint
Definition
types.h:33
code
foundation
util
fourcc.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.