Files
lix/lix/libutil/experimental-features.hh
T
eldritch horrorsandjade b0d7a81613 fix tooling after include reorganization
clangd broke because it can't look through symlinks. compile_commands
manipulation does not fix it, clangd configuration does not fix it, a
vfs overlay does not fix it, and while a combination of those can fix
it with a bind mount in place that's just too cursed to even consider

clangd bug: https://github.com/llvm/llvm-project/issues/116877

Change-Id: I8e3e8489548eb3a7aa65ac9d12a5ec8abf814aec
2024-11-19 22:55:32 +00:00

79 lines
2.1 KiB
C++

#pragma once
///@file
#include "lix/libutil/error.hh"
#include "lix/libutil/types.hh"
namespace nix {
/**
* The list of available experimental features.
*/
enum struct ExperimentalFeature
{
#include "experimental-features.gen.inc"
NumXpFeatures, // number of available experimental features, do not use
};
enum struct ExperimentalFeatures {};
inline ExperimentalFeatures operator| (ExperimentalFeatures a, ExperimentalFeatures b) {
return static_cast<ExperimentalFeatures>(static_cast<size_t>(a) | static_cast<size_t>(b));
}
inline ExperimentalFeatures operator| (ExperimentalFeatures a, ExperimentalFeature b) {
return a | static_cast<ExperimentalFeatures>(1 << static_cast<size_t>(b));
}
inline ExperimentalFeatures operator& (ExperimentalFeatures a, ExperimentalFeature b) {
return static_cast<ExperimentalFeatures>(static_cast<size_t>(a) & (1 << static_cast<size_t>(b)));
}
/**
* Just because writing `ExperimentalFeature::CaDerivations` is way too long
*/
using Xp = ExperimentalFeature;
/**
* Parse an experimental feature (enum value) from its name. Experimental
* feature flag names are hyphenated and do not contain spaces.
*/
const std::optional<ExperimentalFeature> parseExperimentalFeature(
const std::string_view & name);
/**
* Show the name of an experimental feature. This is the opposite of
* parseExperimentalFeature().
*/
std::string_view showExperimentalFeature(const ExperimentalFeature);
/**
* Shorthand for `str << showExperimentalFeature(feature)`.
*/
std::ostream & operator<<(
std::ostream & str,
const ExperimentalFeature & feature);
/**
* Parse a set of strings to the corresponding set of experimental
* features, ignoring (but warning for) any unknown feature.
*/
ExperimentalFeatures parseFeatures(const std::set<std::string> &);
/**
* An experimental feature was required for some (experimental)
* operation, but was not enabled.
*/
class MissingExperimentalFeature : public Error
{
public:
/**
* The experimental feature that was required but not enabled.
*/
ExperimentalFeature missingFeature;
MissingExperimentalFeature(ExperimentalFeature missingFeature);
};
}