Environment

class Environment

This class provides access to the environment variables and provides facilities to specify where to load the underlying AMPL interpreter.

Public Types

typedef internal::CountedIterator<internal::EnvironmentIterator> iterator

Iterator for the map.

Public Functions

Environment()

Default constructor

Environment(const Environment &other)

Copy constructor

Environment &operator=(const Environment &other)

Assignment operator.

Environment(fmt::CStringRef binaryDirectory)

Constructor with ability to select the location of the AMPL binary. Note that if this constructor is used, the automatic lookup for an AMPL executable will not be executed.

Parameters
  • binaryDirectory: The directory in which look for the AMPL Binary

~Environment()

Destructor.

void put(fmt::CStringRef name, fmt::CStringRef value)

Add an environment variable to the environment, or change its value if already defined.

Parameters
  • name: name of the environment variable
  • value: value to be assigned

void setBinDir(fmt::CStringRef binaryDirectory)

Set the location where AMPLAPI will search for the AMPL executable.

Parameters
  • binaryDirectory: Directory

std::string getBinDir() const

Get the location where AMPLAPI will search for the AMPL executable.

std::string toString() const

Print all variables in the map

iterator begin() const

Returns an iterator pointing to the first environment variable in the map.

iterator end() const

Returns an iterator pointing to the past-the-end element in the map.

iterator find(fmt::CStringRef name) const

Searches the current object for an environment variable called name and returns an iterator to it if found, otherwise it returns an iterator to Environment::end.

std::size_t size() const

Returns the size of the map.