Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
store-reference.hh
Go to the documentation of this file.
1
#pragma once
3
4
#include <variant>
5
6
#include "
nix/util/types.hh
"
7
#include "
nix/util/configuration.hh
"
8
#include "
nix/util/json-impls.hh
"
9
#include "
nix/util/json-non-null.hh
"
10
11
namespace
nix {
12
45
struct
StoreReference
46
{
47
using
Params =
StringMap
;
48
52
struct
Auto
53
{
54
inline
bool
operator==(
const
Auto
& rhs)
const
=
default
;
55
inline
auto
operator<=>(
const
Auto
& rhs)
const
=
default
;
56
};
57
62
struct
Specified
63
{
64
std::string scheme;
65
std::string authority =
""
;
66
67
bool
operator==(
const
Specified
& rhs)
const
=
default
;
68
auto
operator<=>(
const
Specified
& rhs)
const
=
default
;
69
};
70
74
struct
Daemon :
Specified
75
{
76
Daemon()
77
:
Specified
({.scheme =
"unix"
})
78
{
79
}
80
};
81
85
struct
Local :
Specified
86
{
87
Local()
88
:
Specified
({.scheme =
"local"
})
89
{
90
}
91
};
92
93
typedef
std::variant<Auto, Specified, Daemon, Local> Variant;
94
95
Variant variant;
96
97
Params params;
98
99
bool
operator==(
const
StoreReference & rhs)
const
=
default
;
100
auto
operator<=>(
const
StoreReference & rhs)
const
=
default
;
101
105
std::string
render
(
bool
withParams =
true
)
const
;
106
107
std::string to_string()
const
108
{
109
return
render
();
110
}
111
115
static
StoreReference parse(
const
std::string & uri,
const
Params & extraParams = Params{});
116
};
117
118
static
inline
std::ostream & operator<<(std::ostream & os,
const
StoreReference &
ref
)
119
{
120
return
os <<
ref
.render();
121
}
122
126
std::pair<std::string, StoreReference::Params>
splitUriAndParams
(
const
std::string & uri);
127
128
template
<>
129
struct
json_avoids_null<StoreReference> : std::true_type
130
{};
131
132
NIX_DECLARE_CONFIG_SERIALISER(StoreReference)
133
NIX_DECLARE_CONFIG_SERIALISER(std::vector<StoreReference>)
134
NIX_DECLARE_CONFIG_SERIALISER(std::set<StoreReference>)
135
136
}
// namespace nix
137
138
JSON_IMPL(nix::StoreReference)
nix::ref
Definition
ref.hh:58
configuration.hh
json-impls.hh
json-non-null.hh
nix::splitUriAndParams
std::pair< std::string, StoreReference::Params > splitUriAndParams(const std::string &uri)
Definition
store-reference.cc:176
nix::render
std::string render(bool withParams=true) const
nix::Auto
Definition
store-reference.hh:53
nix::Specified
Definition
store-reference.hh:63
types.hh
nix::StringMap
std::map< std::string, std::string, std::less<> > StringMap
Definition
types.hh:26
libstore
include
nix
store
store-reference.hh
Generated by
1.18.0