From: Arjen Baart Date: Sun, 5 May 2019 06:13:45 +0000 (+0200) Subject: Code cleanup X-Git-Url: http://www.andromeda.nl/gitweb/?p=account.git;a=commitdiff_plain;h=bf570fc52a567a6715e48324da8631f86e6786a0 Code cleanup --- diff --git a/account.cpp b/account.cpp index 1ccb4f8..171caaa 100644 --- a/account.cpp +++ b/account.cpp @@ -58,7 +58,6 @@ std::ostream &operator<<(std::ostream &s, amount a) s << " "; else { - //s << form("%8d.%02d",a / 100, a % 100); s << std::setw(8) << std::setfill(' ') << a / 100 << "."; s << std::setw(2) << std::setfill('0') << a % 100; s << std::setw(0) << std::setfill(' '); @@ -91,11 +90,7 @@ std::ostream &operator<<(std::ostream &s, balance b) std::istream &operator>>(std::istream &s, Booking &b) { - char cmnt[128]; - s >> b.Bnumber >> b.booked; - //s.get(cmnt, 128); - //b.comment = cmnt; s >> b.comment; return s; @@ -103,8 +98,6 @@ std::istream &operator>>(std::istream &s, Booking &b) std::ostream &operator<<(std::ostream &s, Booking &b) { - //s << form("#%03d ",b.Bnumber) << b.booked << " " << b.comment; - //s << form("%.*s", 58 - ~b.comment, " "); s << "#" << std::setw(4) << std::setfill('0') << b.Bnumber; s << std::setw(0) << std::setfill(' '); s << " " << b.booked << " "; @@ -118,7 +111,6 @@ std::istream &operator>>(std::istream &s, Mutation &m) { int nr_blanks = 0; char c; - char buf[128]; while (s.get(c), c == ' ') nr_blanks++; @@ -127,10 +119,6 @@ std::istream &operator>>(std::istream &s, Mutation &m) s >> m.account; amount a; - //s.get(buf, 128); - - //std::istringstream amnt(buf+strlen(buf)-10); - //amnt >> a; String amnt; int p; @@ -171,7 +159,7 @@ std::ostream &operator<<(std::ostream &s, Mutation &m) std::istream &operator>>(std::istream &s, Account &acc) { - char kind, name[128]; + char kind; s >> acc.Anumber >> kind >> std::ws; if (kind == 'B') @@ -179,9 +167,6 @@ std::istream &operator>>(std::istream &s, Account &acc) else acc.kind = COST; - //s.get(name, 128); - //acc.name = name; - s >> acc.name; return s; @@ -191,7 +176,6 @@ std::ostream &operator<<(std::ostream &s, Account &acc) { s << acc.Anumber << " " << std::setw(44) << std::left << acc.name; s << std::setw(0) << std::right << " "; - //s << form("%.*s", 45 - ~acc.name, " "); s << acc.Bal; return s; @@ -516,23 +500,11 @@ void Account::Postscript_sheet(PostScript &ps) y -= 10; row++; - //s << b[B] << "|" << balance(m[M]) << " |\n"; } } /* Print the footer with the totals */ -#if 0 - s << " SALDO "; - s << " |" << -~total << " |\n"; - s << "----------------------------------------------------------------"; - s << "-----------+-------------+-----------+\n"; - total += -~total; - s << " TOTAAL "; - s << " |" << total << " |\n"; - s << "----------------------------------------------------------------"; - s << "-----------+-------------+-----------+\n"; -#endif if (page_started) { diff --git a/account_main.cpp b/account_main.cpp index b21e129..22336e6 100644 --- a/account_main.cpp +++ b/account_main.cpp @@ -18,8 +18,8 @@ void renumber_journal(char *journal_file, unsigned long renumber); void print_journal(); Ledger ledger; -Booking b[2000]; -Mutation m[6000]; +Booking b[40000]; +Mutation m[200000]; int n_m = 0, n_b = 0; @@ -31,7 +31,7 @@ static struct option long_options[] = { 0, 0, 0, 0 } }; -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i, c; Account a; @@ -94,6 +94,8 @@ main(int argc, char *argv[]) std::ofstream saldi("saldi.xml"); ledger.XML_saldi(saldi, date(b[0]), date(b[n_b-1])); + + return 0; } void read_journal(char *journal_file) diff --git a/bank.cpp b/bank.cpp index e3e693e..7e672b9 100644 --- a/bank.cpp +++ b/bank.cpp @@ -24,6 +24,11 @@ class BankTemplate regex name_match; regex description_match; + // for debugging + + String _nm; + String _dm; + String text_template; public: @@ -39,6 +44,8 @@ public: { Credit = cr; text_template = ""; + _nm = nm; + _dm = dm; } BankTemplate(const BankTemplate & b) @@ -46,6 +53,8 @@ public: { Credit = b.Credit; text_template = b.text_template; + _nm = b._nm; + _dm = b._dm; } void add_to_template(String s) @@ -60,6 +69,7 @@ public: bool BankTemplate::matches(String deb_cred, String name, String descr) { + std::cout << name << " == " << _nm << "\n" << descr << " == " << _dm << "\n"; return (deb_cred == "C") == Credit && name == name_match && descr == description_match; } @@ -147,7 +157,7 @@ static struct option long_options[] = { 0, 0, 0, 0 } }; -main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int c; @@ -179,6 +189,8 @@ main(int argc, char *argv[]) std::vector templates = read_templates("Bank.templ"); read_mutations(argv[optind], templates); + + return 0; } std::vector read_templates(const char * filename) @@ -220,7 +232,7 @@ std::vector read_templates(const char * filename) void read_mutations(const char *filename, std::vector templates) { - int i; + unsigned int i; std::ifstream in(filename); diff --git a/doc/classes.svg b/doc/classes.svg index 351fd43..59beee9 100644 --- a/doc/classes.svg +++ b/doc/classes.svg @@ -9,33 +9,33 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448819" - height="1052.3622047" + width="793.70081" + height="1122.5197" id="svg2" version="1.1" - inkscape:version="0.47 r22583" + inkscape:version="0.92.1 r15371" sodipodi:docname="classes.svg"> + d="M 0,-6.0339855 -6.0339963,0 0,6.0339703 6.0339594,0 Z" + style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-width:0.85333335pt;marker-start:none" + inkscape:connector-curvature="0" /> + id="grid3590" + originx="0" + originy="0" + spacingx="1.0666667" + spacingy="1.0666667" /> @@ -78,632 +82,724 @@ inkscape:groupmode="layer" id="layer1"> + width="149.33333" + height="181.33333" + x="42.666668" + y="589.18634" /> acc_nr + x="53.333332" + y="599.85297" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">acc_nr + style="fill:none;stroke:#000000;stroke-width:3.20000005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 42.666667,610.51966 c 149.333333,0 149.333333,0 149.333333,0 v 0" + id="path4054" + inkscape:connector-curvature="0" /> group + x="53.333332" + y="621.18634" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">group nr + x="53.333332" + y="642.51965" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">nr + style="fill:#0000ff;fill-opacity:0.2477876;stroke:#000000;stroke-width:3.20000005;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> amount + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">amount + d="m 597.33333,621.18633 c 149.33334,0 149.33334,0 149.33334,0 v 0" + style="fill:none;stroke:#000000;stroke-width:3.20000005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + inkscape:connector-curvature="0" /> value + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">value + width="149.33333" + height="202.66667" + x="341.33334" + y="599.85297" /> balance + x="352" + y="610.51965" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">balance + style="fill:none;stroke:#000000;stroke-width:3.20000005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 341.33333,621.18633 c 149.33334,0 149.33334,0 149.33334,0 v 0" + id="path2845" + inkscape:connector-curvature="0" /> Debit + x="352" + y="631.85297" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Debit Credit + x="352" + y="653.18634" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Credit + inkscape:transform-center-x="39.597971" /> + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + inkscape:connector-type="polyline" /> + style="fill:#0000ff;fill-opacity:0.2477876;stroke:#000000;stroke-width:3.20000005;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> Booking + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Booking + d="m 522.66667,311.85299 c 149.33333,0 149.33333,0 149.33333,0 v 0" + style="fill:none;stroke:#000000;stroke-width:3.20000005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + inkscape:connector-curvature="0" /> Bnumber + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Bnumber booked + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">booked comment + x="533.33331" + y="359.853" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">comment + style="fill:#0000ff;fill-opacity:0.2477876;stroke:#000000;stroke-width:3.20000005;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> Mutation + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Mutation + d="m 85.333333,322.51966 c 149.333337,0 149.333337,0 149.333337,0 v 0" + style="fill:none;stroke:#000000;stroke-width:3.20000005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + inkscape:connector-curvature="0" /> booking_nr + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">booking_nr bal + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">bal account + x="96" + y="375.853" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">account + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + inkscape:connector-type="polyline" /> + style="fill:#0000ff;fill-opacity:0.2477876;stroke:#000000;stroke-width:4.03280687;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> Account + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Account + d="m 192,845.18633 c 149.33333,0 149.33333,0 149.33333,0 v 0" + style="fill:none;stroke:#000000;stroke-width:3.20000005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + inkscape:connector-curvature="0" /> Anumber + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Anumber name + sodipodi:role="line" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">name kind + x="203.64674" + y="894.52258" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">kind Bal + x="204.40099" + y="912.62457" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Bal + sodipodi:nodetypes="cc" + inkscape:connector-curvature="0" + inkscape:connector-type="polyline" /> + width="149.33333" + height="245.33333" + x="597.33331" + y="845.18634" /> Ledger + x="608" + y="855.85297" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Ledger + style="fill:none;stroke:#000000;stroke-width:3.20000005;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 597.33333,866.51966 c 149.33334,0 149.33334,0 149.33334,0 v 0" + id="path4609" + inkscape:connector-curvature="0" /> accs + x="608" + y="877.18634" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">accs nr_accs + x="608" + y="898.51965" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">nr_accs idx + x="608" + y="919.85297" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">idx String()==istream >>ostream << + x="58.077034" + y="676.00531" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">String()==istream >>ostream << + style="fill:none;stroke:#000000;stroke-width:1.06666672px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 42.666667,653.18633 c 149.333333,0 149.333333,0 149.333333,0" + id="path4262" + inkscape:connector-curvature="0" /> + style="fill:none;stroke:#000000;stroke-width:1.06666672px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 85.333333,386.51966 c 149.333337,0 149.333337,0 149.333337,0" + id="path4264" + inkscape:connector-curvature="0" /> + style="fill:none;stroke:#000000;stroke-width:1.06666672px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 597.33333,642.51966 c 149.33334,0 149.33334,0 149.33334,0" + id="path4266" + inkscape:connector-curvature="0" /> long()++=to_string()istream >>ostream << + x="609.43176" + y="661.67462" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">long()++=to_string()istream >>ostream << + style="fill:none;stroke:#000000;stroke-width:1.06666672px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 341.33333,663.85299 H 490.66667" + id="path4282" + inkscape:connector-curvature="0" /> debit()credit()~+-+=int()ostream << + x="356.75891" + y="682.03925" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">debit()credit()~+-+=int()ostream << + style="fill:none;stroke:#000000;stroke-width:1.06666672px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 522.66667,365.18633 H 672" + id="path4313" + inkscape:connector-curvature="0" /> number()number()date()date()istream >>istream >>ostream << + x="533.25275" + y="435.1286" + id="tspan4321" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">ostream << number()acc_nr()balance()istream >>ostream << + x="104.84036" + y="404.47629" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">number()acc_nr()balance()istream >>ostream << + style="fill:none;stroke:#000000;stroke-width:1.06666672px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 192,919.85299 H 341.33333" + id="path4335" + inkscape:connector-curvature="0" /> Number()Name()==!=+= MutationBAL()balance()sheet()Postscript_sheet()istream >>ostream << + x="203.64674" + y="940.53162" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Number()Name()==!=+= MutationBAL()balance()sheet()Postscript_sheet()istream >>ostream << + style="fill:none;stroke:#000000;stroke-width:1.06666672px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 597.33333,930.51966 H 746.66667" + id="path4361" + inkscape:connector-curvature="0" /> Account [acc_nr]read()start()next()ostream <<accounts_report()saldi_report()XML_saldi() + x="610.94025" + y="952.81409" + style="font-size:12.80000019px;line-height:1.25;stroke-width:1.06666672">Account [acc_nr]read()start()next()ostream <<accounts_report()saldi_report()XML_saldi() diff --git a/makefile b/makefile index 90bf27b..09ce41c 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,6 @@ +CPPFLAGS = -Wall + OBJS = account_main.o account.o postscript.o SRCS = account_main.cpp account.cpp postscript.cpp