mirror of
https://github.com/NixOS/nix
synced 2025-06-28 13:41:15 +02:00
Remove std::string alias (for real this time)
Also use std::string_view in a few more places.
This commit is contained in:
parent
14b38d0887
commit
df552ff53e
110 changed files with 773 additions and 681 deletions
|
@ -10,37 +10,35 @@ using std::cout;
|
|||
namespace nix {
|
||||
|
||||
|
||||
static string dotQuote(std::string_view s)
|
||||
static std::string dotQuote(std::string_view s)
|
||||
{
|
||||
return "\"" + std::string(s) + "\"";
|
||||
}
|
||||
|
||||
|
||||
static string nextColour()
|
||||
static const std::string & nextColour()
|
||||
{
|
||||
static int n = 0;
|
||||
static string colours[] =
|
||||
static std::vector<std::string> colours
|
||||
{ "black", "red", "green", "blue"
|
||||
, "magenta", "burlywood" };
|
||||
return colours[n++ % (sizeof(colours) / sizeof(string))];
|
||||
return colours[n++ % colours.size()];
|
||||
}
|
||||
|
||||
|
||||
static string makeEdge(const string & src, const string & dst)
|
||||
static std::string makeEdge(std::string_view src, std::string_view dst)
|
||||
{
|
||||
format f = format("%1% -> %2% [color = %3%];\n")
|
||||
% dotQuote(src) % dotQuote(dst) % dotQuote(nextColour());
|
||||
return f.str();
|
||||
return fmt("%1% -> %2% [color = %3%];\n",
|
||||
dotQuote(src), dotQuote(dst), dotQuote(nextColour()));
|
||||
}
|
||||
|
||||
|
||||
static string makeNode(const string & id, std::string_view label,
|
||||
const string & colour)
|
||||
static std::string makeNode(std::string_view id, std::string_view label,
|
||||
std::string_view colour)
|
||||
{
|
||||
format f = format("%1% [label = %2%, shape = box, "
|
||||
"style = filled, fillcolor = %3%];\n")
|
||||
% dotQuote(id) % dotQuote(label) % dotQuote(colour);
|
||||
return f.str();
|
||||
return fmt("%1% [label = %2%, shape = box, "
|
||||
"style = filled, fillcolor = %3%];\n",
|
||||
dotQuote(id), dotQuote(label), dotQuote(colour));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,20 +19,20 @@ static inline std::string_view xmlQuote(std::string_view s)
|
|||
}
|
||||
|
||||
|
||||
static string symbolicName(const std::string & p)
|
||||
static std::string symbolicName(std::string_view p)
|
||||
{
|
||||
return string(p, p.find('-') + 1);
|
||||
return std::string(p.substr(0, p.find('-') + 1));
|
||||
}
|
||||
|
||||
|
||||
static string makeEdge(std::string_view src, std::string_view dst)
|
||||
static std::string makeEdge(std::string_view src, std::string_view dst)
|
||||
{
|
||||
return fmt(" <edge source=\"%1%\" target=\"%2%\"/>\n",
|
||||
xmlQuote(src), xmlQuote(dst));
|
||||
}
|
||||
|
||||
|
||||
static string makeNode(const ValidPathInfo & info)
|
||||
static std::string makeNode(const ValidPathInfo & info)
|
||||
{
|
||||
return fmt(
|
||||
" <node id=\"%1%\">\n"
|
||||
|
|
|
@ -208,8 +208,8 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs)
|
|||
|
||||
Strings::iterator i = opArgs.begin();
|
||||
HashType hashAlgo = parseHashType(*i++);
|
||||
string hash = *i++;
|
||||
string name = *i++;
|
||||
std::string hash = *i++;
|
||||
std::string name = *i++;
|
||||
|
||||
cout << fmt("%s\n", store->printStorePath(store->makeFixedOutputPath(recursive, Hash::parseAny(hash, hashAlgo), name)));
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ static StorePathSet maybeUseOutputs(const StorePath & storePath, bool useOutput,
|
|||
graph. Topological sorting is used to keep the tree relatively
|
||||
flat. */
|
||||
static void printTree(const StorePath & path,
|
||||
const string & firstPad, const string & tailPad, StorePathSet & done)
|
||||
const std::string & firstPad, const std::string & tailPad, StorePathSet & done)
|
||||
{
|
||||
if (!done.insert(path).second) {
|
||||
cout << fmt("%s%s [...]\n", firstPad, store->printStorePath(path));
|
||||
|
@ -277,7 +277,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
|
|||
bool useOutput = false;
|
||||
bool includeOutputs = false;
|
||||
bool forceRealise = false;
|
||||
string bindingName;
|
||||
std::string bindingName;
|
||||
|
||||
for (auto & i : opFlags) {
|
||||
QueryType prev = query;
|
||||
|
@ -637,7 +637,7 @@ static void opDump(Strings opFlags, Strings opArgs)
|
|||
if (opArgs.size() != 1) throw UsageError("only one argument allowed");
|
||||
|
||||
FdSink sink(STDOUT_FILENO);
|
||||
string path = *opArgs.begin();
|
||||
std::string path = *opArgs.begin();
|
||||
dumpPath(path, sink);
|
||||
sink.flush();
|
||||
}
|
||||
|
@ -975,9 +975,9 @@ static void opGenerateBinaryCacheKey(Strings opFlags, Strings opArgs)
|
|||
|
||||
if (opArgs.size() != 3) throw UsageError("three arguments expected");
|
||||
auto i = opArgs.begin();
|
||||
string keyName = *i++;
|
||||
string secretKeyFile = *i++;
|
||||
string publicKeyFile = *i++;
|
||||
std::string keyName = *i++;
|
||||
std::string secretKeyFile = *i++;
|
||||
std::string publicKeyFile = *i++;
|
||||
|
||||
auto secretKey = SecretKey::generate(keyName);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue