diff options
Diffstat (limited to 'c/pl.h')
-rw-r--r-- | c/pl.h | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -1,9 +1,12 @@ #ifndef PL_H #define PL_H +#include <string> #include <windows.h> #include <SWI-Prolog.h> +#include "common.h" + int PL_get_tchars(term_t t, TCHAR** pTsz, int iFlags); struct Frame @@ -43,14 +46,13 @@ inline int PlPut(term_t t, long long x) { return PL_put_int64(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_chars(t, x); } inline int PlPut(term_t t, const char* x) { return PL_put_atom_chars(t, x); } -inline int PlPut(term_t t, wchar_t* x) { return PL_unify_wchars(t, PL_ATOM, -1, x); } -inline int PlPut(term_t t, const wchar_t* x) { return PL_unify_wchars(t, PL_ATOM, -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(term_t, std::string*) { return -1; } +inline int PlPut(term_t, std::wstring*) { return -1; } inline int PlGet(term_t, int) { return -1; } inline int PlGet(term_t, long) { return -1; } @@ -58,14 +60,25 @@ 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, wchar_t*) { return -1; } -inline int PlGet(term_t, const wchar_t*) { 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) { size_t len; return PL_get_wchars(t, &len, x, CVT_ATOM); } +inline int PlGet(term_t t, std::string* x) { + Mark m; + char* sz; + if (!PlGet(t, &sz)) return 0; + *x = sz; + return 1; +} +inline int PlGet(term_t t, std::wstring* x) { + Mark m; + char* sz; + if (!PlGet(t, &sz)) return 0; + *x = BstrFromSz<wchar_t>(sz); + return 1; /* or catch potential exception from BstrFromSz? */ +} /* Put in or get from a term reference an arbitrary number of values, * returning false if any value could not be put/got. */ |