FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "SHA1.H"
00027 #include <cstring>
00028 
00029 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00030 
00031 inline Foam::SHA1::SHA1()
00032 {
00033     clear();
00034 }
00035 
00036 
00037 inline Foam::SHA1::SHA1(const std::string& str)
00038 {
00039     clear();
00040     append(str);
00041 }
00042 
00043 
00044 inline Foam::SHA1::SHA1(const char* str)
00045 {
00046     clear();
00047     append(str);
00048 }
00049 
00050 
00051 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
00052 
00053 
00054 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00055 
00056 inline Foam::SHA1& Foam::SHA1::append(const char* data, size_t len)
00057 {
00058     processBytes(data, len);
00059     return *this;
00060 }
00061 
00062 
00063 inline Foam::SHA1& Foam::SHA1::append(const std::string& str)
00064 {
00065     processBytes(str.data(), str.size());
00066     return *this;
00067 }
00068 
00069 
00070 inline Foam::SHA1& Foam::SHA1::append(const char* str)
00071 {
00072     if (str)
00073     {
00074         processBytes(str, strlen(str));
00075     }
00076     return *this;
00077 }
00078 
00079 
00080 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00081 
00082 inline bool Foam::SHA1::operator==(const SHA1Digest& rhs) const
00083 {
00084     return this->digest() == rhs;
00085 }
00086 
00087 
00088 inline bool Foam::SHA1::operator!=(const SHA1Digest& rhs) const
00089 {
00090     return this->digest() != rhs;
00091 }
00092 
00093 
00094 inline bool Foam::SHA1::operator==(const SHA1& rhs) const
00095 {
00096     return digest() == rhs.digest();
00097 }
00098 
00099 
00100 inline bool Foam::SHA1::operator!=(const SHA1& rhs) const
00101 {
00102     return digest() != rhs.digest();
00103 }
00104 
00105 
00106 inline Foam::SHA1::operator
00107 Foam::SHA1Digest () const
00108 {
00109     return digest();
00110 }
00111 
00112 
00113 // * * * * * * * * * * * * * * * Friend Functions  * * * * * * * * * * * * * //
00114 
00115 
00116 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00117 
00118 
00119 // * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * * //
00120 
00121 
00122 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
00123 
00124 inline Foam::Ostream& Foam::operator<<(Ostream& os, const SHA1& sha)
00125 {
00126     return os << sha.digest();
00127 }
00128 
00129 
00130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00131 
00132 
00133 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines