]> git.cworth.org Git - apitrace/blobdiff - trace_file.hpp
Implement scanning/skipping of fragments of the trace
[apitrace] / trace_file.hpp
index 2129d1e388f197b9e2cd7e844ddcf836b3e4cbdc..13b392cdaa8876729791fb641a2e1f747f2dca8b 100644 (file)
@@ -67,6 +67,7 @@ public:
     void close();
     void flush(void);
     int getc();
+    bool skip(unsigned length);
 
     virtual bool supportsOffsets() const = 0;
     virtual File::Offset currentOffset();
@@ -78,6 +79,7 @@ protected:
     virtual int rawGetc() = 0;
     virtual void rawClose() = 0;
     virtual void rawFlush() = 0;
+    virtual bool rawSkip(unsigned length) = 0;
 
 protected:
     std::string m_filename;
@@ -148,6 +150,14 @@ inline int File::getc()
     return rawGetc();
 }
 
+inline bool File::skip(unsigned length)
+{
+    if (!m_isOpened || m_mode != File::Read) {
+        return false;
+    }
+    return rawSkip(length);
+}
+
 class ZLibFile : public File {
 public:
     ZLibFile(const std::string &filename = std::string(),
@@ -163,6 +173,7 @@ protected:
     virtual int rawGetc();
     virtual void rawClose();
     virtual void rawFlush();
+    virtual bool rawSkip(unsigned length);
 private:
     void *m_gzFile;
 };