EnvVar Class Reference

An EnvVar object exists to provide information about environment variables stored in the map of environment variables without having the user know about the implementation. Here is how an EnvVar is used: More...

#include <options.h>

Collaboration diagram for EnvVar:
Collaboration graph
[legend]

List of all members.

Public Member Functions

char const * c_str () const
 EnvVar (string const &name, string const &value)
 EnvVar (string const &name)
string const & name () const
 get the name of the thing this represents
 operator bool () const
 convert this object to a bool so you can find out if the variable is set or not.
 operator string const & () const
 convert this object to a string, which is the value of environment variable it corresonds to.

Public Attributes

string name_
 the name of the variable you are talking about
bool set_
 is this variable actually defined?
string value_
 the value of it (or empty string if not set)

Detailed Description

An EnvVar object exists to provide information about environment variables stored in the map of environment variables without having the user know about the implementation. Here is how an EnvVar is used:

            if( op.getenv("PATH") )
            { // environment variable is set

Or you can do this:

            string s = op.getenv("PATH");        // gets the value of PATH
            string n = op.getenv("PATH").name()  // gets 'PATH'

If you want to print one of these things, convert it to a std::string

Definition at line 488 of file options.h.


Constructor & Destructor Documentation

EnvVar ( string const &  name  ) 

Creates an EnvVar which indicates that the corresonding variable is not set

Definition at line 511 of file options.h.

EnvVar ( string const &  name,
string const &  value 
)

creates an EnvVar that indicates that it is in fact defined and has a value

Definition at line 519 of file options.h.


Member Function Documentation

char const* c_str (  )  const

Definition at line 541 of file options.h.

string const& name (  )  const

get the name of the thing this represents

Definition at line 538 of file options.h.

operator bool (  )  const

convert this object to a bool so you can find out if the variable is set or not.

Definition at line 528 of file options.h.

operator string const & (  )  const

convert this object to a string, which is the value of environment variable it corresonds to.

Definition at line 533 of file options.h.


Member Data Documentation

the name of the variable you are talking about

Definition at line 508 of file options.h.

bool set_

is this variable actually defined?

Definition at line 507 of file options.h.

the value of it (or empty string if not set)

Definition at line 509 of file options.h.


The documentation for this class was generated from the following file:
Generated on Wed Feb 29 22:56:12 2012 for CXXUtilities by  doxygen 1.6.3