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
Stack Of Tasks
dynamic-graph
Commits
b852eef0
Commit
b852eef0
authored
Jan 09, 2022
by
Olivier Stasse
Committed by
Olivier Stasse
Jan 10, 2022
Browse files
[value] Clang format.
parent
ae9ecbf5
Pipeline
#17278
passed with stage
in 5 minutes and 21 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/dynamic-graph/value.h
View file @
b852eef0
...
...
@@ -27,7 +27,7 @@ class DYNAMIC_GRAPH_DLLAPI EitherType {
~
EitherType
();
operator
bool
()
const
;
operator
unsigned
()
const
;
operator
unsigned
long
int
()
const
;
operator
unsigned
long
int
()
const
;
operator
int
()
const
;
operator
long
int
()
const
;
operator
float
()
const
;
...
...
@@ -69,7 +69,7 @@ class DYNAMIC_GRAPH_DLLAPI Value {
void
deleteValue
();
explicit
Value
(
const
bool
&
value
);
explicit
Value
(
const
unsigned
&
value
);
explicit
Value
(
const
unsigned
long
int
&
value
);
explicit
Value
(
const
unsigned
long
int
&
value
);
explicit
Value
(
const
int
&
value
);
explicit
Value
(
const
long
int
&
value
);
explicit
Value
(
const
float
&
value
);
...
...
src/command/value.cpp
View file @
b852eef0
...
...
@@ -22,7 +22,9 @@ EitherType::~EitherType() {
EitherType
::
operator
bool
()
const
{
return
value_
->
boolValue
();
}
EitherType
::
operator
unsigned
()
const
{
return
value_
->
unsignedValue
();
}
EitherType
::
operator
unsigned
long
int
()
const
{
return
value_
->
unsignedlongintValue
();
}
EitherType
::
operator
unsigned
long
int
()
const
{
return
value_
->
unsignedlongintValue
();
}
EitherType
::
operator
int
()
const
{
return
value_
->
intValue
();
}
EitherType
::
operator
long
int
()
const
{
return
value_
->
longintValue
();
}
EitherType
::
operator
float
()
const
{
return
value_
->
floatValue
();
}
...
...
@@ -36,47 +38,47 @@ EitherType::operator Values() const { return value_->valuesValue(); }
void
Value
::
deleteValue
()
{
switch
(
type_
)
{
case
BOOL
:
delete
(
const
bool
*
)
value_
;
break
;
case
UNSIGNED
:
delete
(
const
unsigned
*
)
value_
;
break
;
case
UNSIGNEDLONGINT
:
delete
(
const
unsigned
long
int
*
)
value_
;
break
;
case
INT
:
delete
(
const
int
*
)
value_
;
break
;
case
LONGINT
:
delete
(
const
long
int
*
)
value_
;
break
;
case
FLOAT
:
delete
(
const
float
*
)
value_
;
break
;
case
DOUBLE
:
delete
(
const
double
*
)
value_
;
break
;
case
STRING
:
delete
(
const
std
::
string
*
)
value_
;
break
;
case
VECTOR
:
delete
(
const
Vector
*
)
value_
;
break
;
case
MATRIX
:
delete
(
const
Eigen
::
MatrixXd
*
)
value_
;
break
;
case
MATRIX4D
:
delete
(
const
Eigen
::
Matrix4d
*
)
value_
;
break
;
case
VALUES
:
delete
(
const
Values
*
)
value_
;
break
;
case
NONE
:
/* Equivalent to void */
break
;
default:
throw
"Value::deleteValue : Undefined type"
;
;
case
BOOL
:
delete
(
const
bool
*
)
value_
;
break
;
case
UNSIGNED
:
delete
(
const
unsigned
*
)
value_
;
break
;
case
UNSIGNEDLONGINT
:
delete
(
const
unsigned
long
int
*
)
value_
;
break
;
case
INT
:
delete
(
const
int
*
)
value_
;
break
;
case
LONGINT
:
delete
(
const
long
int
*
)
value_
;
break
;
case
FLOAT
:
delete
(
const
float
*
)
value_
;
break
;
case
DOUBLE
:
delete
(
const
double
*
)
value_
;
break
;
case
STRING
:
delete
(
const
std
::
string
*
)
value_
;
break
;
case
VECTOR
:
delete
(
const
Vector
*
)
value_
;
break
;
case
MATRIX
:
delete
(
const
Eigen
::
MatrixXd
*
)
value_
;
break
;
case
MATRIX4D
:
delete
(
const
Eigen
::
Matrix4d
*
)
value_
;
break
;
case
VALUES
:
delete
(
const
Values
*
)
value_
;
break
;
case
NONE
:
/* Equivalent to void */
break
;
default:
throw
"Value::deleteValue : Undefined type"
;
;
}
}
...
...
@@ -105,47 +107,47 @@ Value::Value(const Value &value)
void
*
copyValue
(
const
Value
&
value
)
{
void
*
copy
;
switch
(
value
.
type
())
{
case
Value
::
NONE
:
copy
=
NULL
;
break
;
case
Value
::
BOOL
:
copy
=
new
bool
(
value
.
boolValue
());
break
;
case
Value
::
UNSIGNED
:
copy
=
new
unsigned
(
value
.
unsignedValue
());
break
;
case
Value
::
UNSIGNEDLONGINT
:
copy
=
new
unsigned
long
int
(
value
.
unsignedlongintValue
());
break
;
case
Value
::
INT
:
copy
=
new
int
(
value
.
intValue
());
break
;
case
Value
::
LONGINT
:
copy
=
new
long
int
(
value
.
longintValue
());
break
;
case
Value
::
FLOAT
:
copy
=
new
float
(
value
.
floatValue
());
break
;
case
Value
::
DOUBLE
:
copy
=
new
double
(
value
.
doubleValue
());
break
;
case
Value
::
STRING
:
copy
=
new
std
::
string
(
value
.
stringValue
());
break
;
case
Value
::
VECTOR
:
copy
=
new
Vector
(
value
.
vectorValue
());
break
;
case
Value
::
MATRIX
:
copy
=
new
Eigen
::
MatrixXd
(
value
.
matrixXdValue
());
break
;
case
Value
::
MATRIX4D
:
copy
=
new
Eigen
::
Matrix4d
(
value
.
matrix4dValue
());
break
;
case
Value
::
VALUES
:
copy
=
new
Values
(
value
.
valuesValue
());
break
;
default:
abort
();
case
Value
::
NONE
:
copy
=
NULL
;
break
;
case
Value
::
BOOL
:
copy
=
new
bool
(
value
.
boolValue
());
break
;
case
Value
::
UNSIGNED
:
copy
=
new
unsigned
(
value
.
unsignedValue
());
break
;
case
Value
::
UNSIGNEDLONGINT
:
copy
=
new
unsigned
long
int
(
value
.
unsignedlongintValue
());
break
;
case
Value
::
INT
:
copy
=
new
int
(
value
.
intValue
());
break
;
case
Value
::
LONGINT
:
copy
=
new
long
int
(
value
.
longintValue
());
break
;
case
Value
::
FLOAT
:
copy
=
new
float
(
value
.
floatValue
());
break
;
case
Value
::
DOUBLE
:
copy
=
new
double
(
value
.
doubleValue
());
break
;
case
Value
::
STRING
:
copy
=
new
std
::
string
(
value
.
stringValue
());
break
;
case
Value
::
VECTOR
:
copy
=
new
Vector
(
value
.
vectorValue
());
break
;
case
Value
::
MATRIX
:
copy
=
new
Eigen
::
MatrixXd
(
value
.
matrixXdValue
());
break
;
case
Value
::
MATRIX4D
:
copy
=
new
Eigen
::
Matrix4d
(
value
.
matrix4dValue
());
break
;
case
Value
::
VALUES
:
copy
=
new
Values
(
value
.
valuesValue
());
break
;
default:
abort
();
}
return
copy
;
}
...
...
@@ -165,32 +167,32 @@ Value Value::operator=(const Value &value) {
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
::
UNSIGNEDLONGINT
:
return
unsignedlongintValue
()
==
other
.
unsignedlongintValue
();
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
;
case
Value
::
BOOL
:
return
boolValue
()
==
other
.
boolValue
();
case
Value
::
UNSIGNED
:
return
unsignedValue
()
==
other
.
unsignedValue
();
case
Value
::
UNSIGNEDLONGINT
:
return
unsignedlongintValue
()
==
other
.
unsignedlongintValue
();
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
;
}
...
...
@@ -211,21 +213,18 @@ unsigned Value::unsignedValue() const {
}
unsigned
long
int
Value
::
unsignedlongintValue
()
const
{
if
(
type_
==
UNSIGNEDLONGINT
)
return
*
((
const
unsigned
long
int
*
)
value_
);
if
(
type_
==
UNSIGNEDLONGINT
)
return
*
((
const
unsigned
long
int
*
)
value_
);
throw
ExceptionAbstract
(
ExceptionAbstract
::
TOOLS
,
"value is not an unsigned long int"
);
}
long
int
Value
::
longintValue
()
const
{
if
(
type_
==
LONGINT
)
return
*
((
const
long
int
*
)
value_
);
if
(
type_
==
LONGINT
)
return
*
((
const
long
int
*
)
value_
);
throw
ExceptionAbstract
(
ExceptionAbstract
::
TOOLS
,
"value is not an long int"
);
}
int
Value
::
intValue
()
const
{
if
(
type_
==
INT
)
return
*
((
const
int
*
)
value_
);
if
(
type_
==
INT
)
return
*
((
const
int
*
)
value_
);
throw
ExceptionAbstract
(
ExceptionAbstract
::
TOOLS
,
"value is not an int"
);
}
...
...
@@ -281,88 +280,96 @@ const Values &Value::constValuesValue() const {
std
::
string
Value
::
typeName
(
Type
type
)
{
switch
(
type
)
{
case
BOOL
:
return
std
::
string
(
"bool"
);
case
UNSIGNED
:
return
std
::
string
(
"unsigned int"
);
case
UNSIGNEDLONGINT
:
return
std
::
string
(
"unsigned long int"
);
case
INT
:
return
std
::
string
(
"int"
);
case
FLOAT
:
return
std
::
string
(
"float"
);
case
DOUBLE
:
return
std
::
string
(
"double"
);
case
STRING
:
return
std
::
string
(
"string"
);
case
VECTOR
:
return
std
::
string
(
"vector"
);
case
MATRIX
:
return
std
::
string
(
"matrixXd"
);
case
MATRIX4D
:
return
std
::
string
(
"matrix4d"
);
case
VALUES
:
return
std
::
string
(
"values"
);
default:
return
std
::
string
(
"unknown"
);
case
BOOL
:
return
std
::
string
(
"bool"
);
case
UNSIGNED
:
return
std
::
string
(
"unsigned int"
);
case
UNSIGNEDLONGINT
:
return
std
::
string
(
"unsigned long int"
);
case
INT
:
return
std
::
string
(
"int"
);
case
FLOAT
:
return
std
::
string
(
"float"
);
case
DOUBLE
:
return
std
::
string
(
"double"
);
case
STRING
:
return
std
::
string
(
"string"
);
case
VECTOR
:
return
std
::
string
(
"vector"
);
case
MATRIX
:
return
std
::
string
(
"matrixXd"
);
case
MATRIX4D
:
return
std
::
string
(
"matrix4d"
);
case
VALUES
:
return
std
::
string
(
"values"
);
default:
return
std
::
string
(
"unknown"
);
}
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Value
&
value
)
{
os
<<
"Type="
<<
Value
::
typeName
(
value
.
type_
)
<<
", value="
;
switch
(
value
.
type_
)
{
case
Value
::
BOOL
:
os
<<
value
.
boolValue
();
break
;
case
Value
::
UNSIGNED
:
os
<<
value
.
unsignedValue
();
break
;
case
Value
::
UNSIGNEDLONGINT
:
os
<<
value
.
unsignedlongintValue
();
break
;
case
Value
::
INT
:
os
<<
value
.
intValue
();
break
;
case
Value
::
DOUBLE
:
os
<<
value
.
doubleValue
();
break
;
case
Value
::
FLOAT
:
os
<<
value
.
floatValue
();
break
;
case
Value
::
STRING
:
os
<<
value
.
stringValue
();
break
;
case
Value
::
VECTOR
:
os
<<
value
.
vectorValue
();
break
;
case
Value
::
MATRIX
:
os
<<
value
.
matrixXdValue
();
break
;
case
Value
::
MATRIX4D
:
os
<<
value
.
matrix4dValue
();
break
;
case
Value
::
VALUES
:
{
const
std
::
vector
<
Value
>
&
vals
=
value
.
constValuesValue
();
os
<<
"[ "
;
for
(
std
::
size_t
i
=
0
;
i
<
vals
.
size
();
++
i
)
os
<<
"Value("
<<
vals
[
i
]
<<
"), "
;
os
<<
"]"
;
}
break
;
default:
return
os
;
case
Value
::
BOOL
:
os
<<
value
.
boolValue
();
break
;
case
Value
::
UNSIGNED
:
os
<<
value
.
unsignedValue
();
break
;
case
Value
::
UNSIGNEDLONGINT
:
os
<<
value
.
unsignedlongintValue
();
break
;
case
Value
::
INT
:
os
<<
value
.
intValue
();
break
;
case
Value
::
DOUBLE
:
os
<<
value
.
doubleValue
();
break
;
case
Value
::
FLOAT
:
os
<<
value
.
floatValue
();
break
;
case
Value
::
STRING
:
os
<<
value
.
stringValue
();
break
;
case
Value
::
VECTOR
:
os
<<
value
.
vectorValue
();
break
;
case
Value
::
MATRIX
:
os
<<
value
.
matrixXdValue
();
break
;
case
Value
::
MATRIX4D
:
os
<<
value
.
matrix4dValue
();
break
;
case
Value
::
VALUES
:
{
const
std
::
vector
<
Value
>
&
vals
=
value
.
constValuesValue
();
os
<<
"[ "
;
for
(
std
::
size_t
i
=
0
;
i
<
vals
.
size
();
++
i
)
os
<<
"Value("
<<
vals
[
i
]
<<
"), "
;
os
<<
"]"
;
}
break
;
default:
return
os
;
}
return
os
;
}
template
<
>
const
Value
::
Type
ValueHelper
<
bool
>::
TypeID
=
Value
::
BOOL
;
template
<
>
const
Value
::
Type
ValueHelper
<
unsigned
>::
TypeID
=
Value
::
UNSIGNED
;
template
<
>
const
Value
::
Type
ValueHelper
<
unsigned
long
int
>::
TypeID
=
Value
::
UNSIGNEDLONGINT
;
template
<
>
const
Value
::
Type
ValueHelper
<
int
>::
TypeID
=
Value
::
INT
;
template
<
>
const
Value
::
Type
ValueHelper
<
float
>::
TypeID
=
Value
::
FLOAT
;
template
<
>
const
Value
::
Type
ValueHelper
<
double
>::
TypeID
=
Value
::
DOUBLE
;
template
<
>
const
Value
::
Type
ValueHelper
<
std
::
string
>::
TypeID
=
Value
::
STRING
;
template
<
>
const
Value
::
Type
ValueHelper
<
Vector
>::
TypeID
=
Value
::
VECTOR
;
template
<
>
const
Value
::
Type
ValueHelper
<
bool
>::
TypeID
=
Value
::
BOOL
;
template
<
>
const
Value
::
Type
ValueHelper
<
unsigned
>::
TypeID
=
Value
::
UNSIGNED
;
template
<
>
const
Value
::
Type
ValueHelper
<
unsigned
long
int
>::
TypeID
=
Value
::
UNSIGNEDLONGINT
;
template
<
>
const
Value
::
Type
ValueHelper
<
int
>::
TypeID
=
Value
::
INT
;
template
<
>
const
Value
::
Type
ValueHelper
<
float
>::
TypeID
=
Value
::
FLOAT
;
template
<
>
const
Value
::
Type
ValueHelper
<
double
>::
TypeID
=
Value
::
DOUBLE
;
template
<
>
const
Value
::
Type
ValueHelper
<
std
::
string
>::
TypeID
=
Value
::
STRING
;
template
<
>
const
Value
::
Type
ValueHelper
<
Vector
>::
TypeID
=
Value
::
VECTOR
;
template
<
>
const
Value
::
Type
ValueHelper
<
Eigen
::
MatrixXd
>::
TypeID
=
Value
::
MATRIX
;
...
...
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