PageRenderTime 55ms CodeModel.GetById 48ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcommon/llcrc.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 68 lines | 17 code | 8 blank | 43 comment | 0 complexity | f4834a8ee4c33378372dee67f3476655 MD5 | raw file
 1/** 
 2 * @file llcrc.h
 3 * @brief LLCRC class header file.
 4 *
 5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LL_LLCRC_H
28#define LL_LLCRC_H
29
30//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31// Class llcrc
32//
33// Simple 32 bit crc. To use, instantiate an LLCRC instance and feed
34// it the bytes you want to check. It will update the internal crc as
35// you go, and you can qery it at the end. As a horribly inefficient
36// example (don't try this at work kids):
37//
38//  LLCRC crc;
39//  FILE* fp = LLFile::fopen(filename,"rb");
40//  while(!feof(fp)) {
41//    crc.update(fgetc(fp));
42//  }
43//  fclose(fp);
44//  llinfos << "File crc: " << crc.getCRC() << llendl;
45//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46
47class LL_COMMON_API LLCRC
48{
49protected:
50	U32 mCurrent;
51	
52public:
53	LLCRC();
54
55	U32 getCRC() const;
56	void update(U8 next_byte);
57	void update(const U8* buffer, size_t buffer_size);
58	void update(const std::string& filename);
59
60#ifdef _DEBUG
61	// This function runs tests to make sure the crc is
62	// working. Returns TRUE if it is.
63	static BOOL testHarness();
64#endif
65};
66
67
68#endif // LL_LLCRC_H