summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorнаб <nabijaczleweli@nabijaczleweli.xyz>2024-11-12 18:22:44 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2025-02-14 19:45:12 +0100
commit4f6d379124bc51a09608fa3f45d66713f927b959 (patch)
treeb20d5437d722deb919d92f06498402d23e53eef6 /apt-pkg
parent793c9b1f3059c35b66c19f62fa39b6607809fea0 (diff)
Drop APT::StringView
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/proxy.cc3
-rw-r--r--apt-pkg/contrib/string_view.h170
-rw-r--r--apt-pkg/deb/deblistparser.cc19
-rw-r--r--apt-pkg/deb/deblistparser.h9
-rw-r--r--apt-pkg/pkgcache.cc1
-rw-r--r--apt-pkg/pkgcachegen.cc2
6 files changed, 2 insertions, 202 deletions
diff --git a/apt-pkg/contrib/proxy.cc b/apt-pkg/contrib/proxy.cc
index aad272190..4780f9b5a 100644
--- a/apt-pkg/contrib/proxy.cc
+++ b/apt-pkg/contrib/proxy.cc
@@ -12,7 +12,6 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/string_view.h>
#include <apt-pkg/strutl.h>
#include <algorithm>
@@ -89,7 +88,7 @@ bool AutoDetectProxy(URI &URL)
// and apt will use the generic proxy settings
if (goodread == false)
return true;
- APT::StringView const cleanedbuf = _strstrip(buf);
+ std::string_view const cleanedbuf = _strstrip(buf);
// We warn about this as the implementor probably meant to use DIRECT instead
if (cleanedbuf.empty())
{
diff --git a/apt-pkg/contrib/string_view.h b/apt-pkg/contrib/string_view.h
deleted file mode 100644
index 538e79a92..000000000
--- a/apt-pkg/contrib/string_view.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Basic implementation of string_view
- *
- * (C) 2015 Julian Andres Klode <jak@debian.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#if !defined(APT_STRINGVIEW_H)
-#define APT_STRINGVIEW_H
-#include <apt-pkg/macros.h>
-#include <algorithm>
-#include <cstring>
-#include <iosfwd>
-#include <string>
-#include <string_view>
-
-#if APT_PKG_ABI > 600
-namespace APT {
-using StringView = std::string_view;
-}
-#else
-namespace APT {
-
-/**
- * \brief Simple subset of std::string_view from C++17
- *
- * This is an internal implementation of the subset of std::string_view
- * used by APT. It is not meant to be used in programs, only inside the
- * library for performance critical paths.
- */
-class StringView {
- const char *data_;
- size_t size_;
-
-public:
- static constexpr size_t npos = static_cast<size_t>(-1);
- static_assert(APT::StringView::npos == std::string::npos, "npos values are different");
-
- /* Constructors */
- constexpr StringView() : data_(""), size_(0) {}
- constexpr StringView(const char *data, size_t size) : data_(data), size_(size) {}
-
- StringView(const char *data) : data_(data), size_(strlen(data)) {}
- StringView(std::string const & str): data_(str.data()), size_(str.size()) {}
- inline StringView(std::string_view const & str): data_(str.data()), size_(str.size()) {}
-
- /* Modifiers */
- void remove_prefix(size_t n) { data_ += n; size_ -= n; }
- void remove_suffix(size_t n) { size_ -= n; }
- void clear() { size_ = 0; }
-
- /* Viewers */
- constexpr StringView substr(size_t pos, size_t n = npos) const {
- return StringView(data_ + pos, n > (size_ - pos) ? (size_ - pos) : n);
- }
-
- size_t find(int c, size_t pos) const {
- if (pos == 0)
- return find(c);
- size_t const found = substr(pos).find(c);
- if (found == npos)
- return npos;
- return pos + found;
- }
- size_t find(int c) const {
- const char *found = static_cast<const char*>(memchr(data_, c, size_));
-
- if (found == NULL)
- return npos;
-
- return found - data_;
- }
-
- size_t rfind(int c, size_t pos) const {
- if (pos == npos)
- return rfind(c);
- return APT::StringView(data_, pos).rfind(c);
- }
- size_t rfind(int c) const {
- const char *found = static_cast<const char*>(memrchr(data_, c, size_));
-
- if (found == NULL)
- return npos;
-
- return found - data_;
- }
-
- size_t find(APT::StringView const needle) const {
- if (needle.empty())
- return npos;
- if (needle.length() == 1)
- return find(*needle.data());
- size_t found = 0;
- while ((found = find(*needle.data(), found)) != npos) {
- if (compare(found, needle.length(), needle) == 0)
- return found;
- ++found;
- }
- return found;
- }
- size_t find(APT::StringView const needle, size_t pos) const {
- if (pos == 0)
- return find(needle);
- size_t const found = substr(pos).find(needle);
- if (found == npos)
- return npos;
- return pos + found;
- }
-
- /* Conversions */
- std::string to_string() const {
- return std::string(data_, size_);
- }
-
- /* Comparisons */
- int compare(size_t pos, size_t n, StringView other) const {
- return substr(pos, n).compare(other);
- }
-
- int compare(StringView other) const {
- int res;
-
- res = memcmp(data_, other.data_, std::min(size_, other.size_));
- if (res != 0)
- return res;
- if (size_ == other.size_)
- return res;
-
- return (size_ > other.size_) ? 1 : -1;
- }
-
- /* Optimization: If size not equal, string cannot be equal */
- bool operator ==(StringView other) const { return size_ == other.size_ && compare(other) == 0; }
- bool operator !=(StringView other) const { return !(*this == other); }
-
- /* Accessors */
- constexpr bool empty() const { return size_ == 0; }
- constexpr const char* data() const { return data_; }
- constexpr const char* begin() const { return data_; }
- constexpr const char* end() const { return data_ + size_; }
- constexpr char operator [](size_t i) const { return data_[i]; }
- constexpr size_t size() const { return size_; }
- constexpr size_t length() const { return size_; }
-
- inline constexpr operator std::string_view() const { return {data_, size_}; }
-};
-
-inline std::ostream& operator<<(std::ostream& os, const StringView& sv)
-{
- return os << static_cast<std::string_view>(sv);
-}
-
-static constexpr inline APT::StringView operator""_sv(const char *data, size_t size)
-{
- return APT::StringView(data, size);
-}
-}
-
-inline bool operator ==(const char *other, APT::StringView that);
-inline bool operator ==(const char *other, APT::StringView that) { return that.operator==(other); }
-template<class = void> bool operator ==(std::string_view const &other, APT::StringView const &that) { return that.operator==(other); }
-template<class = void> bool operator !=(std::string_view const &other, APT::StringView const &that) { return that.operator!=(other); }
-template<class = void> bool operator !=(APT::StringView const &that, std::string_view const &other) { return that.operator!=(other); }
-#endif
-
-#endif
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 375b5dbd6..e3041f848 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -563,25 +563,6 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
return res;
}
-#if APT_PKG_ABI <= 600
-const char *debListParser::ParseDepends(const char *Start,const char *Stop,
- APT::StringView &Package,APT::StringView &Ver,
- unsigned int &Op, bool ParseArchFlags,
- bool const StripMultiArch,
- bool const ParseRestrictionsList,
- string Arch)
-{
- string_view PackageView;
- string_view VerView;
-
- auto res = ParseDepends(Start, Stop, PackageView, VerView, Op, (bool)ParseArchFlags,
- (bool) StripMultiArch, (bool) ParseRestrictionsList, Arch);
- Package = PackageView;
- Ver = VerView;
-
- return res;
-}
-#endif
const char *debListParser::ParseDepends(const char *Start, const char *Stop,
string_view &Package, string_view &Ver,
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index aec09ed2e..27e900790 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -81,15 +81,6 @@ class APT_HIDDEN debListParser : public pkgCacheListParser
bool const &ParseRestrictionsList = false,
std::string const &Arch = "");
-#if APT_PKG_ABI <= 600
- [[deprecated("Use std::string_view variant instead")]]
- APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop,
- APT::StringView &Package,
- APT::StringView &Ver, unsigned int &Op,
- bool ParseArchFlags = false, bool StripMultiArch = true,
- bool ParseRestrictionsList = false,
- std::string Arch = "");
-#endif
APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop,
std::string_view &Package,
std::string_view &Ver, unsigned int &Op,
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index 3f477b9b1..2beef0e74 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -23,7 +23,6 @@
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/configuration.h>
-#include <apt-pkg/string_view.h>
#include <apt-pkg/error.h>
#include <apt-pkg/macros.h>
#include <apt-pkg/mmap.h>
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index dd79967c0..8c4a1c517 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -24,7 +24,7 @@
#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/progress.h>
#include <apt-pkg/sourcelist.h>
-#include <apt-pkg/string_view.h>
+#include <apt-pkg/strutl.h>
#include <apt-pkg/version.h>
#include <algorithm>