1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +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:
Sergei Zimmerman 2025-05-02 17:40:29 +00:00
parent a976a46ee8
commit d8c97d8073
No known key found for this signature in database
GPG key ID: A9B0B557CA632325
55 changed files with 111 additions and 109 deletions

View file

@ -42,7 +42,7 @@ static AutoCloseFD openSlotLock(const Machine & m, uint64_t slot)
return openLockFile(fmt("%s/%s-%d", currentLoad, escapeUri(m.storeUri.render()), slot), true);
}
static bool allSupportedLocally(Store & store, const std::set<std::string>& requiredFeatures) {
static bool allSupportedLocally(Store & store, const StringSet& requiredFeatures) {
for (auto & feature : requiredFeatures)
if (!store.systemFeatures.get().count(feature)) return false;
return true;
@ -113,7 +113,7 @@ static int main_build_remote(int argc, char * * argv)
auto amWilling = readInt(source);
auto neededSystem = readString(source);
drvPath = store->parseStorePath(readString(source));
auto requiredFeatures = readStrings<std::set<std::string>>(source);
auto requiredFeatures = readStrings<StringSet>(source);
/* It would be possible to build locally after some builds clear out,
so don't show the warning now: */

View file

@ -40,7 +40,7 @@ nlohmann::json NixMultiCommand::toJSON()
void NixMultiCommand::run()
{
if (!command) {
std::set<std::string> subCommandTextLines;
StringSet subCommandTextLines;
for (auto & [name, _] : commands)
subCommandTextLines.insert(fmt("- `%s`", name));
std::string markdownError =

View file

@ -363,7 +363,7 @@ void completeFlakeRefWithFragment(
const Strings & defaultFlakeAttrPaths,
std::string_view prefix);
std::string showVersions(const std::set<std::string> & versions);
std::string showVersions(const StringSet & versions);
void printClosureDiff(
ref<Store> store, const StorePath & beforePath, const StorePath & afterPath, std::string_view indent);

View file

@ -72,7 +72,7 @@ DerivedPathsWithInfo InstallableAttrPath::toDerivedPaths()
auto newOutputs = std::visit(overloaded {
[&](const ExtendedOutputsSpec::Default & d) -> OutputsSpec {
std::set<std::string> outputsToInstall;
StringSet outputsToInstall;
for (auto & output : packageInfo.queryOutputs(false, true))
outputsToInstall.insert(output.first);
if (outputsToInstall.empty())

View file

@ -117,7 +117,7 @@ DerivedPathsWithInfo InstallableFlake::toDerivedPaths()
.drvPath = makeConstantStorePathRef(std::move(drvPath)),
.outputs = std::visit(overloaded {
[&](const ExtendedOutputsSpec::Default & d) -> OutputsSpec {
std::set<std::string> outputsToInstall;
StringSet outputsToInstall;
if (auto aOutputSpecified = attr->maybeGetAttr(state->sOutputSpecified)) {
if (aOutputSpecified->getBool()) {
if (auto aOutputName = attr->maybeGetAttr("outputName"))

View file

@ -74,7 +74,7 @@ std::pair<Value *, PosIdx> findAlongAttrPath(EvalState & state, const std::strin
auto a = v->attrs()->get(state.symbols.create(attr));
if (!a) {
std::set<std::string> attrNames;
StringSet attrNames;
for (auto & attr : *v->attrs())
attrNames.insert(std::string(state.symbols[attr.name]));

View file

@ -492,7 +492,7 @@ Value & AttrCursor::forceValue()
Suggestions AttrCursor::getSuggestionsForAttr(Symbol name)
{
auto attrNames = getAttrs();
std::set<std::string> strAttrNames;
StringSet strAttrNames;
for (auto & name : attrNames)
strAttrNames.insert(std::string(root->state.symbols[name]));

View file

@ -1446,7 +1446,7 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
} else {
state.forceAttrs(*vAttrs, pos, "while selecting an attribute");
if (!(j = vAttrs->attrs()->get(name))) {
std::set<std::string> allAttrNames;
StringSet allAttrNames;
for (auto & attr : *vAttrs->attrs())
allAttrNames.insert(std::string(state.symbols[attr.name]));
auto suggestions = Suggestions::bestMatches(allAttrNames, state.symbols[name]);
@ -1603,7 +1603,7 @@ void EvalState::callFunction(Value & fun, std::span<Value *> args, Value & vRes,
user. */
for (auto & i : *args[0]->attrs())
if (!lambda.formals->has(i.name)) {
std::set<std::string> formalNames;
StringSet formalNames;
for (auto & formal : lambda.formals->formals)
formalNames.insert(std::string(symbols[formal.name]));
auto suggestions = Suggestions::bestMatches(formalNames, symbols[i.name]);

View file

@ -194,7 +194,7 @@ struct MercurialInputScheme : InputScheme
input.attrs.insert_or_assign("ref", chomp(runHg({ "branch", "-R", actualUrl })));
auto files = tokenizeString<std::set<std::string>>(
auto files = tokenizeString<StringSet>(
runHg({ "status", "-R", actualUrl, "--clean", "--modified", "--added", "--no-status", "--print0" }), "\0"s);
Path actualPath(absPath(actualUrl));

View file

@ -224,7 +224,7 @@ ref<SourceAccessor> downloadTarball(
// An input scheme corresponding to a curl-downloadable resource.
struct CurlInputScheme : InputScheme
{
const std::set<std::string> transportUrlSchemes = {"file", "http", "https"};
const StringSet transportUrlSchemes = {"file", "http", "https"};
bool hasTarballExtension(std::string_view path) const
{
@ -236,7 +236,7 @@ struct CurlInputScheme : InputScheme
virtual bool isValidURL(const ParsedURL & url, bool requireTree) const = 0;
static const std::set<std::string> specialParams;
static const StringSet specialParams;
std::optional<Input> inputFromURL(
const Settings & settings,

View file

@ -32,7 +32,7 @@ static void writeTrustedList(const TrustedList & trustedList)
void ConfigFile::apply(const Settings & flakeSettings)
{
std::set<std::string> whitelist{"bash-prompt", "bash-prompt-prefix", "bash-prompt-suffix", "flake-registry", "commit-lock-file-summary", "commit-lockfile-summary"};
StringSet whitelist{"bash-prompt", "bash-prompt-prefix", "bash-prompt-suffix", "flake-registry", "commit-lock-file-summary", "commit-lockfile-summary"};
for (auto & [name, value] : settings) {

View file

@ -323,7 +323,7 @@ static FlakeRef applySelfAttrs(
{
auto newRef(ref);
std::set<std::string> allowedAttrs{"submodules", "lfs"};
StringSet allowedAttrs{"submodules", "lfs"};
for (auto & attr : flake.selfAttrs) {
if (!allowedAttrs.contains(attr.first))

View file

@ -19,7 +19,7 @@ struct PluginFilesSetting : public BaseSetting<Paths>
const Paths & def,
const std::string & name,
const std::string & description,
const std::set<std::string> & aliases = {})
const StringSet & aliases = {})
: BaseSetting<Paths>(def, true, name, description, aliases)
{
options->addSetting(this);

View file

@ -154,7 +154,7 @@ CHARACTERIZATION_TEST(
CHARACTERIZATION_TEST(
set,
"set",
(std::tuple<std::set<std::string>, std::set<std::string>, std::set<std::string>, std::set<std::set<std::string>>> {
(std::tuple<StringSet, StringSet, StringSet, std::set<StringSet>> {
{ },
{ "" },
{ "", "foo", "bar" },

View file

@ -7,7 +7,7 @@
namespace nix {
TEST(OutputsSpec, no_empty_names) {
ASSERT_DEATH(OutputsSpec::Names { std::set<std::string> { } }, "");
ASSERT_DEATH(OutputsSpec::Names { StringSet { } }, "");
}
#define TEST_DONT_PARSE(NAME, STR) \

View file

@ -374,7 +374,7 @@ VERSIONED_CHARACTERIZATION_TEST(
set,
"set",
defaultVersion,
(std::tuple<std::set<std::string>, std::set<std::string>, std::set<std::string>, std::set<std::set<std::string>>> {
(std::tuple<StringSet, StringSet, StringSet, std::set<StringSet>> {
{ },
{ "" },
{ "", "foo", "bar" },

View file

@ -574,7 +574,7 @@ VERSIONED_CHARACTERIZATION_TEST(
set,
"set",
defaultVersion,
(std::tuple<std::set<std::string>, std::set<std::string>, std::set<std::string>, std::set<std::set<std::string>>> {
(std::tuple<StringSet, StringSet, StringSet, std::set<StringSet>> {
{ },
{ "" },
{ "", "foo", "bar" },

View file

@ -55,17 +55,17 @@ typename DerivedPathMap<V>::ChildNode * DerivedPathMap<V>::findSlot(const Single
namespace nix {
template<>
bool DerivedPathMap<std::set<std::string>>::ChildNode::operator == (
const DerivedPathMap<std::set<std::string>>::ChildNode &) const noexcept = default;
bool DerivedPathMap<StringSet>::ChildNode::operator == (
const DerivedPathMap<StringSet>::ChildNode &) const noexcept = default;
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
#if 0
template<>
std::strong_ordering DerivedPathMap<std::set<std::string>>::ChildNode::operator <=> (
const DerivedPathMap<std::set<std::string>>::ChildNode &) const noexcept = default;
std::strong_ordering DerivedPathMap<StringSet>::ChildNode::operator <=> (
const DerivedPathMap<StringSet>::ChildNode &) const noexcept = default;
#endif
template struct DerivedPathMap<std::set<std::string>>::ChildNode;
template struct DerivedPathMap<std::set<std::string>>;
template struct DerivedPathMap<StringSet>::ChildNode;
template struct DerivedPathMap<StringSet>;
};

View file

@ -22,7 +22,7 @@ struct DummyStoreConfig : virtual StoreConfig {
;
}
static std::set<std::string> uriSchemes() {
static StringSet uriSchemes() {
return {"dummy"};
}
};

View file

@ -91,20 +91,20 @@ struct DerivedPathMap {
};
template<>
bool DerivedPathMap<std::set<std::string>>::ChildNode::operator == (
const DerivedPathMap<std::set<std::string>>::ChildNode &) const noexcept;
bool DerivedPathMap<StringSet>::ChildNode::operator == (
const DerivedPathMap<StringSet>::ChildNode &) const noexcept;
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
#if 0
template<>
std::strong_ordering DerivedPathMap<std::set<std::string>>::ChildNode::operator <=> (
const DerivedPathMap<std::set<std::string>>::ChildNode &) const noexcept;
std::strong_ordering DerivedPathMap<StringSet>::ChildNode::operator <=> (
const DerivedPathMap<StringSet>::ChildNode &) const noexcept;
template<>
inline auto DerivedPathMap<std::set<std::string>>::operator <=> (const DerivedPathMap<std::set<std::string>> &) const noexcept = default;
inline auto DerivedPathMap<StringSet>::operator <=> (const DerivedPathMap<StringSet> &) const noexcept = default;
#endif
extern template struct DerivedPathMap<std::set<std::string>>::ChildNode;
extern template struct DerivedPathMap<std::set<std::string>>;
extern template struct DerivedPathMap<StringSet>::ChildNode;
extern template struct DerivedPathMap<StringSet>;
}

View file

@ -24,7 +24,7 @@ struct MaxBuildJobsSetting : public BaseSetting<unsigned int>
unsigned int def,
const std::string & name,
const std::string & description,
const std::set<std::string> & aliases = {})
const StringSet & aliases = {})
: BaseSetting<unsigned int>(def, true, name, description, aliases)
{
options->addSetting(this);

View file

@ -15,10 +15,10 @@ struct HttpBinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
return "HTTP Binary Cache Store";
}
static std::set<std::string> uriSchemes()
static StringSet uriSchemes()
{
static bool forceHttp = getEnv("_NIX_FORCE_HTTP") == "1";
auto ret = std::set<std::string>({"http", "https"});
auto ret = StringSet({"http", "https"});
if (forceHttp)
ret.insert("file");
return ret;

View file

@ -37,7 +37,7 @@ struct LegacySSHStoreConfig : virtual CommonSSHStoreConfig
const std::string name() override { return "SSH Store"; }
static std::set<std::string> uriSchemes() { return {"ssh"}; }
static StringSet uriSchemes() { return {"ssh"}; }
std::string doc() override;
};

View file

@ -15,7 +15,7 @@ struct LocalBinaryCacheStoreConfig : virtual BinaryCacheStoreConfig
return "Local Binary Cache Store";
}
static std::set<std::string> uriSchemes();
static StringSet uriSchemes();
std::string doc() override;
};

View file

@ -63,7 +63,7 @@ struct LocalOverlayStoreConfig : virtual LocalStoreConfig
return ExperimentalFeature::LocalOverlayStore;
}
static std::set<std::string> uriSchemes()
static StringSet uriSchemes()
{
return { "local-overlay" };
}

View file

@ -67,7 +67,7 @@ struct LocalStoreConfig : virtual LocalFSStoreConfig
const std::string name() override { return "Local Store"; }
static std::set<std::string> uriSchemes()
static StringSet uriSchemes()
{ return {"local"}; }
std::string doc() override;

View file

@ -15,12 +15,12 @@ typedef std::vector<Machine> Machines;
struct Machine {
const StoreReference storeUri;
const std::set<std::string> systemTypes;
const StringSet systemTypes;
const std::string sshKey;
const unsigned int maxJobs;
const float speedFactor;
const std::set<std::string> supportedFeatures;
const std::set<std::string> mandatoryFeatures;
const StringSet supportedFeatures;
const StringSet mandatoryFeatures;
const std::string sshPublicHostKey;
bool enabled = true;
@ -34,12 +34,12 @@ struct Machine {
* @return Whether `features` is a subset of the union of `supportedFeatures` and
* `mandatoryFeatures`.
*/
bool allSupported(const std::set<std::string> & features) const;
bool allSupported(const StringSet & features) const;
/**
* @return Whether `mandatoryFeatures` is a subset of `features`.
*/
bool mandatoryMet(const std::set<std::string> & features) const;
bool mandatoryMet(const StringSet & features) const;
Machine(
const std::string & storeUri,
@ -75,7 +75,7 @@ struct Machine {
* with `@` are interpreted as paths to other configuration files in
* the same format.
*/
static Machines parseConfig(const std::set<std::string> & defaultSystems, const std::string & config);
static Machines parseConfig(const StringSet & defaultSystems, const std::string & config);
};
/**

View file

@ -19,7 +19,7 @@ struct StoreDirConfig;
struct StorePathWithOutputs
{
StorePath path;
std::set<std::string> outputs;
StringSet outputs;
std::string to_string(const StoreDirConfig & store) const;

View file

@ -98,7 +98,7 @@ public:
return "S3 Binary Cache Store";
}
static std::set<std::string> uriSchemes()
static StringSet uriSchemes()
{
return {"s3"};
}

View file

@ -23,7 +23,7 @@ struct SSHStoreConfig : virtual RemoteStoreConfig, virtual CommonSSHStoreConfig
return "Experimental SSH Store";
}
static std::set<std::string> uriSchemes()
static StringSet uriSchemes()
{
return {"ssh-ng"};
}
@ -45,7 +45,7 @@ struct MountedSSHStoreConfig : virtual SSHStoreConfig, virtual LocalFSStoreConfi
return "Experimental SSH Store with filesystem mounted";
}
static std::set<std::string> uriSchemes()
static StringSet uriSchemes()
{
return {"mounted-ssh-ng"};
}

View file

@ -888,7 +888,7 @@ std::list<ref<Store>> getDefaultSubstituters();
struct StoreFactory
{
std::set<std::string> uriSchemes;
StringSet uriSchemes;
/**
* The `authorityPath` parameter is `<authority>/<path>`, or really
* whatever comes after `<scheme>://` and before `?<query-params>`.

View file

@ -38,7 +38,7 @@ protected:
static constexpr char const * scheme = "unix";
public:
static std::set<std::string> uriSchemes()
static StringSet uriSchemes()
{ return {scheme}; }
};

View file

@ -119,7 +119,7 @@ bool LocalBinaryCacheStore::fileExists(const std::string & path)
return pathExists(binaryCacheDir + "/" + path);
}
std::set<std::string> LocalBinaryCacheStoreConfig::uriSchemes()
StringSet LocalBinaryCacheStoreConfig::uriSchemes()
{
if (getEnv("_NIX_FORCE_HTTP") == "1")
return {};

View file

@ -535,7 +535,7 @@ void LocalStore::upgradeDBSchema(State & state)
{
state.db.exec("create table if not exists SchemaMigrations (migration text primary key not null);");
std::set<std::string> schemaMigrations;
StringSet schemaMigrations;
{
SQLiteStmt querySchemaMigrations;

View file

@ -47,7 +47,7 @@ bool Machine::systemSupported(const std::string & system) const
return system == "builtin" || (systemTypes.count(system) > 0);
}
bool Machine::allSupported(const std::set<std::string> & features) const
bool Machine::allSupported(const StringSet & features) const
{
return std::all_of(features.begin(), features.end(),
[&](const std::string & feature) {
@ -56,7 +56,7 @@ bool Machine::allSupported(const std::set<std::string> & features) const
});
}
bool Machine::mandatoryMet(const std::set<std::string> & features) const
bool Machine::mandatoryMet(const StringSet & features) const
{
return std::all_of(mandatoryFeatures.begin(), mandatoryFeatures.end(),
[&](const std::string & feature) {
@ -134,7 +134,7 @@ static std::vector<std::string> expandBuilderLines(const std::string & builders)
return result;
}
static Machine parseBuilderLine(const std::set<std::string> & defaultSystems, const std::string & line)
static Machine parseBuilderLine(const StringSet & defaultSystems, const std::string & line)
{
const auto tokens = tokenizeString<std::vector<std::string>>(line);
@ -178,7 +178,7 @@ static Machine parseBuilderLine(const std::set<std::string> & defaultSystems, co
// `storeUri`
tokens[0],
// `systemTypes`
isSet(1) ? tokenizeString<std::set<std::string>>(tokens[1], ",") : defaultSystems,
isSet(1) ? tokenizeString<StringSet>(tokens[1], ",") : defaultSystems,
// `sshKey`
isSet(2) ? tokens[2] : "",
// `maxJobs`
@ -186,15 +186,15 @@ static Machine parseBuilderLine(const std::set<std::string> & defaultSystems, co
// `speedFactor`
isSet(4) ? parseFloatField(4) : 1.0f,
// `supportedFeatures`
isSet(5) ? tokenizeString<std::set<std::string>>(tokens[5], ",") : std::set<std::string>{},
isSet(5) ? tokenizeString<StringSet>(tokens[5], ",") : StringSet{},
// `mandatoryFeatures`
isSet(6) ? tokenizeString<std::set<std::string>>(tokens[6], ",") : std::set<std::string>{},
isSet(6) ? tokenizeString<StringSet>(tokens[6], ",") : StringSet{},
// `sshPublicHostKey`
isSet(7) ? ensureBase64(7) : ""
};
}
static Machines parseBuilderLines(const std::set<std::string> & defaultSystems, const std::vector<std::string> & builders)
static Machines parseBuilderLines(const StringSet & defaultSystems, const std::vector<std::string> & builders)
{
Machines result;
std::transform(
@ -203,7 +203,7 @@ static Machines parseBuilderLines(const std::set<std::string> & defaultSystems,
return result;
}
Machines Machine::parseConfig(const std::set<std::string> & defaultSystems, const std::string & s)
Machines Machine::parseConfig(const StringSet & defaultSystems, const std::string & s)
{
const auto builderLines = expandBuilderLines(s);
return parseBuilderLines(defaultSystems, builderLines);

View file

@ -82,9 +82,9 @@ std::pair<std::string_view, StringSet> parsePathWithOutputs(std::string_view s)
{
size_t n = s.find("!");
return n == s.npos
? std::make_pair(s, std::set<std::string>())
? std::make_pair(s, StringSet())
: std::make_pair(s.substr(0, n),
tokenizeString<std::set<std::string>>(s.substr(n + 1), ","));
tokenizeString<StringSet>(s.substr(n + 1), ","));
}

View file

@ -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);

View file

@ -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);

View file

@ -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)

View file

@ -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)
{

View file

@ -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

View file

@ -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;

View file

@ -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)

View file

@ -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
{

View file

@ -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> &);
/**

View file

@ -35,7 +35,7 @@ public:
) const;
static Suggestions bestMatches (
const std::set<std::string> & allMatches,
const StringSet & allMatches,
std::string_view query
);

View file

@ -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> &);
/**

View file

@ -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;

View file

@ -147,7 +147,7 @@ static void main_nix_build(int argc, char * * argv)
std::string outLink = "./result";
// List of environment variables kept for --pure
std::set<std::string> keepVars{
StringSet keepVars{
"HOME", "XDG_RUNTIME_DIR", "USER", "LOGNAME", "DISPLAY",
"WAYLAND_DISPLAY", "WAYLAND_SOCKET", "PATH", "TERM", "IN_NIX_SHELL",
"NIX_SHELL_PRESERVE_PROMPT", "TZ", "PAGER", "NIX_BUILD_SHELL", "SHLVL",

View file

@ -238,9 +238,9 @@ static void checkSelectorUse(DrvNames & selectors)
namespace {
std::set<std::string> searchByPrefix(const PackageInfos & allElems, std::string_view prefix) {
StringSet searchByPrefix(const PackageInfos & allElems, std::string_view prefix) {
constexpr std::size_t maxResults = 3;
std::set<std::string> result;
StringSet result;
for (const auto & packageInfo : allElems) {
const auto drvName = DrvName { packageInfo.queryName() };
if (hasPrefix(drvName.name, prefix)) {

View file

@ -67,7 +67,7 @@ struct BuildEnvironment
{
BuildEnvironment res;
std::set<std::string> exported;
StringSet exported;
for (auto & [name, info] : json["variables"].items()) {
std::string type = info["type"];
@ -151,7 +151,7 @@ struct BuildEnvironment
return structuredAttrs->second;
}
void toBash(std::ostream & out, const std::set<std::string> & ignoreVars) const
void toBash(std::ostream & out, const StringSet & ignoreVars) const
{
for (auto & [name, value] : vars) {
if (!ignoreVars.count(name)) {
@ -308,7 +308,7 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
struct Common : InstallableCommand, MixProfile
{
std::set<std::string> ignoreVars{
StringSet ignoreVars{
"BASHOPTS",
"HOME", // FIXME: don't ignore in pure mode?
"NIX_BUILD_TOP",

View file

@ -47,10 +47,10 @@ GroupedPaths getClosureInfo(ref<Store> store, const StorePath & toplevel)
return groupedPaths;
}
std::string showVersions(const std::set<std::string> & versions)
std::string showVersions(const StringSet & versions)
{
if (versions.empty()) return "";
std::set<std::string> versions2;
StringSet versions2;
for (auto & version : versions)
versions2.insert(version.empty() ? "ε" : version);
return concatStringsSep(", ", versions2);
@ -65,7 +65,7 @@ void printClosureDiff(
auto beforeClosure = getClosureInfo(store, beforePath);
auto afterClosure = getClosureInfo(store, afterPath);
std::set<std::string> allNames;
StringSet allNames;
for (auto & [name, _] : beforeClosure) allNames.insert(name);
for (auto & [name, _] : afterClosure) allNames.insert(name);
@ -87,11 +87,11 @@ void printClosureDiff(
auto sizeDelta = (int64_t) afterSize - (int64_t) beforeSize;
auto showDelta = std::abs(sizeDelta) >= 8 * 1024;
std::set<std::string> removed, unchanged;
StringSet removed, unchanged;
for (auto & [version, _] : beforeVersions)
if (!afterVersions.count(version)) removed.insert(version); else unchanged.insert(version);
std::set<std::string> added;
StringSet added;
for (auto & [version, _] : afterVersions)
if (!beforeVersions.count(version)) added.insert(version);

View file

@ -386,7 +386,7 @@ struct CmdFlakeCheck : FlakeCommand
}
};
std::set<std::string> omittedSystems;
StringSet omittedSystems;
// FIXME: rewrite to use EvalCache.

View file

@ -67,7 +67,7 @@ struct ProfileElement
* Return a string representing an installable corresponding to the current
* element, either a flakeref or a plain store path
*/
std::set<std::string> toInstallables(Store & store)
StringSet toInstallables(Store & store)
{
if (source)
return {source->to_string()};
@ -600,7 +600,7 @@ public:
});
}
std::set<std::string> getMatchingElementNames(ProfileManifest & manifest) {
StringSet getMatchingElementNames(ProfileManifest & manifest) {
if (_matchers.empty()) {
throw UsageError("No packages specified.");
}
@ -614,7 +614,7 @@ public:
return {};
}
std::set<std::string> result;
StringSet result;
for (auto & matcher : _matchers) {
bool foundMatch = false;
for (auto & [name, element] : manifest.elements) {

View file

@ -193,7 +193,7 @@ struct CmdWhyDepends : SourceExprCommand, MixOperateOnOptions
/* Sort the references by distance to `dependency` to
ensure that the shortest path is printed first. */
std::multimap<size_t, Node *> refs;
std::set<std::string> hashes;
StringSet hashes;
for (auto & ref : node.refs) {
if (ref == node.path && packagePath != dependencyPath) continue;