Commit e49b7304 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by olivier stasse
Browse files

Add argument --separator to roscontrol-sot-parse-log.

parent 9530a676
#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';
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment