apt 3.2.0 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

Referenced by pkgAcqIndexMergeDiffs::Custom600Headers(), pkgAcquire::Queue::QItem::GetExpectedHashes(), operator==(), and pkgAcquire::Worker::QueueItem().

## ◆ clear()

void clear | ( |  | ) |
| inline

start fresh with a clear list

Referenced by pkgAcquire::Queue::QItem::GetExpectedHashes().

## ◆ empty()

bool empty | ( |  | ) | const
| inline

is the list empty ?

Returns
  true if the list is empty, otherwise false

Referenced by pkgAcquire::Worker::RunMessages(), and usable().

## ◆ end()

const_iterator end | ( |  | ) | const
| inline

iterator to the end element

Referenced by pkgAcqIndexMergeDiffs::Custom600Headers(), pkgAcquire::Queue::QItem::GetExpectedHashes(), operator==(), and pkgAcquire::Worker::QueueItem().

## ◆ 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 debRecordParserBase::Hashes(), debReleaseIndex::Load(), pkgAcqDiffIndex::ParseDiffIndex(), pkgAcquire::Worker::QueueItem(), pkgAcquire::QueueName(), and pkgAcquire::Worker::RunMessages().

## ◆ FileSize() [2/2]

bool FileSize | ( | unsigned long long const | Size | ) |

sets the filesize hash

Parameters

  Size | of 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

  type | of 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.

References find().

Referenced by FileSize(), find(), pkgAcquire::Item::HashSum(), operator==(), pkgAcqDiffIndex::ParseDiffIndex(), push_back(), usable(), and VerifyFile().

## ◆ 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.

References begin(), end(), and find().

## ◆ push_back()

bool push_back | ( | const HashString & | hashString | ) |

add the given HashString to the list

Parameters

  hashString | to 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(), pkgAcquire::Queue::QItem::GetExpectedHashes(), debRecordParserBase::Hashes(), pkgAcqDiffIndex::ParseDiffIndex(), and pkgAcquire::Worker::RunMessages().

## ◆ 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

  type | to 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 pkgAcqFile::HashesRequired(), pkgAcqDiffIndex::ParseDiffIndex(), pkgAcquire::Worker::RunMessages(), and VerifyFile().

## ◆ VerifyFile()

bool VerifyFile | ( | std::string | filename | ) | const

verify file against all hashes in the list

Parameters

  filename | to verify

Returns
  true if the file matches the hashsum, otherwise false

References find(), and usable().

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

- apt-pkg/contrib/hashes.h
- apt-pkg/contrib/hashes.cc