diff options
author | John Ankarström <john@ankarstrom.se> | 2022-07-24 02:05:30 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-07-24 02:05:30 +0200 |
commit | 98f28569b631d36a6f129a17ea7589b48884c1eb (patch) | |
tree | 45fdc18108edaf45fa424324591ab7a7aaa1db10 /c/pl.cpp | |
parent | 3a133c4063cbb81bee9f5bc55427be75d8e584e0 (diff) | |
download | EpisodeBrowser-98f28569b631d36a6f129a17ea7589b48884c1eb.tar.gz |
Fix PL_get_tchars.
See c6cd2f1.
Diffstat (limited to 'c/pl.cpp')
-rw-r--r-- | c/pl.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -78,16 +78,20 @@ int Query::NextSolution() } /* Convert Prolog term to normal or wide characters. */ -int PL_get_tchars(const term_t t, TCHAR** const pTsz, const int iFlags) +template <> +int PlString<char>(const term_t t, std::string* const pStr, const int iFlags) { -#ifdef UNICODE - size_t len; - if (!PL_get_wchars(t, &len, pTsz, iFlags)) - return 0; - return len; -#else - if (!PL_get_chars(t, pTsz, iFlags)) - return 0; - return -1; -#endif + char* sz; + int r = PL_get_chars(t, &sz, iFlags); + if (r) *pStr = sz; + return r; +} + +template <> +int PlString<wchar_t>(const term_t t, std::wstring* const pWstr, const int iFlags) +{ + char* sz; + int r = PL_get_chars(t, &sz, iFlags); + if (r) *pWstr = BstrFromSz<wchar_t>(sz); + return r; } |