diff options
author | 2013-02-11 23:16:50 -0800 | |
---|---|---|
committer | 2013-02-11 23:16:50 -0800 | |
commit | 2a7fc9c3a507de45e1aa723068fb373567b869a1 (patch) | |
tree | 638983462e567356b3dbfd227a79adb48d6cc41b /env.h | |
parent | be23c0755e898ee3709c4635885342a9c1f77061 (diff) |
Clean up env_var_table_t. Switch from storing var_uni_entry_t* to var_uni_entry_t. Various other cleanups.
Diffstat (limited to 'env.h')
-rw-r--r-- | env.h | 46 |
1 files changed, 39 insertions, 7 deletions
@@ -108,20 +108,31 @@ class env_var_t : public wcstring private: bool is_missing; public: - static env_var_t missing_var(void); + static env_var_t missing_var(void) + { + env_var_t result(L""); + result.is_missing = true; + return result; + + } + env_var_t(const env_var_t &x) : wcstring(x), is_missing(x.is_missing) { } env_var_t(const wcstring & x) : wcstring(x), is_missing(false) { } env_var_t(const wchar_t *x) : wcstring(x), is_missing(false) { } env_var_t() : wcstring(L""), is_missing(false) { } + bool missing(void) const { return is_missing; } + bool missing_or_empty(void) const { return missing() || empty(); } + const wchar_t *c_str(void) const; + env_var_t &operator=(const env_var_t &s) { is_missing = s.is_missing; @@ -131,14 +142,35 @@ public: bool operator==(const env_var_t &s) const { - if (is_missing && s.is_missing) - return true; - else if (s.is_missing || s.is_missing) - return false; - else - return *static_cast<const wcstring *>(this) == *static_cast<const wcstring *>(&s); + return is_missing == s.is_missing && static_cast<const wcstring &>(*this) == static_cast<const wcstring &>(s); + } + + bool operator==(const wcstring &s) const + { + return ! is_missing && static_cast<const wcstring &>(*this) == s; + } + + bool operator!=(const env_var_t &s) const + { + return !(*this == s); + } + + bool operator!=(const wcstring &s) const + { + return !(*this == s); + } + + bool operator==(const wchar_t *s) const + { + return ! is_missing && static_cast<const wcstring &>(*this) == s; + } + + bool operator!=(const wchar_t *s) const + { + return !(*this == s); } + }; /** Gets the variable with the specified name, or an empty string if it does not exist. |