apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

HashStringList Class Reference

#include <hashes.h>

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 ()
 
 HashStringList (std::string const &hash)
 
 HashStringList (char const *const hash)
 

Static Public Member Functions

static APT_PURE bool supported (char const *const type)
 

Private Attributes

std::vector< HashStringlist
 

Detailed Description

Definition at line 64 of file hashes.h.

Member Typedef Documentation

◆ const_iterator

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

Definition at line 130 of file hashes.h.

Constructor & Destructor Documentation

◆ HashStringList() [1/3]

HashStringList ( )
inline

Definition at line 152 of file hashes.h.

◆ HashStringList() [2/3]

HashStringList ( std::string const &  hash)
inlineexplicit

Definition at line 155 of file hashes.h.

◆ HashStringList() [3/3]

HashStringList ( char const *const  hash)
inlineexplicit

Definition at line 159 of file hashes.h.

Member Function Documentation

◆ begin()

◆ clear()

void clear ( )
inline

start fresh with a clear list

Definition at line 139 of file hashes.h.

Referenced by CacheDB::GetHashes().

◆ empty()

bool empty ( ) const
inline

is the list empty ?

Returns
true if the list is empty, otherwise false

Definition at line 119 of file hashes.h.

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

◆ end()

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

Definition at line 210 of file hashes.cc.

References find(), and HashString::HashValue().

Referenced by BaseHttpMethod::Fetch(), FileMethod::Fetch(), debSrcRecordParser::Files(), Hashes::GetHashStringList(), debRecordParserBase::Hashes(), pkgAcqIndex::Init(), debReleaseIndex::Load(), BaseHttpMethod::Loop(), pkgAcqDiffIndex::ParseDiffIndex(), pkgAcqMetaClearSig::QueueIndexes(), and pkgAcqMethod::Run().

◆ FileSize() [2/2]

bool FileSize ( unsigned long long const  Size)

sets the filesize hash

Parameters
Sizeof the file
Returns
See also
push_back

Definition at line 219 of file hashes.cc.

References push_back().

◆ find() [1/2]

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.

Definition at line 191 of file hashes.cc.

References _config, Configuration::Find(), and HashString::SupportedHashes().

Referenced by SourcesWriter::DoPackage(), FileSize(), pkgRecords::GetHashFromHashes(), pkgAcqDiffIndex::ParseDiffIndex(), push_back(), pkgAcqIndexDiffs::QueueNextDiff(), and usable().

◆ find() [2/2]

HashString const* find ( std::string const &  type) const
inline

Definition at line 75 of file hashes.h.

References find().

Referenced by find().

◆ operator!=()

bool operator!= ( HashStringList const &  other) const

Definition at line 293 of file hashes.cc.

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

Definition at line 268 of file hashes.cc.

References _config, and Configuration::Find().

◆ 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

Definition at line 232 of file hashes.cc.

References find(), HashString::HashType(), HashString::HashValue(), list, and supported().

Referenced by DoDownloadFile(), debSrcRecordParser::Files(), FileSize(), CacheDB::GetHashes(), GetHashesFromMessage(), Hashes::GetHashStringList(), debRecordParserBase::Hashes(), pkgAcqDiffIndex::ParseDiffIndex(), pkgAcqArchive::pkgAcqArchive(), RredMethod::ReadExpectedHashesForPatch(), pkgAcqMethod::Run(), and RredMethod::URIAcquire().

◆ size()

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

Definition at line 106 of file hashes.h.

◆ 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

Definition at line 224 of file hashes.cc.

References HashString::SupportedHashes().

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

Definition at line 178 of file hashes.cc.

References _config, empty(), find(), Configuration::Find(), and list.

Referenced by CheckForBadItemAndFailIt(), BaseHttpMethod::DealWithHeaders(), BaseHttpMethod::Fetch(), pkgAcqFile::HashesRequired(), BaseHttpMethod::Loop(), pkgAcqDiffIndex::ParseDiffIndex(), pkgAcqMetaClearSig::QueueIndexes(), pkgAcqIndexDiffs::QueueNextDiff(), and RredMethod::URIAcquire().

◆ 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

Definition at line 248 of file hashes.cc.

References Hashes::AddFD(), FileFd::FileSize(), Hashes::GetHashStringList(), HashString::HashValue(), FileFd::ReadOnly, and strprintf().

Referenced by FileMethod::Fetch(), and SigVerify::Verify().

Member Data Documentation

◆ list

std::vector<HashString> list
private

Definition at line 165 of file hashes.h.

Referenced by push_back(), and usable().


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