mirror of
https://github.com/red0124/ssp.git
synced 2025-01-23 04:55:20 +01:00
add README, start writing documentation
This commit is contained in:
parent
918023496e
commit
f0d3e6c635
48
README.md
Normal file
48
README.md
Normal file
@ -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 <name,age,grade>:
|
||||
|
||||
```
|
||||
James Bailey,65,2.5
|
||||
Brian S. Wolfe,40,11.9
|
||||
Nathan Fielder,37,Really good grades
|
||||
Bill (Heath) Gates,65,3.3
|
||||
```
|
||||
```
|
||||
#include <iostream>
|
||||
#include <ss/parser.hpp>
|
||||
|
||||
int main() {
|
||||
ss::parser p{"students.csv", ","};
|
||||
if (!p.valid()) {
|
||||
exit(exit_failure);
|
||||
}
|
||||
|
||||
while (!p.eof()) {
|
||||
auto [name, age, grade] = p.get_next<std::string, int, double>();
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
...
|
@ -11,10 +11,6 @@
|
||||
|
||||
namespace ss {
|
||||
|
||||
// todo
|
||||
// taken from
|
||||
// https://gist.github.com/oschonrock/67fc870ba067ebf0f369897a9d52c2dd
|
||||
|
||||
////////////////
|
||||
// number converters
|
||||
////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user