summaryrefslogtreecommitdiff
path: root/pmt/src/lib/pmt.h
diff options
context:
space:
mode:
Diffstat (limited to 'pmt/src/lib/pmt.h')
-rw-r--r--pmt/src/lib/pmt.h72
1 files changed, 63 insertions, 9 deletions
diff --git a/pmt/src/lib/pmt.h b/pmt/src/lib/pmt.h
index 0499a16c1..2cb032e5b 100644
--- a/pmt/src/lib/pmt.h
+++ b/pmt/src/lib/pmt.h
@@ -28,6 +28,7 @@
#include <string>
#include <stdint.h>
#include <iostream>
+#include <stdexcept>
/*!
* This file defines a polymorphic type and the operations on it.
@@ -49,27 +50,28 @@ class pmt_base;
typedef boost::shared_ptr<pmt_base> pmt_t;
-class pmt_exception
+class pmt_exception : public std::logic_error
{
- const char *d_msg;
- pmt_t d_obj;
-
public:
- pmt_exception(const char *msg, pmt_t obj);
- const char *msg() { return d_msg; }
- pmt_t obj() { return d_obj; }
+ pmt_exception(const std::string &msg, pmt_t obj);
};
class pmt_wrong_type : public pmt_exception
{
public:
- pmt_wrong_type(const char *msg, pmt_t obj);
+ pmt_wrong_type(const std::string &msg, pmt_t obj);
};
class pmt_out_of_range : public pmt_exception
{
public:
- pmt_out_of_range(const char *msg, pmt_t obj);
+ pmt_out_of_range(const std::string &msg, pmt_t obj);
+};
+
+class pmt_notimplemented : public pmt_exception
+{
+public:
+ pmt_notimplemented(const std::string &msg, pmt_t obj);
};
/*
@@ -111,6 +113,10 @@ bool pmt_is_symbol(pmt_t obj);
//! Return the symbol whose name is \p s.
pmt_t pmt_string_to_symbol(const std::string &s);
+//! Alias for pmt_string_to_symbol
+pmt_t pmt_intern(const std::string &s);
+
+
/*!
* If \p is a symbol, return the name of the symbol as a string.
* Otherwise, raise the wrong_type exception.
@@ -504,6 +510,44 @@ pmt_acons(pmt_t x, pmt_t y, pmt_t a)
return pmt_cons(pmt_cons(x, y), a);
}
+/*!
+ * \brief locates \p nth element of \n list where the car is the 'zeroth' element.
+ */
+pmt_t pmt_nth(size_t n, pmt_t list);
+
+/*!
+ * \brief returns the tail of \p list that would be obtained by calling
+ * cdr \p n times in succession.
+ */
+pmt_t pmt_nthcdr(size_t n, pmt_t list);
+
+/*!
+ * \brief Return the first sublist of \p list whose car is \p obj.
+ * If \p obj does not occur in \p list, then #f is returned.
+ * pmt_memq use pmt_eq to compare \p obj with the elements of \p list.
+ */
+pmt_t pmt_memq(pmt_t obj, pmt_t list);
+
+/*!
+ * \brief Return the first sublist of \p list whose car is \p obj.
+ * If \p obj does not occur in \p list, then #f is returned.
+ * pmt_memv use pmt_eqv to compare \p obj with the elements of \p list.
+ */
+pmt_t pmt_memv(pmt_t obj, pmt_t list);
+
+/*!
+ * \brief Return the first sublist of \p list whose car is \p obj.
+ * If \p obj does not occur in \p list, then #f is returned.
+ * pmt_member use pmt_equal to compare \p obj with the elements of \p list.
+ */
+pmt_t pmt_member(pmt_t obj, pmt_t list);
+
+/*!
+ * \brief Return true if every element of \p list1 appears in \p list2, and false otherwise.
+ * Comparisons are done with pmt_eqv.
+ */
+bool pmt_subsetp(pmt_t list1, pmt_t list2);
+
/*
* ------------------------------------------------------------------------
* read / write
@@ -536,6 +580,16 @@ pmt_t pmt_read(std::istream &port);
*/
void pmt_write(pmt_t obj, std::ostream &port);
+/*!
+ * Return a string representation of \p obj.
+ * This is the same output as would be generated by pmt_write.
+ */
+std::string pmt_write_string(pmt_t obj);
+
+
+std::ostream& operator<<(std::ostream &os, pmt_t obj);
+
+
/*
* ------------------------------------------------------------------------
* portable byte stream representation