30 #define YUILogComponent "ui"
42 if ( ! _name.empty() )
44 const char * val = getenv( _name.c_str() );
62 return strcmp( _value.c_str(), str.c_str() ) == 0;
64 return strcasecmp( _value.c_str(), str.c_str() ) == 0;
75 return _value.find( str ) != string::npos;
79 return tolower( _value ).find( tolower( str ) ) != string::npos;
84 string tolower(
const string & str )
87 lowStr.reserve( str.size() );
89 for ( string::const_iterator it = str.begin();
93 lowStr += ::tolower( *it );
101 operator<<( std::ostream & stream,
const YEnvVar env )
103 if ( env.
name().empty() )
105 stream <<
"<unnamed environment variable>";
110 stream <<
"$" << env.
name() <<
"=\"" << env.
value() <<
"\"";
112 stream <<
"$" << env.
name() <<
": <not set>";
Helper class to represent an environment variable and its value.
bool isSet() const
Return 'true' if the environment variable is set.
bool contains(const std::string &str, bool caseSensitive=false) const
Return 'true' if the environment variable is set and the value contains 'str'.
std::string name() const
Return the name of the environment variable.
YEnvVar(const std::string &name=std::string())
Constructor: Retrieve the environment variable 'name' and store the value (unless 'name' is empty).
std::string value() const
Return the value of the environment variable.
bool isEqual(const std::string &str, bool caseSensitive=false) const
Return 'true' if the environment variable is set and the value is 'str'.