X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/e788a834ce421042e727b72e43177edaa47e53a7..1d742e01470bba27715a8191c50adde4b39c2f19:/apt-pkg/contrib/hashsum_template.h diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index f96188eb8..4000f230d 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -10,20 +10,27 @@ #ifndef APTPKG_HASHSUM_TEMPLATE_H #define APTPKG_HASHSUM_TEMPLATE_H -#include #include #include -#include -#include +#ifdef APT_PKG_EXPOSE_STRING_VIEW +#include +#endif #include +#ifndef APT_10_CLEANER_HEADERS +#include +#include +#include +#endif #ifndef APT_8_CLEANER_HEADERS using std::string; using std::min; #endif +class FileFd; + template class HashSumValue { @@ -72,22 +79,40 @@ class HashSumValue return Value(); } +#ifdef APT_PKG_EXPOSE_STRING_VIEW + APT_HIDDEN bool Set(APT::StringView Str) + { + return Hex2Num(Str,Sum,sizeof(Sum)); + } +#else bool Set(std::string Str) { return Hex2Num(Str,Sum,sizeof(Sum)); } - +#endif inline void Set(unsigned char S[N/8]) { for (int I = 0; I != sizeof(Sum); ++I) Sum[I] = S[I]; } - HashSumValue(std::string Str) + explicit HashSumValue(std::string const &Str) + { + memset(Sum,0,sizeof(Sum)); + Set(Str); + } +#ifdef APT_PKG_EXPOSE_STRING_VIEW + APT_HIDDEN explicit HashSumValue(APT::StringView const &Str) { memset(Sum,0,sizeof(Sum)); Set(Str); } + APT_HIDDEN explicit HashSumValue(const char *Str) + { + memset(Sum,0,sizeof(Sum)); + Set(Str); + } +#endif HashSumValue() { memset(Sum,0,sizeof(Sum));