diff options
author | John Ankarström <john@ankarstrom.se> | 2022-07-30 03:14:13 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-07-30 03:14:13 +0200 |
commit | ebabd34385feb629b759216c1f7d85edc20bf2fd (patch) | |
tree | 432e68a6a58bcaf4bc1dd3c5ae438157f09f4d4a /c/episodelistview.cpp | |
parent | d485eb2bf7e0a82702afec9387f21bf0f89c985f (diff) | |
download | EpisodeBrowser-ebabd34385feb629b759216c1f7d85edc20bf2fd.tar.gz |
Add wstring_owner, replacing std::wstring.
std::basic_string is nice, but it is not very ergonomic if everything
you really need is to automatically free C strings at end of scope.
I suppose I could have used std::unique_ptr for this, but I suspect
the ergonomics would be worse.
Diffstat (limited to 'c/episodelistview.cpp')
-rw-r--r-- | c/episodelistview.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp index b3ee02f..132941c 100644 --- a/c/episodelistview.cpp +++ b/c/episodelistview.cpp @@ -272,16 +272,16 @@ int CALLBACK EpisodeListView::SortProc(const LPARAM iItem1, const LPARAM iItem2, case ELVSITITLE: { Mark m; - std::wstring ws1, ws2; + wstring_owner wso1, wso2; int cch, cch1, cch2; - if (!Pl("episode_data","episode_title",lvi1.lParam,&ws1)) + if (!Pl("episode_data","episode_title",lvi1.lParam,&wso1)) return 0; - if (!Pl("episode_data","episode_title",lvi2.lParam,&ws2)) + if (!Pl("episode_data","episode_title",lvi2.lParam,&wso2)) return 0; - cch1 = wcslen(ws1.c_str()); - cch2 = wcslen(ws2.c_str()); + cch1 = wcslen(wso1.p); + cch2 = wcslen(wso2.p); cch = cch1 > cch2? cch2: cch1; - return iOrder*_wcsnicmp(ws1.c_str(), ws2.c_str(), cch); + return iOrder*_wcsnicmp(wso1.p, wso2.p, cch); } default: return 0; @@ -412,12 +412,12 @@ void EpisodeListView::Update() /* Update episode name and rating. */ void EpisodeListView::UpdateItem(const LVITEM* const pLvi) { - std::wstring wsName; - if (!Pl("episode_data","episode_title",pLvi->lParam,&wsName)) { + wstring_owner wsoName; + if (!Pl("episode_data","episode_title",pLvi->lParam,&wsoName)) { if (!Pl("episode_data","update_episode_data")) goto r; - if (!Pl("episode_data","episode_title",pLvi->lParam,&wsName)) goto r; + if (!Pl("episode_data","episode_title",pLvi->lParam,&wsoName)) goto r; } - ListView_SetItemText(hWnd, pLvi->iItem, ELVSITITLE, wsName.data()); + ListView_SetItemText(hWnd, pLvi->iItem, ELVSITITLE, wsoName.p); r: int iRating; if (!Pl("episode_data","episode_rating",pLvi->lParam,&iRating)) { |