Skip to content
GitLab
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
roscontrol_sot
Commits
e49b7304
Commit
e49b7304
authored
Jul 12, 2019
by
Joseph Mirabel
Committed by
olivier stasse
Jul 13, 2019
Browse files
Add argument --separator to roscontrol-sot-parse-log.
parent
9530a676
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/roscontrol-sot-parse-log.cc
View file @
e49b7304
#include
<fstream>
#include
<iostream>
#include
<iomanip>
#include
<cassert>
#include
<cstring>
void
usage
(
char
*
bin
)
{
std
::
cerr
<<
"Usage: "
<<
bin
<<
" [--separator sep] binary_file_name
\n
"
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
2
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" binary_file_name
\n
"
;
if
(
argc
<
2
)
{
usage
(
argv
[
0
])
;
return
1
;
}
int
iarg
=
1
;
std
::
string
sep
(
" "
);
while
(
iarg
+
1
<
argc
-
1
)
{
if
(
strcmp
(
argv
[
iarg
],
"--separator"
)
==
0
)
{
sep
=
argv
[
iarg
+
1
];
iarg
+=
2
;
}
else
{
usage
(
argv
[
0
]);
return
1
;
}
}
assert
(
iarg
==
argc
-
1
);
std
::
ifstream
in
(
argv
[
1
],
std
::
ios
::
binary
);
std
::
ifstream
in
(
argv
[
iarg
],
std
::
ios
::
binary
);
if
(
!
in
.
is_open
()
||
!
in
.
good
())
{
std
::
cerr
<<
"Couldn't open file "
<<
argv
[
1
]
<<
'\n'
;
std
::
cerr
<<
"Couldn't open file "
<<
argv
[
iarg
]
<<
'\n'
;
return
2
;
}
...
...
@@ -20,7 +39,7 @@ int main (int argc, char* argv[])
in
.
read
((
char
*
)
&
nVector
,
sizeof
(
std
::
size_t
));
in
.
read
((
char
*
)
&
vectorSize
,
sizeof
(
std
::
size_t
));
if
(
!
in
.
good
())
{
std
::
cerr
<<
"Couldn't parse file: "
<<
argv
[
1
]
<<
'\n'
;
std
::
cerr
<<
"Couldn't parse file: "
<<
argv
[
iarg
]
<<
'\n'
;
return
3
;
}
...
...
@@ -33,10 +52,10 @@ int main (int argc, char* argv[])
in
.
read
((
char
*
)
&
v
,
sizeof
(
double
));
if
(
!
in
.
good
())
{
std
::
cerr
<<
"Stopped to parse at ("
<<
i
<<
','
<<
j
<<
") of file: "
<<
argv
[
1
]
<<
'\n'
;
<<
") of file: "
<<
argv
[
iarg
]
<<
'\n'
;
return
4
;
}
std
::
cout
<<
v
<<
' '
;
std
::
cout
<<
v
<<
sep
;
}
std
::
cout
<<
'\n'
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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