diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-10-21 18:48:21 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-10-21 18:48:21 +0200 |
commit | 9a18f544ac09c3a40e9a87c166edd878a1368c6f (patch) | |
tree | 9a2dcd0d4545f46c2c3e3930239f9a503903db19 /src/libutil/util.hh | |
parent | b82f75464d1e5ae9a00d8004e5dd7b1ca05059e4 (diff) | |
parent | 629b9b0049363e091b76b7f60a8357d9f94733cc (diff) |
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r-- | src/libutil/util.hh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 814028442..30654e315 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -386,6 +386,20 @@ string replaceStrings(const std::string & s, const std::string & from, const std::string & to); +std::string rewriteStrings(const std::string & s, const StringMap & rewrites); + + +/* If a set contains 'from', remove it and insert 'to'. */ +template<typename T> +void replaceInSet(std::set<T> & set, const T & from, const T & to) +{ + auto i = set.find(from); + if (i == set.end()) return; + set.erase(i); + set.insert(to); +} + + /* Convert the exit status of a child as returned by wait() into an error string. */ string statusToString(int status); |