Environment

class ampl::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

inline Environment()

Default constructor

inline Environment(const Environment &other)

Copy constructor

inline Environment &operator=(const Environment &other)

Assignment operator.

inline explicit Environment(fmt::CStringRef binaryDirectory, fmt::CStringRef binaryName = "")

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

  • binaryName – The name of the AMPL executable if other than “ampl”

inline ~Environment()

Destructor.

inline 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

inline void setBinDir(fmt::CStringRef binaryDirectory)

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

Parameters

binaryDirectory – Directory

inline std::string getBinDir() const

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

inline void setBinName(fmt::CStringRef binaryName)

Set the name of the AMPL executable.

Parameters

binaryName – Executable

inline std::string getBinName() const

Get the name of the AMPL executable.

inline std::string toString() const

Print all variables in the map

inline iterator begin() const

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

inline iterator end() const

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

inline 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.

inline std::size_t size() const

Returns the size of the map.