Decomposing ECLiPSe terms in C++

## B.2 Decomposing ECLiPSe terms in C++

The following methods type-check an ECLiPSe term and retrieve its contents if it is of the correct type. The return code is EC_succeed for successful conversion, an error code otherwise.

int EC_word::is_atom(EC_atom *)
  checks whether the ECLiPSe pword is an atom, and if so, return its atom identifier.
int EC_word::is_string(char **)
  checks whether the EC_word is a string (or atom) and converts it to a C++ string. This string is volatile, ie. it should be copied when it is required to survive resuming of ECLiPSe.
int EC_word::is_string(char **, long *)
  checks whether the EC_word is a string (or atom) and converts it to a C++ string. This string is volatile, ie. it should be copied when it is required to survive resuming of ECLiPSe. The string’s length is returned in the second argument.
int EC_word::is_long(long *)
  checks whether the EC_word is an integer that fits into a C++ long, and if so, stores it via the pointer provided.
int EC_word::is_long_long(long long *)
  checks whether the EC_word is an integer that fits into a C++ long long, and if so, stores it via the pointer provided.
int EC_word::is_double(double *)
  checks whether the EC_word is a floating point number, and if so, returns it as an C++ double.
int EC_word::is_list(EC_word&,EC_word&)
  checks whether the EC_word is a list and if so, returns its head and tail.
int EC_word::is_nil()
  checks whether the EC_word is nil, the empty list.
int EC_word::functor(EC_functor *)
  checks whether the EC_word is a compound term and if so, returns its functor.
int EC_word::arg(const int,EC_word&)
  checks whether the EC_word is a compound term and if so, returns its nth argument.
int EC_word::arity()
  returns the arity of an EC_word if it is a compound term, zero otherwise.
int EC_word::is_handle(const t_ext_type *, t_ext_ptr *)
  checks whether the EC_word is a handle whose method table matches the given one, and if so, the data pointer is returned.
int EC_word::is_var()
  checks whether the EC_word is a variable. Returns EC_succeed if so, EC_fail otherwise.