00001 /* 00002 * Checksum 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 checksum.hpp 00022 * Interface for classes that compute checksums. 00023 */ 00024 00025 #ifndef INC_CHECKSUM_HPP 00026 #define INC_CHECKSUM_HPP 00027 00028 //--------------------------------------------------------------------------- 00029 // For compilers that support precompilation, includes "wx.h". 00030 #include <wx/wxprec.h> 00031 00032 #ifdef __BORLANDC__ 00033 #pragma hdrstop 00034 #endif 00035 00036 #ifndef WX_PRECOMP 00037 // Include your minimal set of headers here, or wx.h 00038 #include <wx/wx.h> 00039 #endif 00040 //--------------------------------------------------------------------------- 00041 00042 00043 /** 00044 * Computes a checksum from a byte stream. 00045 * 00046 * Using this class in very simple:<BR> 00047 * Use the @link update(const wxByte* buf, unsigned int len) update @endlink 00048 * method to provide to the class the bytes for computing the checksum. 00049 * 00050 * The checksum value can be gotten by the @link getValue(const bool) const 00051 * getValue @endlink method which puts the checksum value in a string. 00052 * 00053 * The checksum computing can be reseted by the @link reset() reset @endlink 00054 * method. 00055 */ 00056 class Checksum 00057 { 00058 public: 00059 /** 00060 * Resets the checksum to initial value. 00061 */ 00062 virtual void reset() = 0; 00063 00064 /** 00065 * Returns the checksum value in a string. 00066 * 00067 * @param hexInUpperCase If <CODE>true</CODE> the hexadecimal letters will 00068 * be in uppercase. 00069 * @return The current checksum value. 00070 */ 00071 virtual wxString getValue(const bool hexInUpperCase = false) const = 0; 00072 00073 /** 00074 * Updates the checksum with specified array of bytes. 00075 * 00076 * @param buf The byte array to update the checksum with. 00077 * @param len The number of bytes to use for the update. 00078 */ 00079 virtual void update(const wxByte* buf, unsigned int len) = 0; 00080 }; 00081 //--------------------------------------------------------------------------- 00082 00083 /// A dynamic array of checksums. 00084 WX_DEFINE_ARRAY(Checksum*, ArrayChecksum); 00085 //--------------------------------------------------------------------------- 00086 00087 #endif // INC_CHECKSUM_HPP