aboutsummaryrefslogtreecommitdiff
path: root/c/pl.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/pl.h')
-rw-r--r--c/pl.h72
1 files changed, 36 insertions, 36 deletions
diff --git a/c/pl.h b/c/pl.h
index e1dbea7..9f40676 100644
--- a/c/pl.h
+++ b/c/pl.h
@@ -19,61 +19,61 @@ private:
};
/* Polymorphic aliases for PL_put_*, PL_get_*. */
-inline int PlPut(term_t t, int x) { return PL_put_integer(t, x); }
-inline int PlPut(term_t t, long x) { return PL_put_integer(t, x); }
-inline int PlPut(term_t t, long long x) { return PL_put_integer(t, x); }
-inline int PlPut(term_t t, atom_t x) { return PL_put_atom(t, x); }
-inline int PlPut(term_t t, char *x) { return PL_put_atom(t, PL_new_atom(x)); }
-inline int PlPut(term_t t, const char *x) { return PL_put_atom(t, PL_new_atom(x)); }
-inline int PlPut(term_t t, wchar_t *x) { return PL_put_atom(t, PL_new_atom_wchars(-1, x)); }
-inline int PlPut(term_t t, const wchar_t *x) { return PL_put_atom(t, PL_new_atom_wchars(-1, x)); }
-inline int PlPut(term_t, int *) { return -1; }
-inline int PlPut(term_t, long *) { return -1; }
-inline int PlPut(term_t, long long *) { return -1; }
-inline int PlPut(term_t, atom_t *) { return -1; }
-inline int PlPut(term_t, char **) { return -1; }
-inline int PlPut(term_t, wchar_t **) { return -1; }
+inline int PlPut(const term_t t, const int x) { return PL_put_integer(t, x); }
+inline int PlPut(const term_t t, const long x) { return PL_put_integer(t, x); }
+inline int PlPut(const term_t t, const long long x) { return PL_put_integer(t, x); }
+inline int PlPut(const term_t t, const atom_t x) { return PL_put_atom(t, x); }
+inline int PlPut(const term_t t, char *x) { return PL_put_atom(t, PL_new_atom(x)); }
+inline int PlPut(const term_t t, const char *x) { return PL_put_atom(t, PL_new_atom(x)); }
+inline int PlPut(const term_t t, wchar_t *x) { return PL_put_atom(t, PL_new_atom_wchars(-1, x)); }
+inline int PlPut(const term_t t, const wchar_t *x) { return PL_put_atom(t, PL_new_atom_wchars(-1, x)); }
+inline int PlPut(const term_t, int *) { return -1; }
+inline int PlPut(const term_t, long *) { return -1; }
+inline int PlPut(const term_t, long long *) { return -1; }
+inline int PlPut(const term_t, atom_t *) { return -1; }
+inline int PlPut(const term_t, char **) { return -1; }
+inline int PlPut(const term_t, wchar_t **) { return -1; }
-inline int PlGet(term_t, int) { return -1; }
-inline int PlGet(term_t, long) { return -1; }
-inline int PlGet(term_t, long long) { return -1; }
-inline int PlGet(term_t, atom_t) { return -1; }
-inline int PlGet(term_t, char*) { return -1; }
-inline int PlGet(term_t, const char *) { return -1; }
-inline int PlGet(term_t t, int *x) { return PL_get_integer(t, x); }
-inline int PlGet(term_t t, long *x) { return PL_get_long(t, x); }
-inline int PlGet(term_t t, long long *x) { return PL_get_int64(t, x); }
-inline int PlGet(term_t t, atom_t *x) { return PL_get_atom(t, x); }
-inline int PlGet(term_t t, char **x) { return PL_get_atom_chars(t, x); }
-inline int PlGet(term_t t, wchar_t **x)
+inline int PlGet(const term_t, const int) { return -1; }
+inline int PlGet(const term_t, const long) { return -1; }
+inline int PlGet(const term_t, const long long) { return -1; }
+inline int PlGet(const term_t, const atom_t) { return -1; }
+inline int PlGet(const term_t, char*) { return -1; }
+inline int PlGet(const term_t, const char *) { return -1; }
+inline int PlGet(const term_t t, int *x) { return PL_get_integer(t, x); }
+inline int PlGet(const term_t t, long *x) { return PL_get_long(t, x); }
+inline int PlGet(const term_t t, long long *x) { return PL_get_int64(t, x); }
+inline int PlGet(const term_t t, atom_t *x) { return PL_get_atom(t, x); }
+inline int PlGet(const term_t t, char **x) { return PL_get_atom_chars(t, x); }
+inline int PlGet(const term_t t, wchar_t **x)
{
atom_t a;
- size_t siz;
+ size_t len;
if (!PL_get_atom(t, &a)) return 0;
- *x = (wchar_t *)PL_atom_wchars(a, &siz);
+ *x = (wchar_t *)PL_atom_wchars(a, &len);
return *x != NULL;
}
/* Helper templates for Plx, Pl. */
template <typename T>
-int PlPutv(term_t t, T arg) { return PlPut(t, arg); }
+int PlPutv(const term_t t, T arg) { return PlPut(t, arg); }
template <typename T, typename ...R>
-int PlPutv(term_t t, T arg, R... rest) { return PlPut(t, arg)? PlPutv(t+1, rest...): 0; }
+int PlPutv(const term_t t, T arg, R... rest) { return PlPut(t, arg)? PlPutv(t+1, rest...): 0; }
template <typename T>
-int PlGetv(term_t t, T arg) { return PlGet(t, arg); }
+int PlGetv(const term_t t, T arg) { return PlGet(t, arg); }
template <typename T, typename ...R>
-int PlGetv(term_t t, T arg, R... rest) { return PlGet(t, arg)? PlGetv(t+1, rest...): 0; }
+int PlGetv(const term_t t, T arg, R... rest) { return PlGet(t, arg)? PlGetv(t+1, rest...): 0; }
template <typename T>
-int Countv(int i, T arg) { return i+1; }
+int Countv(const int i, T arg) { return i+1; }
template <typename T, typename ...R>
-int Countv(int i, T arg, R... rest) { return Countv(i+1, rest...); }
+int Countv(const int i, T arg, R... rest) { return Countv(i+1, rest...); }
/* Call Prolog predicate, propagating Prolog exceptions. */
template <typename ...T>
int Plx(const char *szMod, const char *szPred, T... args)
{
- int iArity = Countv(0, args...);
- term_t t = PL_new_term_refs(iArity);
+ const int iArity = Countv(0, args...);
+ const term_t t = PL_new_term_refs(iArity);
if (!PlPutv(t, args...)) return 0;
Query q(NULL, PL_predicate(szPred, iArity, szMod), t);
if (!q.NextSolution()) return 0;