diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2010-06-25 19:16:12 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2010-06-25 19:16:12 +0200 |
commit | c4ba7c44ff03d67ff982bbab26dc48d796041e02 (patch) | |
tree | 500071e2c7fa262c2a1e054e23a25a7470d192a4 /apt-pkg/contrib/error.cc | |
parent | 98ee7cd35cf205c52b3698ee91cec76d704a3937 (diff) |
add a simple stack handling to be able to delay error handling
Diffstat (limited to 'apt-pkg/contrib/error.cc')
-rw-r--r-- | apt-pkg/contrib/error.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc index 837d9e615..8cee21c9c 100644 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@ -181,7 +181,13 @@ bool GlobalError::PopMessage(std::string &Text) { } /*}}}*/ // GlobalError::DumpErrors - Dump all of the errors/warns to cerr /*{{{*/ -void GlobalError::DumpErrors(std::ostream &out, MsgType const &trashhold) { +void GlobalError::DumpErrors(std::ostream &out, MsgType const &trashhold, + bool const &mergeStack) { + if (mergeStack == true) + for (std::list<MsgStack>::const_reverse_iterator s = Stacks.rbegin(); + s != Stacks.rend(); ++s) + Messages.insert(Messages.begin(), s->Messages.begin(), s->Messages.end()); + for (std::list<Item>::const_iterator m = Messages.begin(); m != Messages.end(); m++) if (m->Type >= trashhold) @@ -211,3 +217,27 @@ bool GlobalError::empty(MsgType const &trashhold) const { return true; } /*}}}*/ +// GlobalError::PushToStack /*{{{*/ +void GlobalError::PushToStack() { + MsgStack pack(Messages, PendingFlag); + Stacks.push_back(pack); + Discard(); +} + /*}}}*/ +// GlobalError::RevertToStack /*{{{*/ +void GlobalError::RevertToStack() { + Discard(); + MsgStack pack = Stacks.back(); + Messages = pack.Messages; + PendingFlag = pack.PendingFlag; + Stacks.pop_back(); +} + /*}}}*/ +// GlobalError::MergeWithStack /*{{{*/ +void GlobalError::MergeWithStack() { + MsgStack pack = Stacks.back(); + Messages.insert(Messages.begin(), pack.Messages.begin(), pack.Messages.end()); + PendingFlag = PendingFlag || pack.PendingFlag; + Stacks.pop_back(); +} + /*}}}*/ |