From f0d3e6c635743ebda184f897fd079ea14d135589 Mon Sep 17 00:00:00 2001 From: ado Date: Sun, 27 Dec 2020 20:50:45 +0100 Subject: [PATCH] add README, start writing documentation --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++ include/ss/extract.hpp | 4 ---- 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..357fe07 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# Static split parser + +A header only "csv" parser which is fast and versatile with modern c++ api. Requires compiler with c++17 support. + +Conversion for numeric values taken from [oliver schönrock](https://gist.github.com/oschonrock/67fc870ba067ebf0f369897a9d52c2dd) . +Function traits taken from [qt-creator](https://code.woboq.org/qt5/qt-creator/src/libs/utils/functiontraits.h.html) . + +Example, lets say we have a csv file containing students in the +following format : + +``` +James Bailey,65,2.5 +Brian S. Wolfe,40,11.9 +Nathan Fielder,37,Really good grades +Bill (Heath) Gates,65,3.3 +``` +``` +#include +#include + +int main() { + ss::parser p{"students.csv", ","}; + if (!p.valid()) { + exit(exit_failure); + } + + while (!p.eof()) { + auto [name, age, grade] = p.get_next(); + + if (p.valid()) { + std::cout << name << ' ' << age << ' ' << grade << std::endl; + } + } + + return 0; +} +``` + +And if we execute the program we get the following output: + +``` +$ ./program +James Bailey 65 2.5 +Brian S. Wolfe 40 11.9 +Bill (Heath) Gates 65 3.3 +``` + +... diff --git a/include/ss/extract.hpp b/include/ss/extract.hpp index 044c7c5..f994430 100644 --- a/include/ss/extract.hpp +++ b/include/ss/extract.hpp @@ -11,10 +11,6 @@ namespace ss { -// todo -// taken from -// https://gist.github.com/oschonrock/67fc870ba067ebf0f369897a9d52c2dd - //////////////// // number converters ////////////////