diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-04-19 22:02:33 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2022-04-19 22:02:33 +0000 |
commit | 8abb6270022eb9d4aab9e85f29880644e3973d02 (patch) | |
tree | 7abfdc7b5c8f01dbef03d2d6e75e232f1fa7895c /src/libstore/content-address.hh | |
parent | ff2a8ccfe176fa3e075ed8925a371eeb17e627e6 (diff) | |
parent | 2c21cb672043fcf3c3fd19f89618b37693c0dc62 (diff) |
Merge branch 'path-info' into ca-drv-exotic
Diffstat (limited to 'src/libstore/content-address.hh')
-rw-r--r-- | src/libstore/content-address.hh | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/src/libstore/content-address.hh b/src/libstore/content-address.hh index eb56fe571..54f22782b 100644 --- a/src/libstore/content-address.hh +++ b/src/libstore/content-address.hh @@ -3,6 +3,7 @@ #include <variant> #include "hash.hh" #include "path.hh" +#include "comparator.hh" namespace nix { @@ -56,6 +57,8 @@ std::pair<ContentAddressMethod, HashType> parseContentAddressMethod(std::string_ struct TextHash { Hash hash; + + GENERATE_CMP(TextHash, me->hash); }; /// Pair of a hash, and how the file system was ingested @@ -63,6 +66,8 @@ struct FixedOutputHash { FileIngestionMethod method; Hash hash; std::string printMethodAlgo() const; + + GENERATE_CMP(FixedOutputHash, me->method, me->hash); }; /* @@ -102,23 +107,13 @@ struct PathReferences std::set<Ref> references; bool hasSelfReference = false; - bool operator == (const PathReferences<Ref> & other) const - { - return references == other.references - && hasSelfReference == other.hasSelfReference; - } - - bool operator != (const PathReferences<Ref> & other) const - { - return references != other.references - || hasSelfReference != other.hasSelfReference; - } - /* Functions to view references + hasSelfReference as one set, mainly for compatibility's sake. */ StorePathSet referencesPossiblyToSelf(const Ref & self) const; void insertReferencePossiblyToSelf(const Ref & self, Ref && ref); void setReferencesPossiblyToSelf(const Ref & self, std::set<Ref> && refs); + + GENERATE_CMP(PathReferences<Ref>, me->references, me->hasSelfReference); }; template<typename Ref> @@ -159,11 +154,15 @@ void PathReferences<Ref>::setReferencesPossiblyToSelf(const Ref & self, std::set struct TextInfo : TextHash { // References for the paths, self references disallowed StorePathSet references; + + GENERATE_CMP(TextInfo, *(const TextHash *)me, me->references); }; struct FixedOutputInfo : FixedOutputHash { // References for the paths PathReferences<StorePath> references; + + GENERATE_CMP(FixedOutputInfo, *(const FixedOutputHash *)me, me->references); }; typedef std::variant< @@ -185,17 +184,7 @@ struct StorePathDescriptor { std::string name; ContentAddressWithReferences info; - bool operator == (const StorePathDescriptor & other) const - { - return name == other.name; - // FIXME second field - } - - bool operator < (const StorePathDescriptor & other) const - { - return name < other.name; - // FIXME second field - } + GENERATE_CMP(StorePathDescriptor, me->name, me->info); }; } |