Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
path.hh
Go to the documentation of this file.
1#pragma once
3
4#include <string_view>
5#include <string>
6
7#include "lix/libutil/types.hh" // IWYU pragma: keep
8
9namespace nix {
10
11struct Hash;
12
20class StorePath
21{
22 std::string baseName;
23
24public:
25
29 constexpr static size_t HashLen = 32; // i.e. 160 bits
30
31 constexpr static size_t MaxPathLen = 211;
32
33 StorePath() = delete;
34
35 StorePath(std::string_view baseName);
36
37 StorePath(const Hash & hash, std::string_view name);
38
39 std::string_view to_string() const
40 {
41 return baseName;
42 }
43
44 bool operator < (const StorePath & other) const
45 {
46 return baseName < other.baseName;
47 }
48
49 bool operator == (const StorePath & other) const
50 {
51 return baseName == other.baseName;
52 }
53
54 bool operator != (const StorePath & other) const
55 {
56 return baseName != other.baseName;
57 }
58
62 bool isDerivation() const;
63
64 std::string_view name() const
65 {
66 return std::string_view(baseName).substr(HashLen + 1);
67 }
68
69 std::string_view hashPart() const
70 {
71 return std::string_view(baseName).substr(0, HashLen);
72 }
73
74 static StorePath dummy;
75
76 static StorePath random(std::string_view name);
77};
78
79typedef std::set<StorePath> StorePathSet;
80typedef std::vector<StorePath> StorePaths;
81
86const std::string drvExtension = ".drv";
87
88}
89
90namespace std {
91
92template<> struct hash<nix::StorePath> {
93 std::size_t operator()(const nix::StorePath & path) const noexcept;
94};
95
96}
Definition path.hh:21
bool isDerivation() const
Definition path.cc:54
static constexpr size_t HashLen
Definition path.hh:29
const std::string drvExtension
Definition path.hh:86
Definition hash.hh:41