teditor  1.8.0@@fee5e94
Terminal based editor written in C++
ledger/parser.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "objects.h"
4 #include "core/time_utils.h"
5 
6 namespace teditor {
7 namespace ledger {
8 
10 class Parser {
11 public:
12  Parser(const std::string& f);
13 
14  void reload();
15  const Transactions& transactions() const { return trans; }
16  const Accounts& accounts() const { return accts; }
17 
26  Accounts topAccounts(bool sort = true) const;
27 
33  Accounts allAccounts(bool sort = true) const;
34 
36  void minmaxDates(TimePoint& min, TimePoint& max) const;
37 
38 private:
39  std::string file;
40  Transactions trans;
41  Accounts accts;
42 
43  void parse(const std::string& f);
44 };
45 
46 } // end namespace ledger
47 } // end namespace teditor
teditor::ledger::Parser::topAccounts
Accounts topAccounts(bool sort=true) const
Computes balances of only the top-level accounts. Top-level account is the account name that preceeds...
Definition: ledger/parser.cpp:134
teditor::ledger::Parser::accounts
const Accounts & accounts() const
Definition: ledger/parser.h:16
teditor::ledger::Parser::transactions
const Transactions & transactions() const
Definition: ledger/parser.h:15
teditor::ledger::Parser::minmaxDates
void minmaxDates(TimePoint &min, TimePoint &max) const
Definition: ledger/parser.cpp:177
teditor::ledger::Parser::reload
void reload()
Definition: ledger/parser.cpp:128
objects.h
teditor::TimePoint
std::chrono::system_clock::time_point TimePoint
Definition: time_utils.h:7
teditor::ledger::Transactions
std::vector< Transaction > Transactions
Definition: ledger/objects.h:110
teditor::ledger::Accounts
Definition: ledger/objects.h:52
time_utils.h
teditor::ledger::Parser
Definition: ledger/parser.h:10
teditor::ledger::Parser::allAccounts
Accounts allAccounts(bool sort=true) const
Computes balances of the top-level accounts as well as all accounts.
Definition: ledger/parser.cpp:149
teditor
Definition: any.hpp:10
teditor::ledger::Parser::Parser
Parser(const std::string &f)
Definition: ledger/parser.cpp:42