ROOT logo
// $Id: GCRC32.h 2475 2011-05-29 21:25:12Z matevz $

// Public domain, original author Eric Durbin, 1998.
// Modified by Andrew Hanushevsky, 2007.
// Modified by Matevz Tadel upon inclusion in Gled in 2011.

#ifndef GledCore_GCRC32_H
#define GledCore_GCRC32_H

#include <Rtypes.h>

class GCRC32
{
public:
  enum Init_e { I_Now };

protected:
  UInt_t	mCrc;

  static const UInt_t sInit;
  static const UInt_t sXorOut;

  void process(const UChar_t* p, Int_t len);

public:
  GCRC32() : mCrc(sInit) {}
  GCRC32(const GCRC32& t) : mCrc(t.mCrc) {}

  ~GCRC32() {}

  UInt_t GetCrc() const { return mCrc ^ sXorOut; }
  void   Reset() { mCrc = sInit; }

  template<typename T> GCRC32& Start(T* p, Int_t len)
  { mCrc = sInit; process((UChar_t*) p, len); return *this; }

  template<typename T> GCRC32& Start(T& r)
  { mCrc = sInit; process((UChar_t*) &r, sizeof(T)); return *this; }

  template<typename T> GCRC32& Process(const T* p, Int_t len)
  { process((const UChar_t*) p, len); return *this; }

  template<typename T> GCRC32& Process(T& r)
  { process((UChar_t*) &r, sizeof(T)); return *this; }

  template<typename T> UInt_t Finish(const T* p, Int_t len)
  { process((const UChar_t*) p, len); return GetCrc(); }

  template<typename T> UInt_t Finish(T& r)
  { process((UChar_t*) &r, sizeof(T)); return GetCrc(); }


  static UInt_t CRC32(const UChar_t* p, Int_t len);

  ClassDefNV(GCRC32, 0);
}; // endclass GCRC32

#endif

 GCRC32.h:1
 GCRC32.h:2
 GCRC32.h:3
 GCRC32.h:4
 GCRC32.h:5
 GCRC32.h:6
 GCRC32.h:7
 GCRC32.h:8
 GCRC32.h:9
 GCRC32.h:10
 GCRC32.h:11
 GCRC32.h:12
 GCRC32.h:13
 GCRC32.h:14
 GCRC32.h:15
 GCRC32.h:16
 GCRC32.h:17
 GCRC32.h:18
 GCRC32.h:19
 GCRC32.h:20
 GCRC32.h:21
 GCRC32.h:22
 GCRC32.h:23
 GCRC32.h:24
 GCRC32.h:25
 GCRC32.h:26
 GCRC32.h:27
 GCRC32.h:28
 GCRC32.h:29
 GCRC32.h:30
 GCRC32.h:31
 GCRC32.h:32
 GCRC32.h:33
 GCRC32.h:34
 GCRC32.h:35
 GCRC32.h:36
 GCRC32.h:37
 GCRC32.h:38
 GCRC32.h:39
 GCRC32.h:40
 GCRC32.h:41
 GCRC32.h:42
 GCRC32.h:43
 GCRC32.h:44
 GCRC32.h:45
 GCRC32.h:46
 GCRC32.h:47
 GCRC32.h:48
 GCRC32.h:49
 GCRC32.h:50
 GCRC32.h:51
 GCRC32.h:52
 GCRC32.h:53
 GCRC32.h:54
 GCRC32.h:55
 GCRC32.h:56
 GCRC32.h:57
 GCRC32.h:58
 GCRC32.h:59