| 36 |
36 |
| 37 for (auto line: std::views::split(log, "\n"sv)) { |
37 for (auto line: std::views::split(log, "\n"sv)) { |
| 38 if (line.empty()) continue; |
38 if (line.empty()) continue; |
| 39 |
39 |
| 40 // split the line by delimiter |
40 // split the line by delimiter |
| |
41 // this needs to be so crappy, because C++ split does not have a max-split parameter |
| 41 const auto line_view = std::string_view{line}; |
42 const auto line_view = std::string_view{line}; |
| 42 auto parts = std::views::split(line_view, '#') |
43 const auto pos_delim1 = line_view.find('#', 0); |
| 43 | std::views::transform([](auto r) { return std::string_view(r); }) |
44 const auto pos_delim2 = line_view.find('#', pos_delim1 + 1); |
| 44 | std::ranges::to<std::vector>(); |
45 const auto pos_delim3 = line_view.find('#', pos_delim2 + 1); |
| |
46 const auto pos_delim4 = line_view.find('#', pos_delim3 + 1); |
| 45 |
47 |
| 46 std::string_view hash_view{parts[0]}; |
48 std::string_view hash_view{line_view.substr(0, pos_delim1)}; |
| 47 std::string author{settings.map_author(parts[1])}; |
49 std::string author{line_view.substr(pos_delim1+1, pos_delim2 - pos_delim1 - 1)}; |
| 48 std::string_view date_view{parts[2]}; |
50 std::string_view date_view{line_view.substr(pos_delim2+1, pos_delim3 - pos_delim2 - 1)}; |
| 49 std::string_view tags_view{parts[3]}; |
51 std::string_view tags_view{line_view.substr(pos_delim3+1, pos_delim4 - pos_delim3 - 1)}; |
| 50 std::string_view summary_view{parts[4]}; |
52 std::string_view summary_view{line_view.substr(pos_delim4+1)}; |
| 51 |
53 |
| 52 int year = 0; |
54 int year = 0; |
| 53 unsigned int month = 0, day = 0; |
55 unsigned int month = 0, day = 0; |
| 54 auto date_parts = std::views::split(date_view, "-"sv) |
56 auto date_parts = std::views::split(date_view, "-"sv) |
| 55 | std::views::transform([](auto r) { return std::string_view(r); }) |
57 | std::views::transform([](auto r) { return std::string_view(r); }) |