"Fossies" - the Fresh Open Source Software Archive

Member "xdelta3-3.1.0/testing/delta.h" (4 Jan 2016, 1681 Bytes) of package /linux/misc/xdelta3-3.1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "delta.h": 3.0.11_vs_3.1.0.

    1 // Mode: -*- C++ -*-
    2 
    3 class Delta {
    4 public:
    5   Delta(const Block &block) {
    6     int ret;
    7     xd3_config config;
    8     memset(&stream_, 0, sizeof (stream_));
    9     memset(&config, 0, sizeof (config));
   10 
   11     xd3_init_config(&config, XD3_SKIP_EMIT | XD3_ADLER32_NOVER);
   12 
   13     CHECK_EQ(0, xd3_config_stream (&stream_, &config));
   14 
   15     xd3_avail_input (&stream_, block.Data(), block.Size());
   16 
   17     bool done = false;
   18     while (!done) {
   19       ret = xd3_decode_input(&stream_);
   20     
   21       switch (ret) {
   22       case XD3_INPUT:
   23     done = true;
   24     break;
   25       case XD3_OUTPUT:
   26     CHECK_EQ(0, xd3_whole_append_window (&stream_));
   27     break;
   28       case XD3_GOTHEADER:
   29       case XD3_WINSTART:
   30       case XD3_WINFINISH:
   31     break;
   32       default:
   33     cerr << "decode: " << done;
   34     abort();
   35       }
   36     }
   37   }
   38 
   39   ~Delta() {
   40     xd3_free_stream(&stream_);
   41   }
   42 
   43   xoff_t AddedBytes() const {
   44     return stream_.whole_target.addslen;
   45   }
   46 
   47   xoff_t Windows() const {
   48     return stream_.whole_target.wininfolen;
   49   }
   50 
   51 // Note: This does not benefit from -Wformat= checking, due to the
   52 // enclosing template. Further, it was not used.
   53 // void Print() const {
   54 //     for (size_t i = 0; i < stream_.whole_target.instlen; i++) {
   55 //       xd3_winst &winst = stream_.whole_target.inst[i];
   56 //       switch (winst.type) {
   57 //       case XD3_RUN: 
   58 //  DP(RINT, "%" Q "u run %" W "u\n", winst.position, winst.size);
   59 //  break;
   60 //       case XD3_ADD: 
   61 //  DP(RINT "%" Q "u add %" W "u\n", winst.position, winst.size);
   62 //  break;
   63 //       default:
   64 //  DP(RINT "%" Q "u copy %" W "u @ %" Q "u (mode %u)\n", 
   65 //     winst.position, winst.size, winst.addr, winst.mode);
   66 //  break;
   67 //       }
   68 //     }
   69 //   }
   70 
   71 private:
   72   xd3_stream stream_;
   73 };