llcrc.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLCRC_H
00033 #define LL_LLCRC_H
00034 
00035 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00036 // Class llcrc
00037 //
00038 // Simple 32 bit crc. To use, instantiate an LLCRC instance and feed
00039 // it the bytes you want to check. It will update the internal crc as
00040 // you go, and you can qery it at the end. As a horribly inefficient
00041 // example (don't try this at work kids):
00042 //
00043 //  LLCRC crc;
00044 //  FILE* fp = LLFile::fopen(filename,"rb");
00045 //  while(!feof(fp)) {
00046 //    crc.update(fgetc(fp));
00047 //  }
00048 //  fclose(fp);
00049 //  llinfos << "File crc: " << crc.getCRC() << llendl;
00050 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00051 
00052 class LLCRC
00053 {
00054 protected:
00055         U32 mCurrent;
00056         
00057 public:
00058         LLCRC();
00059 
00060         U32 getCRC() const;
00061         void update(U8 next_byte);
00062         void update(const U8* buffer, size_t buffer_size);
00063         void update(const char *filename);
00064 
00065 #ifdef _DEBUG
00066         // This function runs tests to make sure the crc is
00067         // working. Returns TRUE if it is.
00068         static BOOL testHarness();
00069 #endif
00070 };
00071 
00072 
00073 #endif // LL_LLCRC_H

Generated on Thu Jul 1 06:08:23 2010 for Second Life Viewer by  doxygen 1.4.7