mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
Use StringMap
instead of std::map<std::string, std::string>
throughout the codebase
This commit is contained in:
parent
8c10104e9e
commit
8ee513379a
26 changed files with 37 additions and 37 deletions
|
@ -336,7 +336,7 @@ struct MixEnvironment : virtual Args
|
|||
|
||||
StringSet keepVars;
|
||||
StringSet unsetVars;
|
||||
std::map<std::string, std::string> setVars;
|
||||
StringMap setVars;
|
||||
bool ignoreEnvironment;
|
||||
|
||||
MixEnvironment();
|
||||
|
|
|
@ -89,9 +89,9 @@ bool getBoolAttr(const Attrs & attrs, const std::string & name)
|
|||
return *s;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> attrsToQuery(const Attrs & attrs)
|
||||
StringMap attrsToQuery(const Attrs & attrs)
|
||||
{
|
||||
std::map<std::string, std::string> query;
|
||||
StringMap query;
|
||||
for (auto & attr : attrs) {
|
||||
if (auto v = std::get_if<uint64_t>(&attr.second)) {
|
||||
query.insert_or_assign(attr.first, fmt("%d", *v));
|
||||
|
|
|
@ -134,7 +134,7 @@ ParsedURL Input::toURL() const
|
|||
return scheme->toURL(*this);
|
||||
}
|
||||
|
||||
std::string Input::toURLString(const std::map<std::string, std::string> & extraQuery) const
|
||||
std::string Input::toURLString(const StringMap & extraQuery) const
|
||||
{
|
||||
auto url = toURL();
|
||||
for (auto & attr : extraQuery)
|
||||
|
|
|
@ -368,7 +368,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
|
|||
if (git_config_iterator_glob_new(Setter(it), config.get(), "^submodule\\..*\\.(path|url|branch)$"))
|
||||
throw Error("iterating over .gitmodules: %s", git_error_last()->message);
|
||||
|
||||
std::map<std::string, std::string> entries;
|
||||
StringMap entries;
|
||||
|
||||
while (true) {
|
||||
git_config_entry * entry = nullptr;
|
||||
|
|
|
@ -37,7 +37,7 @@ std::optional<bool> maybeGetBoolAttr(const Attrs & attrs, const std::string & na
|
|||
|
||||
bool getBoolAttr(const Attrs & attrs, const std::string & name);
|
||||
|
||||
std::map<std::string, std::string> attrsToQuery(const Attrs & attrs);
|
||||
StringMap attrsToQuery(const Attrs & attrs);
|
||||
|
||||
Hash getRevAttr(const Attrs & attrs, const std::string & name);
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
|
||||
ParsedURL toURL() const;
|
||||
|
||||
std::string toURLString(const std::map<std::string, std::string> & extraQuery = {}) const;
|
||||
std::string toURLString(const StringMap & extraQuery = {}) const;
|
||||
|
||||
std::string to_string() const;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ const static std::string subDirRegex = subDirElemRegex + "(?:/" + subDirElemRege
|
|||
|
||||
std::string FlakeRef::to_string() const
|
||||
{
|
||||
std::map<std::string, std::string> extraQuery;
|
||||
StringMap extraQuery;
|
||||
if (subdir != "")
|
||||
extraQuery.insert_or_assign("dir", subdir);
|
||||
return input.toURLString(extraQuery);
|
||||
|
|
|
@ -974,7 +974,7 @@ void runPostBuildHook(
|
|||
fmt("running post-build-hook '%s'", settings.postBuildHook),
|
||||
Logger::Fields{store.printStorePath(drvPath)});
|
||||
PushActivity pact(act.id);
|
||||
std::map<std::string, std::string> hookEnvironment = getEnv();
|
||||
StringMap hookEnvironment = getEnv();
|
||||
|
||||
hookEnvironment.emplace("DRV_PATH", store.printStorePath(drvPath));
|
||||
hookEnvironment.emplace("OUT_PATHS", chomp(concatStringsSep(" ", store.printStorePathSet(outputPaths))));
|
||||
|
|
|
@ -125,7 +125,7 @@ struct StoreDirConfigBase : Config
|
|||
*/
|
||||
struct StoreDirConfig : StoreDirConfigBase, MixStoreDirMethods
|
||||
{
|
||||
using Params = std::map<std::string, std::string>;
|
||||
using Params = StringMap;
|
||||
|
||||
StoreDirConfig(const Params & params);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace nix {
|
|||
*/
|
||||
struct StoreReference
|
||||
{
|
||||
using Params = std::map<std::string, std::string>;
|
||||
using Params = StringMap;
|
||||
|
||||
/**
|
||||
* Special store reference `""` or `"auto"`
|
||||
|
|
|
@ -96,7 +96,7 @@ Realisation Realisation::fromJSON(
|
|||
|
||||
std::map <DrvOutput, StorePath> dependentRealisations;
|
||||
if (auto jsonDependencies = json.find("dependentRealisations"); jsonDependencies != json.end())
|
||||
for (auto & [jsonDepId, jsonDepOutPath] : jsonDependencies->get<std::map<std::string, std::string>>())
|
||||
for (auto & [jsonDepId, jsonDepOutPath] : jsonDependencies->get<StringMap>())
|
||||
dependentRealisations.insert({DrvOutput::parse(jsonDepId), StorePath(jsonDepOutPath)});
|
||||
|
||||
return Realisation{
|
||||
|
|
|
@ -83,7 +83,7 @@ bool SSHMaster::isMasterRunning() {
|
|||
Strings createSSHEnv()
|
||||
{
|
||||
// Copy the environment and set SHELL=/bin/sh
|
||||
std::map<std::string, std::string> env = getEnv();
|
||||
StringMap env = getEnv();
|
||||
|
||||
// SSH will invoke the "user" shell for -oLocalCommand, but that means
|
||||
// $SHELL. To keep things simple and avoid potential issues with other
|
||||
|
|
|
@ -187,7 +187,7 @@ private:
|
|||
typedef std::map<Path, ChrootPath> PathsInChroot; // maps target path to source path
|
||||
PathsInChroot pathsInChroot;
|
||||
|
||||
typedef std::map<std::string, std::string> Environment;
|
||||
typedef StringMap Environment;
|
||||
Environment env;
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,7 +106,7 @@ TEST(concatMapStringsSep, two)
|
|||
|
||||
TEST(concatMapStringsSep, map)
|
||||
{
|
||||
std::map<std::string, std::string> strings;
|
||||
StringMap strings;
|
||||
strings["this"] = "that";
|
||||
strings["1"] = "one";
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ namespace nix {
|
|||
|
||||
/* ----------- tests for url.hh --------------------------------------------------*/
|
||||
|
||||
std::string print_map(std::map<std::string, std::string> m) {
|
||||
std::map<std::string, std::string>::iterator it;
|
||||
std::string print_map(StringMap m) {
|
||||
StringMap::iterator it;
|
||||
std::string s = "{ ";
|
||||
for (it = m.begin(); it != m.end(); ++it) {
|
||||
s += "{ ";
|
||||
|
|
|
@ -72,7 +72,7 @@ void SourceAccessor::dumpPath(
|
|||
|
||||
/* If we're on a case-insensitive system like macOS, undo
|
||||
the case hack applied by restorePath(). */
|
||||
std::map<std::string, std::string> unhacked;
|
||||
StringMap unhacked;
|
||||
for (auto & i : readDirectory(path))
|
||||
if (archiveSettings.useCaseHack) {
|
||||
std::string name(i.first);
|
||||
|
|
|
@ -21,9 +21,9 @@ std::optional<std::string> getEnvNonEmpty(const std::string & key)
|
|||
return value;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> getEnv()
|
||||
StringMap getEnv()
|
||||
{
|
||||
std::map<std::string, std::string> env;
|
||||
StringMap env;
|
||||
for (size_t i = 0; environ[i]; ++i) {
|
||||
auto s = environ[i];
|
||||
auto eq = strchr(s, '=');
|
||||
|
@ -41,7 +41,7 @@ void clearEnv()
|
|||
unsetenv(name.first.c_str());
|
||||
}
|
||||
|
||||
void replaceEnv(const std::map<std::string, std::string> & newEnv)
|
||||
void replaceEnv(const StringMap & newEnv)
|
||||
{
|
||||
clearEnv();
|
||||
for (auto & newEnvVar : newEnv)
|
||||
|
|
|
@ -34,7 +34,7 @@ std::optional<std::string> getEnvNonEmpty(const std::string & key);
|
|||
/**
|
||||
* Get the entire environment.
|
||||
*/
|
||||
std::map<std::string, std::string> getEnv();
|
||||
StringMap getEnv();
|
||||
|
||||
#ifdef _WIN32
|
||||
/**
|
||||
|
@ -64,6 +64,6 @@ void clearEnv();
|
|||
/**
|
||||
* Replace the entire environment with the given one.
|
||||
*/
|
||||
void replaceEnv(const std::map<std::string, std::string> & newEnv);
|
||||
void replaceEnv(const StringMap & newEnv);
|
||||
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ struct RunOptions
|
|||
std::optional<uid_t> gid;
|
||||
#endif
|
||||
std::optional<Path> chdir;
|
||||
std::optional<std::map<std::string, std::string>> environment;
|
||||
std::optional<StringMap> environment;
|
||||
std::optional<std::string> input;
|
||||
Source * standardIn = nullptr;
|
||||
Sink * standardOut = nullptr;
|
||||
|
|
|
@ -10,7 +10,7 @@ struct ParsedURL
|
|||
std::string scheme;
|
||||
std::optional<std::string> authority;
|
||||
std::string path;
|
||||
std::map<std::string, std::string> query;
|
||||
StringMap query;
|
||||
std::string fragment;
|
||||
|
||||
std::string to_string() const;
|
||||
|
@ -30,9 +30,9 @@ MakeError(BadURL, Error);
|
|||
std::string percentDecode(std::string_view in);
|
||||
std::string percentEncode(std::string_view s, std::string_view keep="");
|
||||
|
||||
std::map<std::string, std::string> decodeQuery(const std::string & query);
|
||||
StringMap decodeQuery(const std::string & query);
|
||||
|
||||
std::string encodeQuery(const std::map<std::string, std::string> & query);
|
||||
std::string encodeQuery(const StringMap & query);
|
||||
|
||||
ParsedURL parseURL(const std::string & url);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
namespace nix {
|
||||
|
||||
|
||||
typedef std::map<std::string, std::string> XMLAttrs;
|
||||
typedef std::map<std::string, std::string, std::less<>> XMLAttrs;
|
||||
|
||||
|
||||
class XMLWriter
|
||||
|
|
|
@ -31,9 +31,9 @@ std::optional<Path> getCgroupFS()
|
|||
}
|
||||
|
||||
// FIXME: obsolete, check for cgroup2
|
||||
std::map<std::string, std::string> getCgroups(const Path & cgroupFile)
|
||||
StringMap getCgroups(const Path & cgroupFile)
|
||||
{
|
||||
std::map<std::string, std::string> cgroups;
|
||||
StringMap cgroups;
|
||||
|
||||
for (auto & line : tokenizeString<std::vector<std::string>>(readFile(cgroupFile), "\n")) {
|
||||
static std::regex regex("([0-9]+):([^:]*):(.*)");
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace nix {
|
|||
|
||||
std::optional<Path> getCgroupFS();
|
||||
|
||||
std::map<std::string, std::string> getCgroups(const Path & cgroupFile);
|
||||
StringMap getCgroups(const Path & cgroupFile);
|
||||
|
||||
struct CgroupStats
|
||||
{
|
||||
|
|
|
@ -70,9 +70,9 @@ std::string percentDecode(std::string_view in)
|
|||
return decoded;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> decodeQuery(const std::string & query)
|
||||
StringMap decodeQuery(const std::string & query)
|
||||
{
|
||||
std::map<std::string, std::string> result;
|
||||
StringMap result;
|
||||
|
||||
for (const auto & s : tokenizeString<Strings>(query, "&")) {
|
||||
auto e = s.find('=');
|
||||
|
@ -108,7 +108,7 @@ std::string percentEncode(std::string_view s, std::string_view keep)
|
|||
return res;
|
||||
}
|
||||
|
||||
std::string encodeQuery(const std::map<std::string, std::string> & ss)
|
||||
std::string encodeQuery(const StringMap & ss)
|
||||
{
|
||||
std::string res;
|
||||
bool first = true;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
typedef std::map<std::string, std::string> Channels;
|
||||
typedef StringMap Channels;
|
||||
|
||||
static Channels channels;
|
||||
static std::filesystem::path channelsList;
|
||||
|
|
|
@ -55,12 +55,12 @@ struct BuildEnvironment
|
|||
|
||||
using Array = std::vector<std::string>;
|
||||
|
||||
using Associative = std::map<std::string, std::string>;
|
||||
using Associative = StringMap;
|
||||
|
||||
using Value = std::variant<String, Array, Associative>;
|
||||
|
||||
std::map<std::string, Value> vars;
|
||||
std::map<std::string, std::string> bashFunctions;
|
||||
StringMap bashFunctions;
|
||||
std::optional<std::pair<std::string, std::string>> structuredAttrs;
|
||||
|
||||
static BuildEnvironment fromJSON(const nlohmann::json & json)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue