summaryrefslogtreecommitdiff
path: root/trace_parser.hpp
diff options
context:
space:
mode:
authorJosé Fonseca <jose.r.fonseca@gmail.com>2011-09-11 16:53:34 +0100
committerJosé Fonseca <jose.r.fonseca@gmail.com>2011-09-11 16:53:34 +0100
commit61e61f716a77595277dad9ffca2b5cfb541ab1ab (patch)
tree2058c8f0e8628367ab729aaf3d9da881562c354a /trace_parser.hpp
parent90c80a024172cc3b957ba38fca3253eb14a4ea08 (diff)
Encapsulate on parser state in structure.
So that parser users don't need to know what needs and needs not to be saved/restored.
Diffstat (limited to 'trace_parser.hpp')
-rw-r--r--trace_parser.hpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/trace_parser.hpp b/trace_parser.hpp
index 962c323..d76ffb4 100644
--- a/trace_parser.hpp
+++ b/trace_parser.hpp
@@ -37,6 +37,14 @@
namespace Trace {
+
+struct ParseBookmark
+{
+ File::Offset offset;
+ unsigned next_call_no;
+};
+
+
class Parser
{
protected:
@@ -92,24 +100,14 @@ public:
return file->supportsOffsets();
}
- File::Offset currentOffset()
- {
- return file->currentOffset();
- }
-
- void setCurrentOffset(const File::Offset &offset)
- {
- file->setCurrentOffset(offset);
+ void getBookmark(ParseBookmark &bookmark) {
+ bookmark.offset = file->currentOffset();
+ bookmark.next_call_no = next_call_no;
}
- unsigned currentCallNumber() const
- {
- return next_call_no;
- }
-
- void setCurrentCallNumber(unsigned num)
- {
- next_call_no = num;
+ void setBookmark(const ParseBookmark &bookmark) {
+ file->setCurrentOffset(bookmark.offset);
+ next_call_no = bookmark.next_call_no;
}
int percentRead()