apt 3.0.3
commandline package manager
Public Types | Public Member Functions | Static Public Member Functions | List of all members
HashStringList Class Reference

Public Types

typedef std::vector< HashString >::const_iterator const_iterator
 

Public Member Functions

HashString const * find (char const *const type) const
 
HashString const * find (std::string const &type) const
 
unsigned long long FileSize () const
 
bool FileSize (unsigned long long const Size)
 
bool push_back (const HashString &hashString)
 
size_t size () const
 
bool VerifyFile (std::string filename) const
 
bool empty () const
 
bool usable () const
 
const_iterator begin () const
 
const_iterator end () const
 
void clear ()
 
bool operator== (HashStringList const &other) const
 
bool operator!= (HashStringList const &other) const
 
 HashStringList (std::string const &hash)
 
 HashStringList (char const *const hash)
 

Static Public Member Functions

static APT_PURE bool supported (char const *const type)
 

Member Function Documentation

◆ begin()

const_iterator begin ( ) const
inline

iterator to the first element

◆ clear()

void clear ( )
inline

start fresh with a clear list

◆ empty()

bool empty ( ) const
inline

is the list empty ?

Returns
true if the list is empty, otherwise false

Referenced by pkgAcqArchive::pkgAcqArchive(), pkgAcqMetaClearSig::QueueIndexes(), and usable().

◆ end()

const_iterator end ( ) const
inline

iterator to the end element

◆ FileSize() [1/2]

unsigned long long FileSize ( ) const

finds the filesize hash and returns it as number

Returns
beware: if the size isn't known we return 0 here, just like we would do for an empty file. If that is a problem for you have to get the size manually out of the list.

References find().

Referenced by debReleaseIndex::Load(), pkgAcqDiffIndex::ParseDiffIndex(), pkgAcqMetaClearSig::QueueIndexes(), and pkgAcquire::QueueName().

◆ FileSize() [2/2]

bool FileSize ( unsigned long long const  Size)

sets the filesize hash

Parameters
Sizeof the file
Returns
See also
push_back

References push_back().

◆ find()

HashString const * find ( char const *const  type) const

find best hash if no specific one is requested

Parameters
typeof the checksum to return, can be NULL
Returns
If type is NULL (or the empty string) it will return the 'best' hash; otherwise the hash which was specifically requested. If no hash is found NULL will be returned.

Referenced by FileSize(), pkgAcqDiffIndex::ParseDiffIndex(), push_back(), and usable().

◆ operator==()

bool operator== ( HashStringList const &  other) const

compare two HashStringList for similarity.

Two lists are similar if at least one hashtype is in both lists and the hashsum matches. All hashes are checked by default, if one doesn't match false is returned regardless of how many matched before. If a hash is forced, only this hash is compared, all others are ignored.

◆ push_back()

bool push_back ( const HashString hashString)

add the given HashString to the list

Parameters
hashStringto add
Returns
true if the hash is added because it is supported and not already a different hash of the same type included, otherwise false

References find(), and supported().

Referenced by FileSize(), debReleaseIndex::Load(), pkgAcqDiffIndex::ParseDiffIndex(), and pkgAcqArchive::pkgAcqArchive().

◆ size()

size_t size ( ) const
inline
Returns
size of the list of HashStrings

◆ supported()

bool supported ( char const *const  type)
static

check if the given hash type is supported

Parameters
typeto check
Returns
true if supported, otherwise false

Referenced by push_back().

◆ usable()

bool usable ( ) const

has the list at least one good entry

similar to empty, but handles forced hashes.

Returns
if no hash is forced, same result as empty, if one is forced true if this has is available, false otherwise

References empty(), and find().

Referenced by pkgAcqDiffIndex::ParseDiffIndex(), and pkgAcqMetaClearSig::QueueIndexes().

◆ VerifyFile()

bool VerifyFile ( std::string  filename) const

verify file against all hashes in the list

Parameters
filenameto verify
Returns
true if the file matches the hashsum, otherwise false

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