aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/datalistview.cpp14
-rw-r--r--c/episodelistview.cpp10
-rw-r--r--c/pl.cpp6
-rw-r--r--c/pl.h33
4 files changed, 35 insertions, 28 deletions
diff --git a/c/datalistview.cpp b/c/datalistview.cpp
index f75fc99..532e3a6 100644
--- a/c/datalistview.cpp
+++ b/c/datalistview.cpp
@@ -9,6 +9,7 @@
#include "episodelistview.h"
#include "listview.h"
#include "main.h"
+#include "pl.h"
extern EpisodeListView *g_lpElv;
@@ -44,24 +45,21 @@ void DataListView::ShowEpisode(int iEpisode)
PL_predicate("episode_datum", 3, "episode_data"), t);
for (int i = 0; PL_next_solution(q); i++) {
- char *szKey;
- char *szValue;
+ TCHAR *tszKey;
+ TCHAR *tszValue;
- if (!(PL_get_atom_chars(t+1,&szKey) && PL_get_atom_chars(t+2,&szValue)))
+ if (!(PlGet(t+1, &tszKey) && PlGet(t+2, &tszValue)))
continue;
- std::basic_string<TCHAR> tsmKey = TsmFromSz(szKey, CP_UTF8);
- std::basic_string<TCHAR> tsmValue = TsmFromSz(szValue, CP_UTF8);
-
lviKey.mask = LVIF_TEXT;
lviKey.iItem = i;
lviKey.iSubItem = 0;
- lviKey.pszText = tsmKey.data();
+ lviKey.pszText = tszKey;
ListView_InsertItem(m_hWnd, &lviKey);
lviValue.iItem = i;
lviValue.iSubItem = 1;
- lviValue.pszText = tsmValue.data();
+ lviValue.pszText = tszValue;
ListView_SetItem(m_hWnd, &lviValue);
}
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp
index 5003495..01b4c1a 100644
--- a/c/episodelistview.cpp
+++ b/c/episodelistview.cpp
@@ -355,18 +355,16 @@ void EpisodeListView::Update()
/* Update episode name and rating. */
void EpisodeListView::UpdateItem(LPLVITEM lpLvi)
{
- std::basic_string<TCHAR> tsmName;
- char *szName;
+ TCHAR *tszName;
int iRating;
static TCHAR tszRating[3];
- if (!Pl("episode_data","episode_title",lpLvi->lParam,&szName)) {
+ if (!Pl("episode_data","episode_title",lpLvi->lParam,&tszName)) {
if (!Pl("episode_data","update_episode_data")) goto r;
- if (!Pl("episode_data","episode_title",lpLvi->lParam,&szName))
+ if (!Pl("episode_data","episode_title",lpLvi->lParam,&tszName))
goto r;
}
- tsmName = TsmFromSz(szName, CP_UTF8);
- ListView_SetItemText(m_hWnd, lpLvi->iItem, ELVSITITLE, tsmName.data());
+ ListView_SetItemText(m_hWnd, lpLvi->iItem, ELVSITITLE, tszName);
r: if (!Pl("episode_data","episode_rating",lpLvi->lParam,&iRating)) {
ListView_SetItemText(m_hWnd, lpLvi->iItem, ELVSIRATING, TEXT(""));
diff --git a/c/pl.cpp b/c/pl.cpp
index c944547..21253ba 100644
--- a/c/pl.cpp
+++ b/c/pl.cpp
@@ -37,10 +37,10 @@ int Query::NextSolution()
int PL_get_tchars(term_t t, TCHAR **lpTsz, int iFlags)
{
#ifdef UNICODE
- size_t sizLen;
- if (!PL_get_wchars(t, &sizLen, lpTsz, iFlags))
+ size_t len;
+ if (!PL_get_wchars(t, &len, lpTsz, iFlags))
return 0;
- return sizLen;
+ return len;
#else
if (!PL_get_chars(t, lpTsz, iFlags))
return 0;
diff --git a/c/pl.h b/c/pl.h
index e91aff0..e1dbea7 100644
--- a/c/pl.h
+++ b/c/pl.h
@@ -25,23 +25,34 @@ 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, int *x) { return -1; }
-inline int PlPut(term_t t, long *x) { return -1; }
-inline int PlPut(term_t t, long long *x) { return -1; }
-inline int PlPut(term_t t, atom_t *x) { return -1; }
-inline int PlPut(term_t t, char **x) { return -1; }
+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 PlGet(term_t t, int x) { return -1; }
-inline int PlGet(term_t t, long x) { return -1; }
-inline int PlGet(term_t t, long long x) { return -1; }
-inline int PlGet(term_t t, atom_t x) { return -1; }
-inline int PlGet(term_t t, char *x) { return -1; }
-inline int PlGet(term_t t, const char *x) { 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)
+{
+ atom_t a;
+ size_t siz;
+ if (!PL_get_atom(t, &a)) return 0;
+ *x = (wchar_t *)PL_atom_wchars(a, &siz);
+ return *x != NULL;
+}
/* Helper templates for Plx, Pl. */
template <typename T>