aboutsummaryrefslogtreecommitdiffhomepage
path: root/env.h
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-02-11 23:16:50 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-02-11 23:16:50 -0800
commit2a7fc9c3a507de45e1aa723068fb373567b869a1 (patch)
tree638983462e567356b3dbfd227a79adb48d6cc41b /env.h
parentbe23c0755e898ee3709c4635885342a9c1f77061 (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.h46
1 files changed, 39 insertions, 7 deletions
diff --git a/env.h b/env.h
index e2110a92..5a91497c 100644
--- a/env.h
+++ b/env.h
@@ -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.