Adler32.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: Adler32.hpp 2535 2011-03-25 15:58:06Z ccutlip $"
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_ALDER32_H
00029 #define VDRAW_ALDER32_H
00030 
00031 #include <string>
00032 #include <memory>
00033 
00034 //http://en.wikipedia.org/wiki/Adler-32
00035 
00036 namespace vdraw
00037 {
00040 
00044   class Adler32
00045   {
00046     protected:
00048       static const unsigned int mod = 65521;
00049 
00051       unsigned int a;
00052 
00054       unsigned int b;
00055 
00056     public:
00060       Adler32()
00061       {
00062         reset();
00063       }
00064 
00065 
00069       inline void reset()
00070       {
00071         a=1; b=0;
00072       }
00073 
00079       inline unsigned int getValue() const
00080       {
00081         return (b << 16) | a;
00082       }
00083 
00089       void update(const std::string &str)
00090       {
00091         update(str.c_str(),str.length());
00092       }
00093 
00099       void update(const std::auto_ptr<std::string> &str)
00100       {
00101         update(str->c_str(),str->length());
00102       }
00103 
00110       void update(const char* buf, unsigned int len);
00111 
00112   }; // class Adler32
00113 
00115 
00116 } // namespace vdraw
00117 
00118 #endif //VDRAW_ALDER32_H
00119 
00120 

Generated on Wed Feb 8 03:30:57 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1