Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

crc32.hpp

Go to the documentation of this file.
00001 /* 00002 * CRC32 00003 * Written by Julien Couot. 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 /** 00021 * \file crc32.hpp 00022 * Compute crc32. 00023 */ 00024 00025 00026 //--------------------------------------------------------------------------- 00027 // For compilers that support precompilation, includes "wx.h". 00028 #include <wx/wxprec.h> 00029 00030 #ifdef __BORLANDC__ 00031 #pragma hdrstop 00032 #endif 00033 00034 #ifndef WX_PRECOMP 00035 // Include your minimal set of headers here, or wx.h 00036 #include <wx/wx.h> 00037 #endif 00038 #include "checksum.hpp" 00039 //--------------------------------------------------------------------------- 00040 00041 00042 /** 00043 * Computes the CRC-32 from a byte stream. 00044 * 00045 * This class is writen with the code found in 00046 * <A HREF="http://www.fodder.org/cksfv/">cksfv</A> and 00047 * <A HREF="http://www.gzip.org/zlib/">zlib</A> code. 00048 * 00049 * Using this class in very simple:<BR> 00050 * Use the @link update(const wxByte* buf, unsigned int len) update @endlink 00051 * method to provide to the class the bytes for computing the checksum. 00052 * 00053 * The CRC-32 checksum value can be gotten by the @link getValue(const bool) const 00054 * getValue @endlink method which puts the CRC32 checksum value in a 00055 * unsigned 32 bits integer. 00056 * 00057 * The CRC32 checksum computing can be reseted by the @link reset() reset 00058 * @endlink method. 00059 */ 00060 class CRC32 : public Checksum 00061 { 00062 protected: 00063 /// Table used to compute the CRC32 value. 00064 static const wxUint32 crc_table[256]; 00065 00066 /// The current CRC32 value. 00067 wxUint32 crc32; 00068 00069 public: 00070 /** 00071 * Default constructor. 00072 */ 00073 CRC32(); 00074 00075 /** 00076 * Resets the CRC32 to initial value. 00077 */ 00078 void reset(); 00079 00080 /** 00081 * Returns the CRC32 value. 00082 * 00083 * @return The current checksum value. 00084 */ 00085 wxUint32 getUint32Value() const; 00086 00087 /** 00088 * Returns the CRC32 value in a string. 00089 * 00090 * @param hexInUpperCase If <CODE>true</CODE> the hexadecimal letters will 00091 * be in uppercase. 00092 * @return The current CRC32 value. 00093 */ 00094 wxString getValue(const bool hexInUpperCase = false) const; 00095 00096 /** 00097 * Updates the CRC32 with specified array of bytes. 00098 * 00099 * @param buf The byte array to update the CRC32 with. 00100 * @param len The number of bytes to use for the update. 00101 */ 00102 void update(const wxByte* buf, unsigned int len); 00103 }; 00104 //---------------------------------------------------------------------------

Generated on Sun May 30 13:37:44 2004 for wxChecksums by doxygen 1.3.7