mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 06:52:43 +01: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
|
|
@ -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>;
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ struct DummyStoreConfig : virtual StoreConfig {
|
|||
;
|
||||
}
|
||||
|
||||
static std::set<std::string> uriSchemes() {
|
||||
static StringSet uriSchemes() {
|
||||
return {"dummy"};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ struct LocalOverlayStoreConfig : virtual LocalStoreConfig
|
|||
return ExperimentalFeature::LocalOverlayStore;
|
||||
}
|
||||
|
||||
static std::set<std::string> uriSchemes()
|
||||
static StringSet uriSchemes()
|
||||
{
|
||||
return { "local-overlay" };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public:
|
|||
return "S3 Binary Cache Store";
|
||||
}
|
||||
|
||||
static std::set<std::string> uriSchemes()
|
||||
static StringSet uriSchemes()
|
||||
{
|
||||
return {"s3"};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>`.
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ protected:
|
|||
static constexpr char const * scheme = "unix";
|
||||
|
||||
public:
|
||||
static std::set<std::string> uriSchemes()
|
||||
static StringSet uriSchemes()
|
||||
{ return {scheme}; }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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), ","));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue