mirror of
https://github.com/NixOS/nix
synced 2025-07-05 08:11:47 +02:00
treewide: Use StringSet alias consistently instead of std::set<std::string>
The intention is to switch to transparent comparators from N3657 for ordered set containers for strings and using the alias consistently would simplify things.
This commit is contained in:
parent
a976a46ee8
commit
d8c97d8073
55 changed files with 111 additions and 109 deletions
|
@ -593,7 +593,7 @@ MultiCommand::MultiCommand(std::string_view commandName, const Commands & comman
|
|||
assert(!command);
|
||||
auto i = commands.find(s);
|
||||
if (i == commands.end()) {
|
||||
std::set<std::string> commandNames;
|
||||
StringSet commandNames;
|
||||
for (auto & [name, _] : commands)
|
||||
commandNames.insert(name);
|
||||
auto suggestions = Suggestions::bestMatches(commandNames, s);
|
||||
|
|
|
@ -220,7 +220,7 @@ void Config::convertToArgs(Args & args, const std::string & category)
|
|||
AbstractSetting::AbstractSetting(
|
||||
const std::string & name,
|
||||
const std::string & description,
|
||||
const std::set<std::string> & aliases,
|
||||
const StringSet & aliases,
|
||||
std::optional<ExperimentalFeature> experimentalFeature)
|
||||
: name(name)
|
||||
, description(stripIndentation(description))
|
||||
|
@ -428,7 +428,7 @@ PathSetting::PathSetting(Config * options,
|
|||
const Path & def,
|
||||
const std::string & name,
|
||||
const std::string & description,
|
||||
const std::set<std::string> & aliases)
|
||||
const StringSet & aliases)
|
||||
: BaseSetting<Path>(def, true, name, description, aliases)
|
||||
{
|
||||
options->addSetting(this);
|
||||
|
@ -444,7 +444,7 @@ OptionalPathSetting::OptionalPathSetting(Config * options,
|
|||
const std::optional<Path> & def,
|
||||
const std::string & name,
|
||||
const std::string & description,
|
||||
const std::set<std::string> & aliases)
|
||||
const StringSet & aliases)
|
||||
: BaseSetting<std::optional<Path>>(def, true, name, description, aliases)
|
||||
{
|
||||
options->addSetting(this);
|
||||
|
|
|
@ -358,7 +358,7 @@ nlohmann::json documentExperimentalFeatures()
|
|||
return (nlohmann::json) res;
|
||||
}
|
||||
|
||||
std::set<ExperimentalFeature> parseFeatures(const std::set<std::string> & rawFeatures)
|
||||
std::set<ExperimentalFeature> parseFeatures(const StringSet & rawFeatures)
|
||||
{
|
||||
std::set<ExperimentalFeature> res;
|
||||
for (auto & rawFeature : rawFeatures)
|
||||
|
|
|
@ -32,9 +32,9 @@ static size_t regularHashSize(HashAlgorithm type) {
|
|||
}
|
||||
|
||||
|
||||
const std::set<std::string> hashAlgorithms = {"blake3", "md5", "sha1", "sha256", "sha512" };
|
||||
const StringSet hashAlgorithms = {"blake3", "md5", "sha1", "sha256", "sha512" };
|
||||
|
||||
const std::set<std::string> hashFormats = {"base64", "nix32", "base16", "sri" };
|
||||
const StringSet hashFormats = {"base64", "nix32", "base16", "sri" };
|
||||
|
||||
Hash::Hash(HashAlgorithm algo, const ExperimentalFeatureSettings & xpSettings) : algo(algo)
|
||||
{
|
||||
|
|
|
@ -179,7 +179,7 @@ public:
|
|||
using ptr = std::shared_ptr<Flag>;
|
||||
|
||||
std::string longName;
|
||||
std::set<std::string> aliases;
|
||||
StringSet aliases;
|
||||
char shortName = 0;
|
||||
std::string description;
|
||||
std::string category;
|
||||
|
@ -263,7 +263,7 @@ protected:
|
|||
virtual Strings::iterator rewriteArgs(Strings & args, Strings::iterator pos)
|
||||
{ return pos; }
|
||||
|
||||
std::set<std::string> hiddenCategories;
|
||||
StringSet hiddenCategories;
|
||||
|
||||
/**
|
||||
* Called after all command line flags before the first non-flag
|
||||
|
|
|
@ -179,7 +179,7 @@ public:
|
|||
|
||||
const std::string name;
|
||||
const std::string description;
|
||||
const std::set<std::string> aliases;
|
||||
const StringSet aliases;
|
||||
|
||||
int created = 123;
|
||||
|
||||
|
@ -192,7 +192,7 @@ protected:
|
|||
AbstractSetting(
|
||||
const std::string & name,
|
||||
const std::string & description,
|
||||
const std::set<std::string> & aliases,
|
||||
const StringSet & aliases,
|
||||
std::optional<ExperimentalFeature> experimentalFeature = std::nullopt);
|
||||
|
||||
virtual ~AbstractSetting();
|
||||
|
@ -251,7 +251,7 @@ public:
|
|||
const bool documentDefault,
|
||||
const std::string & name,
|
||||
const std::string & description,
|
||||
const std::set<std::string> & aliases = {},
|
||||
const StringSet & aliases = {},
|
||||
std::optional<ExperimentalFeature> experimentalFeature = std::nullopt)
|
||||
: AbstractSetting(name, description, aliases, experimentalFeature)
|
||||
, value(def)
|
||||
|
@ -323,7 +323,7 @@ public:
|
|||
const T & def,
|
||||
const std::string & name,
|
||||
const std::string & description,
|
||||
const std::set<std::string> & aliases = {},
|
||||
const StringSet & aliases = {},
|
||||
const bool documentDefault = true,
|
||||
std::optional<ExperimentalFeature> experimentalFeature = std::nullopt)
|
||||
: BaseSetting<T>(def, documentDefault, name, description, aliases, std::move(experimentalFeature))
|
||||
|
@ -349,7 +349,7 @@ public:
|
|||
const Path & def,
|
||||
const std::string & name,
|
||||
const std::string & description,
|
||||
const std::set<std::string> & aliases = {});
|
||||
const StringSet & aliases = {});
|
||||
|
||||
Path parse(const std::string & str) const override;
|
||||
|
||||
|
@ -371,7 +371,7 @@ public:
|
|||
const std::optional<Path> & def,
|
||||
const std::string & name,
|
||||
const std::string & description,
|
||||
const std::set<std::string> & aliases = {});
|
||||
const StringSet & aliases = {});
|
||||
|
||||
std::optional<Path> parse(const std::string & str) const override;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ std::ostream & operator<<(
|
|||
* Parse a set of strings to the corresponding set of experimental
|
||||
* features, ignoring (but warning for) any unknown feature.
|
||||
*/
|
||||
std::set<ExperimentalFeature> parseFeatures(const std::set<std::string> &);
|
||||
std::set<ExperimentalFeature> parseFeatures(const StringSet &);
|
||||
|
||||
/**
|
||||
* An experimental feature was required for some (experimental)
|
||||
|
|
|
@ -20,7 +20,7 @@ const int sha1HashSize = 20;
|
|||
const int sha256HashSize = 32;
|
||||
const int sha512HashSize = 64;
|
||||
|
||||
extern const std::set<std::string> hashAlgorithms;
|
||||
extern const StringSet hashAlgorithms;
|
||||
|
||||
extern const std::string nix32Chars;
|
||||
|
||||
|
@ -40,7 +40,7 @@ enum struct HashFormat : int {
|
|||
SRI
|
||||
};
|
||||
|
||||
extern const std::set<std::string> hashFormats;
|
||||
extern const StringSet hashFormats;
|
||||
|
||||
struct Hash
|
||||
{
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "nix/util/types.hh"
|
||||
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <string_view>
|
||||
|
@ -30,7 +32,7 @@ template<class C>
|
|||
C tokenizeString(std::string_view s, std::string_view separators = " \t\n\r");
|
||||
|
||||
extern template std::list<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
extern template std::set<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
extern template StringSet tokenizeString(std::string_view s, std::string_view separators);
|
||||
extern template std::vector<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
|
||||
/**
|
||||
|
@ -44,7 +46,7 @@ template<typename C>
|
|||
C splitString(std::string_view s, std::string_view separators);
|
||||
|
||||
extern template std::list<std::string> splitString(std::string_view s, std::string_view separators);
|
||||
extern template std::set<std::string> splitString(std::string_view s, std::string_view separators);
|
||||
extern template StringSet splitString(std::string_view s, std::string_view separators);
|
||||
extern template std::vector<std::string> splitString(std::string_view s, std::string_view separators);
|
||||
|
||||
/**
|
||||
|
@ -54,7 +56,7 @@ template<class C>
|
|||
std::string concatStringsSep(const std::string_view sep, const C & ss);
|
||||
|
||||
extern template std::string concatStringsSep(std::string_view, const std::list<std::string> &);
|
||||
extern template std::string concatStringsSep(std::string_view, const std::set<std::string> &);
|
||||
extern template std::string concatStringsSep(std::string_view, const StringSet &);
|
||||
extern template std::string concatStringsSep(std::string_view, const std::vector<std::string> &);
|
||||
extern template std::string concatStringsSep(std::string_view, const boost::container::small_vector<std::string, 64> &);
|
||||
|
||||
|
@ -85,7 +87,7 @@ template<class C>
|
|||
dropEmptyInitThenConcatStringsSep(const std::string_view sep, const C & ss);
|
||||
|
||||
extern template std::string dropEmptyInitThenConcatStringsSep(std::string_view, const std::list<std::string> &);
|
||||
extern template std::string dropEmptyInitThenConcatStringsSep(std::string_view, const std::set<std::string> &);
|
||||
extern template std::string dropEmptyInitThenConcatStringsSep(std::string_view, const StringSet &);
|
||||
extern template std::string dropEmptyInitThenConcatStringsSep(std::string_view, const std::vector<std::string> &);
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
) const;
|
||||
|
||||
static Suggestions bestMatches (
|
||||
const std::set<std::string> & allMatches,
|
||||
const StringSet & allMatches,
|
||||
std::string_view query
|
||||
);
|
||||
|
||||
|
|
|
@ -26,18 +26,18 @@ __attribute__((no_sanitize("undefined"))) std::string_view toView(const std::ost
|
|||
}
|
||||
|
||||
template std::list<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
template std::set<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
template StringSet tokenizeString(std::string_view s, std::string_view separators);
|
||||
template std::vector<std::string> tokenizeString(std::string_view s, std::string_view separators);
|
||||
|
||||
template std::list<std::string> splitString(std::string_view s, std::string_view separators);
|
||||
template std::set<std::string> splitString(std::string_view s, std::string_view separators);
|
||||
template StringSet splitString(std::string_view s, std::string_view separators);
|
||||
template std::vector<std::string> splitString(std::string_view s, std::string_view separators);
|
||||
|
||||
template std::list<OsString>
|
||||
basicSplitString(std::basic_string_view<OsChar> s, std::basic_string_view<OsChar> separators);
|
||||
|
||||
template std::string concatStringsSep(std::string_view, const std::list<std::string> &);
|
||||
template std::string concatStringsSep(std::string_view, const std::set<std::string> &);
|
||||
template std::string concatStringsSep(std::string_view, const StringSet &);
|
||||
template std::string concatStringsSep(std::string_view, const std::vector<std::string> &);
|
||||
template std::string concatStringsSep(std::string_view, const boost::container::small_vector<std::string, 64> &);
|
||||
|
||||
|
@ -49,7 +49,7 @@ typedef std::string_view strings_4[4];
|
|||
template std::string concatStringsSep(std::string_view, const strings_4 &);
|
||||
|
||||
template std::string dropEmptyInitThenConcatStringsSep(std::string_view, const std::list<std::string> &);
|
||||
template std::string dropEmptyInitThenConcatStringsSep(std::string_view, const std::set<std::string> &);
|
||||
template std::string dropEmptyInitThenConcatStringsSep(std::string_view, const StringSet &);
|
||||
template std::string dropEmptyInitThenConcatStringsSep(std::string_view, const std::vector<std::string> &);
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,7 @@ int levenshteinDistance(std::string_view first, std::string_view second)
|
|||
}
|
||||
|
||||
Suggestions Suggestions::bestMatches (
|
||||
const std::set<std::string> & allMatches,
|
||||
const StringSet & allMatches,
|
||||
std::string_view query)
|
||||
{
|
||||
std::set<Suggestion> res;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue