Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,17 @@ std::cout << "Hello, my name is " << homer2.first_name() << " "
reflect-cpp also supports tabular data formats, like CSV or Parquet:

```cpp
#include <rfl/csv.hpp>
#include <rfl/parquet.hpp>

struct Person {
std::string first_name;
std::string last_name = "Simpson";
std::string town = "Springfield";
int age;
rfl::Email email;
};
Comment on lines +255 to +261
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The Person struct is missing the birthday field, but it's being used to initialize Person objects on lines 264-279. This will cause a compilation error. Based on other examples in this file and the CSV output, you should add a birthday field.

Suggested change
struct Person {
std::string first_name;
std::string last_name = "Simpson";
std::string town = "Springfield";
int age;
rfl::Email email;
};
struct Person {
std::string first_name;
std::string last_name = "Simpson";
std::string town = "Springfield";
rfl::Timestamp<"%Y-%m-%d"> birthday;
int age;
rfl::Email email;
};


const auto people =
std::vector<Person>({Person{.first_name = "Bart",
.birthday = "1987-04-19",
Expand All @@ -276,7 +285,7 @@ const auto bytestring = rfl::parquet::write(people);
This will resulting CSV will look like this:

```
"first_name";"last_name";"town";"birthday";"age";"email"
"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"
Expand Down
Loading