#include <time.h>
#include <stdint.h>
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+#include <apt-pkg/string_view.h>
+#endif
+
#ifndef APT_8_CLEANER_HEADERS
using std::string;
#endif
// Memory mapped cache file
std::string CacheFile;
MMap ⤅
-
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+ APT_HIDDEN map_id_t sHash(APT::StringView S) const APT_PURE;
+#endif
map_id_t sHash(const std::string &S) const APT_PURE;
map_id_t sHash(const char *S) const APT_PURE;
inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();}
// String hashing function (512 range)
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+ APT_HIDDEN inline map_id_t Hash(APT::StringView S) const {return sHash(S);}
+#endif
inline map_id_t Hash(const std::string &S) const {return sHash(S);}
inline map_id_t Hash(const char *S) const {return sHash(S);}
+ APT_HIDDEN uint32_t CacheHash();
+
// Useful transformation things
static const char *Priority(unsigned char Priority);
// Accessors
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+ APT_HIDDEN GrpIterator FindGrp(APT::StringView Name);
+ APT_HIDDEN PkgIterator FindPkg(APT::StringView Name);
+ APT_HIDDEN PkgIterator FindPkg(APT::StringView Name, APT::StringView Arch);
+#endif
+
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+ APT::StringView ViewString(map_stringitem_t idx) const
+ {
+ char *name = StrP + idx;
+ uint16_t len = *reinterpret_cast<const uint16_t*>(name - sizeof(uint16_t));
+ return APT::StringView(name, len);
+ }
+#endif
+
+
GrpIterator FindGrp(const std::string &Name);
PkgIterator FindPkg(const std::string &Name);
PkgIterator FindPkg(const std::string &Name, const std::string &Arch);
map_pointer_t * PkgHashTableP() const { return (map_pointer_t*) (this + 1); }
map_pointer_t * GrpHashTableP() const { return PkgHashTableP() + GetHashTableSize(); }
- /** \brief Size of the complete cache file */
+ /** \brief Hash of the file (TODO: Rename) */
map_filesize_small_t CacheFileSize;
bool CheckSizes(Header &Against) const APT_PURE;