From 8276b51f5692796bfdf75dd64f709e0de1c7caaf Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 31 Jul 2008 04:28:58 -0400 Subject: 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. --- mask.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'mask.cc') diff --git a/mask.cc b/mask.cc index 52074394..d3ad539e 100644 --- a/mask.cc +++ b/mask.cc @@ -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 -- cgit v1.2.3