30 #define YUILogComponent "ui"
40 if ( ! _name.empty() )
42 const char * val = getenv( _name.c_str() );
60 return strcmp( _value.c_str(), str.c_str() ) == 0;
62 return strcasecmp( _value.c_str(), str.c_str() ) == 0;
73 return _value.find( str ) != std::string::npos;
77 return tolower( _value ).find( tolower( str ) ) != std::string::npos;
82 std::string tolower(
const std::string & str )
85 lowStr.reserve( str.size() );
87 for ( std::string::const_iterator it = str.begin();
91 lowStr += ::tolower( *it );
99 operator<<( std::ostream & stream,
const YEnvVar env )
101 if ( env.
name().empty() )
103 stream <<
"<unnamed environment variable>";
108 stream <<
"$" << env.
name() <<
"=\"" << env.
value() <<
"\"";
110 stream <<
"$" << env.
name() <<
": <not set>";
YEnvVar(const std::string &name=std::string())
Constructor: Retrieve the environment variable 'name' and store the value (unless 'name' is empty)...
bool isSet() const
Return 'true' if the environment variable is set.
Helper class to represent an environment variable and its value.
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'.
std::string name() const
Return the name of the environment variable.
bool contains(const std::string &str, bool caseSensitive=false) const
Return 'true' if the environment variable is set and the value contains 'str'.