Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
dynamic-graph
Commits
28e306bc
Commit
28e306bc
authored
Jan 16, 2020
by
Joseph Mirabel
Committed by
olivier stasse
Jan 29, 2020
Browse files
Add Value::operator==
parent
4b49e534
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/dynamic-graph/value.h
View file @
28e306bc
...
...
@@ -72,6 +72,8 @@ public:
explicit
Value
();
// operator assignement
Value
operator
=
(
const
Value
&
value
);
// Equality operator
bool
operator
==
(
const
Value
&
other
)
const
;
/// Return the type of the value
Type
type
()
const
;
...
...
src/command/value.cpp
View file @
28e306bc
...
...
@@ -144,6 +144,25 @@ Value Value::operator=(const Value &value) {
return
*
this
;
}
bool
Value
::
operator
==
(
const
Value
&
other
)
const
{
if
(
type_
!=
other
.
type_
)
return
false
;
switch
(
type_
)
{
case
Value
::
BOOL
:
return
boolValue
()
==
other
.
boolValue
();
case
Value
::
UNSIGNED
:
return
unsignedValue
()
==
other
.
unsignedValue
();
case
Value
::
INT
:
return
intValue
()
==
other
.
intValue
();
case
Value
::
DOUBLE
:
return
doubleValue
()
==
other
.
doubleValue
();
case
Value
::
FLOAT
:
return
floatValue
()
==
other
.
floatValue
();
case
Value
::
STRING
:
return
stringValue
()
==
other
.
stringValue
();
case
Value
::
VECTOR
:
return
vectorValue
()
==
other
.
vectorValue
();
case
Value
::
MATRIX
:
return
matrixXdValue
()
==
other
.
matrixXdValue
();
case
Value
::
MATRIX4D
:
return
matrix4dValue
()
==
other
.
matrix4dValue
();
case
Value
::
VALUES
:
return
constValuesValue
()
==
other
.
constValuesValue
();
case
Value
::
NONE
:
break
;
default:
break
;
}
return
false
;
}
const
EitherType
Value
::
value
()
const
{
return
EitherType
(
*
this
);
}
Value
::
Type
Value
::
type
()
const
{
return
type_
;
}
...
...
tests/value.cpp
View file @
28e306bc
...
...
@@ -371,4 +371,5 @@ BOOST_AUTO_TEST_CASE(value_values) {
const
Values
&
vs
=
vvalues
.
constValuesValue
();
BOOST_CHECK_EQUAL
(
vs
.
size
(),
values
.
size
());
BOOST_CHECK
(
vs
==
values
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment