mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Clean up env_var_t interface
This commit is contained in:
parent
05b5e8e4f8
commit
2c5b49c3fe
1 changed files with 17 additions and 25 deletions
42
src/env.h
42
src/env.h
|
@ -74,28 +74,24 @@ class env_var_t {
|
||||||
wcstring_list_t vals; // list of values assigned to the var
|
wcstring_list_t vals; // list of values assigned to the var
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool exportv; // whether the variable should be exported
|
bool exportv = false; // whether the variable should be exported
|
||||||
|
|
||||||
// Constructors.
|
// Constructors.
|
||||||
env_var_t(const env_var_t &v) : name(v.name), vals(v.vals), exportv(v.exportv) {}
|
env_var_t(const env_var_t &) = default;
|
||||||
env_var_t(const wcstring &our_name, const wcstring_list_t &l)
|
env_var_t(env_var_t &&) = default;
|
||||||
: name(our_name), vals(l), exportv(false) {}
|
env_var_t(wcstring name, wcstring_list_t vals) : name(std::move(name)), vals(std::move(vals)) {}
|
||||||
env_var_t(const wcstring &our_name, const wcstring &s)
|
|
||||||
: name(our_name),
|
|
||||||
vals({
|
|
||||||
s,
|
|
||||||
}),
|
|
||||||
exportv(false) {}
|
|
||||||
env_var_t(const wcstring &our_name, const wchar_t *s)
|
|
||||||
: name(our_name),
|
|
||||||
vals({
|
|
||||||
wcstring(s),
|
|
||||||
}),
|
|
||||||
exportv(false) {}
|
|
||||||
env_var_t() : name(), vals(), exportv(false) {}
|
|
||||||
|
|
||||||
bool empty(void) const { return vals.empty() || (vals.size() == 1 && vals[0].empty()); };
|
env_var_t(wcstring name, wcstring val)
|
||||||
bool read_only(void) const;
|
: name(std::move(name)),
|
||||||
|
vals({
|
||||||
|
std::move(val),
|
||||||
|
}),
|
||||||
|
exportv(false) {}
|
||||||
|
|
||||||
|
env_var_t() = default;
|
||||||
|
|
||||||
|
bool empty() const { return vals.empty() || (vals.size() == 1 && vals[0].empty()); };
|
||||||
|
bool read_only() const;
|
||||||
|
|
||||||
bool matches_string(const wcstring &str) {
|
bool matches_string(const wcstring &str) {
|
||||||
if (vals.size() > 1) return false;
|
if (vals.size() > 1) return false;
|
||||||
|
@ -110,12 +106,8 @@ class env_var_t {
|
||||||
|
|
||||||
void set_vals(wcstring_list_t v) { vals = std::move(v); }
|
void set_vals(wcstring_list_t v) { vals = std::move(v); }
|
||||||
|
|
||||||
env_var_t &operator=(const env_var_t &var) {
|
env_var_t &operator=(const env_var_t &var) = default;
|
||||||
this->name = var.name;
|
env_var_t &operator=(env_var_t &&) = default;
|
||||||
this->vals = var.vals;
|
|
||||||
this->exportv = var.exportv;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Compare a simple string to the var. Returns true iff the var has a single
|
/// Compare a simple string to the var. Returns true iff the var has a single
|
||||||
/// value and that value matches the string being compared to.
|
/// value and that value matches the string being compared to.
|
||||||
|
|
Loading…
Reference in a new issue