Skip to content

Commit

Permalink
New filters
Browse files Browse the repository at this point in the history
  • Loading branch information
wichtounet committed Nov 23, 2024
1 parent 8c704fb commit b6972d5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/views.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ inline auto filter_by_name(std::string_view name) {
return std::views::filter([name] (const auto & account) { return account.name == name; });
}

inline auto filter_by_original_name(std::string_view name) {
return std::views::filter([name] (const auto & account) { return account.original_name == name; });
}

inline auto filter_by_amount(budget::money amount) {
return std::views::filter([amount] (const auto & element) { return element.amount == amount; });
}
Expand Down Expand Up @@ -310,6 +314,16 @@ inline auto filter_by_date(budget::year year, budget::month month) {
});
}

inline auto filter_by_date(budget::date date) {
return std::views::filter([date] <typename T> (const T & element) -> bool {
if constexpr (std::is_same_v<T, budget::date>) {
return element == date;
} else {
return element.date == date;
}
});
}

inline auto between(budget::month sm, budget::month month) {
return std::views::filter([sm, month] <typename T> (const T & element) -> bool {
if constexpr (std::is_same_v<T, budget::date>) {
Expand Down

0 comments on commit b6972d5

Please sign in to comment.