openMSX
Classes | Public Member Functions | Friends | List of all members
openmsx::Sha1Sum Class Reference

This class represents the result of a sha1 calculation (a 160-bit value). More...

#include <sha1.hh>

Classes

struct  UninitializedTag
 

Public Member Functions

 Sha1Sum (UninitializedTag)
 
 Sha1Sum ()
 
 Sha1Sum (std::string_view hex)
 Construct from string, throws when string is malformed. More...
 
void parse40 (const char *str)
 Parse from a 40-character long buffer. More...
 
std::string toString () const
 
bool empty () const
 
void clear ()
 
bool operator== (const Sha1Sum &other) const
 
bool operator!= (const Sha1Sum &other) const
 
bool operator< (const Sha1Sum &other) const
 
bool operator<= (const Sha1Sum &other) const
 
bool operator> (const Sha1Sum &other) const
 
bool operator>= (const Sha1Sum &other) const
 

Friends

class SHA1
 
std::ostream & operator<< (std::ostream &os, const Sha1Sum &sum)
 

Detailed Description

This class represents the result of a sha1 calculation (a 160-bit value).

Objects of this class can be constructed from/converted to 40-digit hex string. We treat the value '000...00' (all zeros) special. This value can be used to indicate a null-sha1sum value (e.g. sha1 not yet calculated, or not meaningful). In theory it's possible this special value is the result of an actual sha1 calculation, but this has an extremely low probability.

Definition at line 21 of file sha1.hh.

Constructor & Destructor Documentation

◆ Sha1Sum() [1/3]

openmsx::Sha1Sum::Sha1Sum ( UninitializedTag  )
inline

Definition at line 25 of file sha1.hh.

◆ Sha1Sum() [2/3]

openmsx::Sha1Sum::Sha1Sum ( )

Definition at line 96 of file utils/sha1.cc.

References clear().

◆ Sha1Sum() [3/3]

openmsx::Sha1Sum::Sha1Sum ( std::string_view  hex)
explicit

Construct from string, throws when string is malformed.

Definition at line 101 of file utils/sha1.cc.

References parse40().

Member Function Documentation

◆ clear()

void openmsx::Sha1Sum::clear ( )

Definition at line 246 of file utils/sha1.cc.

References ranges::fill().

Referenced by openmsx::SectorAccessibleDisk::flushCaches(), and Sha1Sum().

◆ empty()

bool openmsx::Sha1Sum::empty ( ) const

◆ operator!=()

bool openmsx::Sha1Sum::operator!= ( const Sha1Sum other) const
inline

Definition at line 49 of file sha1.hh.

◆ operator<()

bool openmsx::Sha1Sum::operator< ( const Sha1Sum other) const
inline

Definition at line 50 of file sha1.hh.

References xrange().

◆ operator<=()

bool openmsx::Sha1Sum::operator<= ( const Sha1Sum other) const
inline

Definition at line 57 of file sha1.hh.

◆ operator==()

bool openmsx::Sha1Sum::operator== ( const Sha1Sum other) const
inline

Definition at line 43 of file sha1.hh.

References xrange().

◆ operator>()

bool openmsx::Sha1Sum::operator> ( const Sha1Sum other) const
inline

Definition at line 58 of file sha1.hh.

◆ operator>=()

bool openmsx::Sha1Sum::operator>= ( const Sha1Sum other) const
inline

Definition at line 59 of file sha1.hh.

◆ parse40()

void openmsx::Sha1Sum::parse40 ( const char *  str)

Parse from a 40-character long buffer.

Precondition
'str' points to a buffer of at least 40 characters
Exceptions
MSXExceptionif chars are not 0-9, a-f, A-F

Definition at line 139 of file utils/sha1.cc.

References repeat(), t, and unlikely.

Referenced by Sha1Sum().

◆ toString()

std::string openmsx::Sha1Sum::toString ( ) const

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Sha1Sum sum 
)
friend

Definition at line 61 of file sha1.hh.

◆ SHA1

friend class SHA1
friend

Definition at line 68 of file sha1.hh.


The documentation for this class was generated from the following files: