aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/config.hh
diff options
context:
space:
mode:
authorRebecca Turner <rbt@sent.as>2024-08-25 11:58:10 -0700
committerRebecca Turner <rbt@sent.as>2024-08-25 15:54:22 -0700
commit5fc6fcb31035f79a8e590f07d73dc6cc592e9e29 (patch)
treea47f804e3b3d74688e1dab6b6fd952664e0ef88b /src/libutil/config.hh
parentb6884388a1281d70bb4e5bb12e1cadd34bb832f0 (diff)
Thread `ApplyConfigOptions` through config parsing
This makes no changes to logic but makes the `ApplyConfigOptions` value available to consumers. Change-Id: I88cf53d38faac8472c556aee55c13d0acbd1e5db
Diffstat (limited to 'src/libutil/config.hh')
-rw-r--r--src/libutil/config.hh19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/libutil/config.hh b/src/libutil/config.hh
index dbca4b406..59cc281c5 100644
--- a/src/libutil/config.hh
+++ b/src/libutil/config.hh
@@ -10,6 +10,7 @@
#include "types.hh"
#include "experimental-features.hh"
#include "deprecated-features.hh"
+#include "apply-config-options.hh"
namespace nix {
@@ -61,7 +62,7 @@ public:
* Sets the value referenced by `name` to `value`. Returns true if the
* setting is known, false otherwise.
*/
- virtual bool set(const std::string & name, const std::string & value) = 0;
+ virtual bool set(const std::string & name, const std::string & value, const ApplyConfigOptions & options = {}) = 0;
struct SettingInfo
{
@@ -81,7 +82,7 @@ public:
* - contents: configuration contents to be parsed and applied
* - path: location of the configuration file
*/
- void applyConfig(const std::string & contents, const std::string & path = "<unknown>");
+ void applyConfig(const std::string & contents, const ApplyConfigOptions & options = {});
/**
* Resets the `overridden` flag of all Settings
@@ -155,7 +156,7 @@ public:
Config(StringMap initials = {});
- bool set(const std::string & name, const std::string & value) override;
+ bool set(const std::string & name, const std::string & value, const ApplyConfigOptions & options = {}) override;
void addSetting(AbstractSetting * setting);
@@ -200,7 +201,7 @@ protected:
virtual ~AbstractSetting();
- virtual void set(const std::string & value, bool append = false) = 0;
+ virtual void set(const std::string & value, bool append = false, const ApplyConfigOptions & options = {}) = 0;
/**
* Whether the type is appendable; i.e. whether the `append`
@@ -237,7 +238,7 @@ protected:
*
* Used by `set()`.
*/
- virtual T parse(const std::string & str) const;
+ virtual T parse(const std::string & str, const ApplyConfigOptions & options) const;
/**
* Append or overwrite `value` with `newValue`.
@@ -247,7 +248,7 @@ protected:
*
* @param append Whether to append or overwrite.
*/
- virtual void appendOrSet(T newValue, bool append);
+ virtual void appendOrSet(T newValue, bool append, const ApplyConfigOptions & options);
public:
@@ -284,7 +285,7 @@ public:
* Uses `parse()` to get the value from `str`, and `appendOrSet()`
* to set it.
*/
- void set(const std::string & str, bool append = false) override final;
+ void set(const std::string & str, bool append = false, const ApplyConfigOptions & options = {}) override final;
/**
* C++ trick; This is template-specialized to compile-time indicate whether
@@ -373,7 +374,7 @@ public:
options->addSetting(this);
}
- T parse(const std::string & str) const override;
+ T parse(const std::string & str, const ApplyConfigOptions & options) const override;
void operator =(const T & v) { this->assign(v); }
};
@@ -384,7 +385,7 @@ struct GlobalConfig : public AbstractConfig
typedef std::vector<Config*> ConfigRegistrations;
static ConfigRegistrations * configRegistrations;
- bool set(const std::string & name, const std::string & value) override;
+ bool set(const std::string & name, const std::string & value, const ApplyConfigOptions & options = {}) override;
void getSettings(std::map<std::string, SettingInfo> & res, bool overriddenOnly = false) override;