-
Notifications
You must be signed in to change notification settings - Fork 143
Added CSV to README.md #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -68,6 +68,7 @@ The following table lists the serialization formats currently supported by refle | |||||||||||||||||||||||
| | BSON | [libbson](https://github.com/mongodb/mongo-c-driver) | >= 1.25.1 | Apache 2.0 | JSON-like binary format | | ||||||||||||||||||||||||
| | Cap'n Proto | [capnproto](https://capnproto.org) | >= 1.0.2 | MIT | Schemaful binary format | | ||||||||||||||||||||||||
| | CBOR | [jsoncons](https://github.com/danielaparker/jsoncons)| >= 0.176.0 | BSL 1.0 | JSON-like binary format | | ||||||||||||||||||||||||
| | CSV | [Apache Arrow](https://arrow.apache.org/) | >= 21.0.0 | Apache 2.0 | Tabular textual format | | ||||||||||||||||||||||||
| | flexbuffers | [flatbuffers](https://github.com/google/flatbuffers) | >= 23.5.26 | Apache 2.0 | Schema-less version of flatbuffers, binary format | | ||||||||||||||||||||||||
| | msgpack | [msgpack-c](https://github.com/msgpack/msgpack-c) | >= 6.0.0 | BSL 1.0 | JSON-like binary format | | ||||||||||||||||||||||||
| | parquet | [Apache Arrow](https://arrow.apache.org/) | >= 21.0.0 | Apache 2.0 | Tabular binary format | | ||||||||||||||||||||||||
|
|
@@ -245,7 +246,7 @@ std::cout << "Hello, my name is " << homer2.first_name() << " " | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### Tabular data | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| reflect-cpp also supports tabular data formats, like Parquet: | ||||||||||||||||||||||||
| reflect-cpp also supports tabular data formats, like CSV or Parquet: | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ```cpp | ||||||||||||||||||||||||
| #include <rfl/parquet.hpp> | ||||||||||||||||||||||||
|
|
@@ -268,9 +269,20 @@ const auto people = | |||||||||||||||||||||||
| .age = 45, | ||||||||||||||||||||||||
| .email = "homer@simpson.com"}}); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const auto csv_string = rfl::csv::write(people); | ||||||||||||||||||||||||
| const auto bytestring = rfl::parquet::write(people); | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| This will resulting CSV will look like this: | ||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
| "first_name";"last_name";"town";"birthday";"age";"email" | ||||||||||||||||||||||||
| "Bart";"Simpson";"Springfield";1987-04-19;10;"bart@simpson.com" | ||||||||||||||||||||||||
| "Lisa";"Simpson";"Springfield";1987-04-19;8;"lisa@simpson.com" | ||||||||||||||||||||||||
| "Maggie";"Simpson";"Springfield";1987-04-19;0;"maggie@simpson.com" | ||||||||||||||||||||||||
| "Homer";"Simpson";"Springfield";1987-04-19;45;"homer@simpson.com" | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
|
Comment on lines
+279
to
+284
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CSV output shown here uses semicolons (
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### Error messages | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| reflect-cpp returns clear and comprehensive error messages: | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This CSV serialization example has some inconsistencies with the surrounding documentation that could be confusing for users:
#include <rfl/csv.hpp>.Personstruct being serialized here is implicitly the one from the "More Comprehensive Example". That struct is not compatible with the CSV output shown below because it usesrfl::Renameto producecamelCasenames (e.g.,firstName) and contains astd::vector<Person> childrenfield, which is not supported in tabular formats.To improve clarity, it would be best to define a new, flat
Personstruct for this tabular data section that is compatible with CSV and matches the generated output.