00001 #pragma ident "$Id: CRC32.hpp 1644 2009-01-27 19:26:14Z ckiesch $" 00002 00004 00005 //============================================================================ 00006 // 00007 // This file is part of GPSTk, the GPS Toolkit. 00008 // 00009 // The GPSTk is free software; you can redistribute it and/or modify 00010 // it under the terms of the GNU Lesser General Public License as published 00011 // by the Free Software Foundation; either version 2.1 of the License, or 00012 // any later version. 00013 // 00014 // The GPSTk is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with GPSTk; if not, write to the Free Software Foundation, 00021 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 // Copyright 2004, The University of Texas at Austin 00024 // 00025 //============================================================================ 00026 00027 00028 #ifndef VDRAW_CRC32_H 00029 #define VDRAW_CRC32_H 00030 00031 #include <string> 00032 00033 // Based on 00034 // http://burtleburtle.net/bob/c/crc.c 00035 // and 00036 // http://www.csbruce.com/~csbruce/software/crc32.c 00037 00038 namespace vdraw 00039 { 00042 00046 class CRC32 00047 { 00048 protected: 00050 static const unsigned int crc_table[256]; 00051 00053 unsigned int crc32; 00054 00055 public: 00057 CRC32() 00058 { 00059 reset(); 00060 } 00061 00063 inline void reset() 00064 { 00065 crc32 = 0xffffffff; 00066 } 00067 00069 inline unsigned int getValue() const 00070 { 00071 return crc32 ^ 0xffffffff; 00072 } 00073 00078 void update(const std::string &str) 00079 { 00080 update(str.c_str(),str.length()); 00081 } 00082 00088 void update(const char* buf, unsigned int len); 00089 00090 }; // class CRC32 00091 00093 00094 } // namespace vdraw 00095 00096 #endif //VDRAW_CRC32_H 00097 00098
1.3.9.1