mirror of
https://github.com/NixOS/nix.git
synced 2025-12-14 21:11:04 +01:00
Introduce OutputName and OutputNameView type aliases
Hopefully they make the code easier to understand!
This commit is contained in:
parent
0a6ac133cf
commit
2f5d3da806
11 changed files with 45 additions and 33 deletions
|
|
@ -13,24 +13,36 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
/**
|
||||
* An (owned) output name. Just a type alias used to make code more
|
||||
* readible.
|
||||
*/
|
||||
typedef std::string OutputName;
|
||||
|
||||
/**
|
||||
* A borrowed output name. Just a type alias used to make code more
|
||||
* readible.
|
||||
*/
|
||||
typedef std::string_view OutputNameView;
|
||||
|
||||
struct OutputsSpec {
|
||||
/**
|
||||
* A non-empty set of outputs, specified by name
|
||||
*/
|
||||
struct Names : std::set<std::string> {
|
||||
using std::set<std::string>::set;
|
||||
struct Names : std::set<OutputName> {
|
||||
using std::set<OutputName>::set;
|
||||
|
||||
/* These need to be "inherited manually" */
|
||||
|
||||
Names(const std::set<std::string> & s)
|
||||
: std::set<std::string>(s)
|
||||
Names(const std::set<OutputName> & s)
|
||||
: std::set<OutputName>(s)
|
||||
{ assert(!empty()); }
|
||||
|
||||
/**
|
||||
* Needs to be "inherited manually"
|
||||
*/
|
||||
Names(std::set<std::string> && s)
|
||||
: std::set<std::string>(s)
|
||||
Names(std::set<OutputName> && s)
|
||||
: std::set<OutputName>(s)
|
||||
{ assert(!empty()); }
|
||||
|
||||
/* This set should always be non-empty, so we delete this
|
||||
|
|
@ -57,7 +69,7 @@ struct OutputsSpec {
|
|||
*/
|
||||
OutputsSpec() = delete;
|
||||
|
||||
bool contains(const std::string & output) const;
|
||||
bool contains(const OutputName & output) const;
|
||||
|
||||
/**
|
||||
* Create a new OutputsSpec which is the union of this and that.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue