diff options
author | Peter Ammon <corydoras@ridiculousfish.com> | 2012-01-14 01:06:47 -0800 |
---|---|---|
committer | Peter Ammon <corydoras@ridiculousfish.com> | 2012-01-14 01:06:47 -0800 |
commit | e8b6d48ad038089e37730990212676e50a8d2352 (patch) | |
tree | 18b23c3bff183e9c9a3d3bae9ecbbb49a28f8743 /env.h | |
parent | 8ba79d6ab9093388df36c06c2b9e2e2b95014cd5 (diff) |
Introduce env_var_t to replace empty string as missing environment variable
Diffstat (limited to 'env.h')
-rw-r--r-- | env.h | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -95,10 +95,22 @@ int env_set( const wchar_t *key, */ wchar_t *env_get( const wchar_t *key ); +class env_var_t : public wcstring { +private: + bool is_missing; +public: + static env_var_t missing_var(void); + 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; +}; /** Gets the variable with the specified name, or an empty string if it does not exist. */ -wcstring env_get_string( const wchar_t *key ); +env_var_t env_get_string( const wchar_t *key ); /** Returns 1 if the specified key exists. This can't be reliably done |