OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

SHA1I.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "SHA1.H"
00028 #include <cstring>
00029 
00030 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00031 
00032 inline Foam::SHA1::SHA1()
00033 {
00034     clear();
00035 }
00036 
00037 
00038 inline Foam::SHA1::SHA1(const std::string& str)
00039 {
00040     clear();
00041     append(str);
00042 }
00043 
00044 
00045 inline Foam::SHA1::SHA1(const char* str)
00046 {
00047     clear();
00048     append(str);
00049 }
00050 
00051 
00052 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
00053 
00054 
00055 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00056 
00057 inline Foam::SHA1& Foam::SHA1::append(const char* data, size_t len)
00058 {
00059     processBytes(data, len);
00060     return *this;
00061 }
00062 
00063 
00064 inline Foam::SHA1& Foam::SHA1::append(const std::string& str)
00065 {
00066     processBytes(str.data(), str.size());
00067     return *this;
00068 }
00069 
00070 
00071 inline Foam::SHA1& Foam::SHA1::append(const char* str)
00072 {
00073     if (str)
00074     {
00075         processBytes(str, strlen(str));
00076     }
00077     return *this;
00078 }
00079 
00080 
00081 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00082 
00083 inline bool Foam::SHA1::operator==(const SHA1Digest& rhs) const
00084 {
00085     return this->digest() == rhs;
00086 }
00087 
00088 
00089 inline bool Foam::SHA1::operator!=(const SHA1Digest& rhs) const
00090 {
00091     return this->digest() != rhs;
00092 }
00093 
00094 
00095 inline bool Foam::SHA1::operator==(const SHA1& rhs) const
00096 {
00097     return digest() == rhs.digest();
00098 }
00099 
00100 
00101 inline bool Foam::SHA1::operator!=(const SHA1& rhs) const
00102 {
00103     return digest() != rhs.digest();
00104 }
00105 
00106 
00107 inline Foam::SHA1::operator
00108 Foam::SHA1Digest () const
00109 {
00110     return digest();
00111 }
00112 
00113 
00114 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
00115 
00116 
00117 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00118 
00119 
00120 // * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * * //
00121 
00122 
00123 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
00124 
00125 inline Foam::Ostream& Foam::operator<<(Ostream& os, const SHA1& sha)
00126 {
00127     return os << sha.digest();
00128 }
00129 
00130 
00131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00132 
00133 
00134 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd