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 19 of file sha1.hh.

Constructor & Destructor Documentation

◆ Sha1Sum() [1/3]

openmsx::Sha1Sum::Sha1Sum ( UninitializedTag  )
inline

Definition at line 23 of file sha1.hh.

References clear(), empty(), parse40(), Sha1Sum(), and toString().

◆ Sha1Sum() [2/3]

openmsx::Sha1Sum::Sha1Sum ( )

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

Referenced by Sha1Sum().

◆ Sha1Sum() [3/3]

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

Construct from string, throws when string is malformed.

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

References openmsx::x.

Member Function Documentation

◆ clear()

void openmsx::Sha1Sum::clear ( )

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

References ranges::fill().

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

◆ empty()

bool openmsx::Sha1Sum::empty ( ) const

◆ operator!=()

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

Definition at line 47 of file sha1.hh.

◆ operator<()

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

Definition at line 48 of file sha1.hh.

◆ operator<=()

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

Definition at line 55 of file sha1.hh.

◆ operator==()

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

Definition at line 41 of file sha1.hh.

◆ operator>()

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

Definition at line 56 of file sha1.hh.

◆ operator>=()

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

Definition at line 57 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

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

References t, and unlikely.

Referenced by Sha1Sum(), and TEST_CASE().

◆ 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 59 of file sha1.hh.

◆ SHA1

friend class SHA1
friend

Definition at line 66 of file sha1.hh.


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