aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/qtools/decoder.h
blob: 44905fd51276c84db7b1ff0ba8765f1e6875285a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2006 The Android Open Source Project

#include <stdio.h>
#include <inttypes.h>

class Decoder {
 public:
  Decoder();
  ~Decoder();

  void          Open(char *filename);
  void          Close();
  int64_t       Decode(bool is_signed);
  void          Read(char *dest, int len);
  bool          IsEOF()          { return (end_ == next_) && feof(fstream_); }

 private:
  static const int kBufSize = 4096;
  static const int kDecodingSpace = 9;

  void          FillBuffer();

  char          *filename_;
  FILE          *fstream_;
  uint8_t       buf_[kBufSize];
  uint8_t       *next_;
  uint8_t       *end_;
};