diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-31 04:28:58 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-31 04:28:58 -0400 |
commit | 8276b51f5692796bfdf75dd64f709e0de1c7caaf (patch) | |
tree | 8f2a964080d2ee7e90400e158d3f89e9ffdbfa75 /mask.cc | |
parent | 208c414ab9600eca4852034a923418948629ced0 (diff) | |
download | ledger-8276b51f5692796bfdf75dd64f709e0de1c7caaf.tar.gz ledger-8276b51f5692796bfdf75dd64f709e0de1c7caaf.tar.bz2 ledger-8276b51f5692796bfdf75dd64f709e0de1c7caaf.zip |
A new binary_cache_t object has been creating to manage saving and restoring a
Ledger session from a cache file. It doesn't work at all yet, though at least
the major structures are in place now.
Diffstat (limited to 'mask.cc')
-rw-r--r-- | mask.cc | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -30,12 +30,19 @@ */ #include "mask.h" +#include "binary.h" namespace ledger { mask_t::mask_t(const string& pat) : exclude(false), expr() { TRACE_CTOR(mask_t, "const string&"); + *this = pat; +} + +mask_t& mask_t::operator=(const string& pat) +{ + exclude = false; const char * p = pat.c_str(); @@ -52,6 +59,24 @@ mask_t::mask_t(const string& pat) : exclude(false), expr() } expr.assign(p); + + return *this; +} + +void mask_t::read(const char *& data) +{ + binary::read_number(data, exclude); + + string pattern; + binary::read_string(data, pattern); + + *this = pattern; +} + +void mask_t::write(std::ostream& out) const +{ + binary::write_number(out, exclude); + binary::write_string(out, expr.str()); } } // namespace ledger |