MRPT
2.0.4
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Variables
a
b
c
d
e
g
h
i
l
m
n
p
r
s
t
u
v
w
+
Typedefs
a
c
f
i
m
o
p
r
s
t
v
+
Enumerations
c
e
f
g
m
n
p
s
t
v
+
Enumerator
a
b
c
d
e
f
i
k
l
m
n
o
p
r
s
t
u
v
w
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
+
Enumerations
a
e
f
j
m
o
p
q
r
s
t
u
v
+
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
y
+
Related Functions
c
d
e
g
m
o
p
t
w
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
+
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
+
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Typedefs
b
c
d
g
i
j
l
m
p
r
s
t
v
x
Enumerations
+
Enumerator
a
d
e
i
j
n
p
r
s
u
w
+
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Examples
typemeta_TEnumType/test.cpp
/* +------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| https://www.mrpt.org/ |
| |
| Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
| See: https://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See: https://www.mrpt.org/License |
+------------------------------------------------------------------------+ */
/** \example typemeta_TEnumType/test.cpp */
//! [example]
#include <
mrpt/typemeta/TEnumType.h
>
#include <iostream>
#include <string>
// Example declaration of "enum class"
enum class
TestColors
{
Black
= 0,
Gray
= 7,
White
= 15
};
MRPT_ENUM_TYPE_BEGIN
(
TestColors
)
MRPT_FILL_ENUM_MEMBER
(
TestColors
, Black);
MRPT_FILL_ENUM_MEMBER
(
TestColors
, Gray);
MRPT_FILL_ENUM_MEMBER
(
TestColors
, White);
MRPT_ENUM_TYPE_END
()
// Example declaration of plain enum
enum
Directions
{
North
,
East
,
South
,
West
};
// Example declaration of "enum class"
MRPT_ENUM_TYPE_BEGIN
(
Directions
)
MRPT_FILL_ENUM
(
North
);
MRPT_FILL_ENUM
(
East
);
MRPT_FILL_ENUM
(
South
);
MRPT_FILL_ENUM
(
West
);
MRPT_ENUM_TYPE_END
()
void
Test_EnumType
()
{
using namespace
std
;
using namespace
mrpt::typemeta
;
cout <<
"White => "
<< (int)
TEnumType<TestColors>::name2value
(
"White"
)
<< endl;
cout <<
"Black => "
<< (int)
TEnumType<TestColors>::name2value
(
"Black"
)
<< endl;
cout <<
"Gray => "
<< (int)
TEnumType<TestColors>::name2value
(
"Gray"
)
<< endl;
cout <<
"7 <= "
<<
TEnumType<TestColors>::value2name
(
TestColors
(7))
<< endl;
}
//! [example]
int
main
(
int
argc
,
char
**
argv
)
{
try
{
Test_EnumType
();
return
0;
}
catch
(
const
std::exception& e)
{
std::cerr <<
"MRPT error: "
<< e.what() << std::endl;
return
-1;
}
}
Page generated by
Doxygen 1.8.14
for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020