A simple parser that replaces the boost spirit parser. More...
#include <SignatureParser.h>
Public Types | |
using | Row = std::vector< double > |
using | Table = std::vector< Row > |
Static Public Member Functions | |
static std::optional< Table > | Parse (const std::string &str) |
A simple parser that replaces the boost spirit parser.
It is meant to parse strings like "1/1 2/3 1/4". Every word of the form "a/b/c/..." is parsed as a row, and the rows are stored in a table.
A Row
is a vector of doubles, and a Table
is a vector of rows.
Examples: the parser is able to parse the following strings: "1/1 2/3 1/4": {{1,1},{2,3},{1,4}} "1/1 2/3 1/4 1/1 2/3 1/4" : {{1,1},{2,3},{1,4},{1,1},{2,3},{1,4}} "1/2/3 2/3/4 1/2/3 2/3/4 1/2/3 2/3/4 1/2/3 2/3/4 1/2/3" : {{1,2,3},{2,3,4},{1,2,3},{2,3,4},{1,2,3},{2,3,4},{1,2,3},{2,3,4},{1,2,3}}
If the string has un-parsable elements the parser will fail with nullopt: "1/2 sdf" : nullopt !
It also fails if the string is empty: "": nullopt !
Also fails if the rows are not of the same size.
Definition at line 50 of file SignatureParser.h.
using gtsam::SignatureParser::Row = std::vector<double> |
Definition at line 51 of file SignatureParser.h.
using gtsam::SignatureParser::Table = std::vector<Row> |
Definition at line 52 of file SignatureParser.h.
|
static |
Definition at line 77 of file SignatureParser.cpp.