create two new functions String::str() and String::toLower() to avoid _tcslwr() calls and allow convenient string conversions

svn path=/trunk/; revision=18937
This commit is contained in:
Martin Fuchs 2005-11-01 20:30:17 +00:00
parent 0749054fcf
commit 07a232d2e7
10 changed files with 34 additions and 43 deletions

View file

@ -151,9 +151,7 @@ void FindProgramDlg::Refresh(bool delete_cache)
TCHAR buffer[1024]; TCHAR buffer[1024];
GetWindowText(GetDlgItem(_hwnd, IDC_FILTER), buffer, COUNTOF(buffer)); GetWindowText(GetDlgItem(_hwnd, IDC_FILTER), buffer, COUNTOF(buffer));
#ifndef __WINE__ ///@todo _tcslwr() for Wine CharLower(buffer);
_tcslwr(buffer);
#endif
_lwr_filter = buffer; _lwr_filter = buffer;
HiddenWindow hide_listctrl(_list_ctrl); HiddenWindow hide_listctrl(_list_ctrl);
@ -230,10 +228,8 @@ void FindProgramDlg::add_entry(const FPDEntry& cache_entry)
String lwr_path = cache_entry._path; String lwr_path = cache_entry._path;
String lwr_name = cache_entry._entry->_display_name; String lwr_name = cache_entry._entry->_display_name;
#ifndef __WINE__ ///@todo _tcslwr() for Wine lwr_path.toLower();
_tcslwr(&lwr_path.at(0)); lwr_name.toLower();
_tcslwr(&lwr_name.at(0));
#endif
if (_lwr_filter.empty()) if (_lwr_filter.empty())
if (_tcsstr(lwr_name, _T("uninstal")) || _tcsstr(lwr_name, _T("deinstal"))) // filter out deinstallation links if (_tcsstr(lwr_name, _T("uninstal")) || _tcsstr(lwr_name, _T("deinstal"))) // filter out deinstallation links

View file

@ -182,9 +182,7 @@ bool FileTypeManager::is_exe_file(LPCTSTR ext)
const FileTypeInfo& FileTypeManager::operator[](String ext) const FileTypeInfo& FileTypeManager::operator[](String ext)
{ {
#ifndef __WINE__ ///@todo _tcslwr() for Wine ext.toLower();
_tcslwr(&ext.at(0));
#endif
iterator found = find(ext); iterator found = find(ext);
if (found != end()) if (found != end())
@ -414,9 +412,7 @@ const Icon& IconCache::extract(LPCTSTR path, int idx)
{ {
CachePair key(path, idx); CachePair key(path, idx);
#ifndef __WINE__ ///@todo _tcslwr() for Wine key.first.toLower();
_tcslwr(&key.first.at(0));
#endif
PathIdxMap::iterator found = _pathIdxMap.find(key); PathIdxMap::iterator found = _pathIdxMap.find(key);

View file

@ -514,7 +514,7 @@ bool Entry::get_path_base ( PTSTR path, size_t path_count, ENTRY_TYPE etype ) co
LPCTSTR name = NULL; LPCTSTR name = NULL;
TCHAR buffer[MAX_PATH]; TCHAR buffer[MAX_PATH];
if ( !path || 0 == path_count ) if (!path || path_count==0)
return false; return false;
const Entry* entry; const Entry* entry;

View file

@ -679,7 +679,7 @@ void MainFrameBase::FillBookmarks()
tvi.hInsertAfter = TVI_LAST; tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE; tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
ResString sFavorites(IDS_FAVORITES); ResString sFavorites(IDS_FAVORITES);
tvi.item.pszText = (LPTSTR)sFavorites.c_str(); tvi.item.pszText = sFavorites.str();
tvi.item.iSelectedImage = tvi.item.iImage = 0; tvi.item.iSelectedImage = tvi.item.iImage = 0;
HTREEITEM hitem_bookmarks = TreeView_InsertItem(_hsidebar, &tvi); HTREEITEM hitem_bookmarks = TreeView_InsertItem(_hsidebar, &tvi);
@ -1673,7 +1673,7 @@ void SDIMainFrame::entry_selected(Entry* entry)
TCHAR path[MAX_PATH]; TCHAR path[MAX_PATH];
if (shell_entry->get_path(path,COUNTOF(path))) { if (shell_entry->get_path(path, COUNTOF(path))) {
String url; String url;
if (path[0] == ':') if (path[0] == ':')

View file

@ -128,7 +128,7 @@ ShellPath ShellEntry::create_absolute_pidl() const
// get full path of a shell entry // get full path of a shell entry
bool ShellEntry::get_path(PTSTR path, size_t path_count) const bool ShellEntry::get_path(PTSTR path, size_t path_count) const
{ {
if ( !path || 0 == path_count ) if (!path || path_count==0)
return false; return false;
/* /*
path[0] = TEXT('\0'); path[0] = TEXT('\0');
@ -152,7 +152,7 @@ bool ShellDirectory::get_path(PTSTR path, size_t path_count) const
{ {
CONTEXT("ShellDirectory::get_path()"); CONTEXT("ShellDirectory::get_path()");
if ( !path || 0 == path_count ) if (!path || path_count==0)
return false; return false;
path[0] = TEXT('\0'); path[0] = TEXT('\0');

View file

@ -161,7 +161,7 @@ bool UnixEntry::get_path(PTSTR path, size_t path_count) const
int level = 0; int level = 0;
size_t len = 0; size_t len = 0;
if ( !path || 0 == path_count ) if (!path || path_count==0)
return false; return false;
if ( path_count > 1 ) if ( path_count > 1 )

View file

@ -282,7 +282,7 @@ int QuickLaunchBar::Notify(int id, NMHDR* pnmh)
NMTTDISPINFO* ttdi = (NMTTDISPINFO*) pnmh; NMTTDISPINFO* ttdi = (NMTTDISPINFO*) pnmh;
int id = ttdi->hdr.idFrom; int id = ttdi->hdr.idFrom;
ttdi->lpszText = (LPTSTR)_entries[id]._title.c_str(); ttdi->lpszText = _entries[id]._title.str();
#ifdef TTF_DI_SETITEM #ifdef TTF_DI_SETITEM
ttdi->uFlags |= TTF_DI_SETITEM; ttdi->uFlags |= TTF_DI_SETITEM;
#endif #endif

View file

@ -257,9 +257,7 @@ void StartMenu::AddShellEntries(const ShellDirectory& dir, int max, const String
*ignore_name = '\0'; *ignore_name = '\0';
String lwr_filter = _create_info._filter; String lwr_filter = _create_info._filter;
#ifndef __WINE__ ///@todo _tcslwr() for Wine lwr_filter.toLower();
_tcslwr((LPTSTR)lwr_filter.c_str());
#endif
int cnt = 0; int cnt = 0;
for(Entry*entry=dir._down; entry; entry=entry->_next) { for(Entry*entry=dir._down; entry; entry=entry->_next) {
@ -281,10 +279,8 @@ void StartMenu::AddShellEntries(const ShellDirectory& dir, int max, const String
String lwr_name = entry->_data.cFileName; String lwr_name = entry->_data.cFileName;
String lwr_disp = entry->_display_name; String lwr_disp = entry->_display_name;
#ifndef __WINE__ ///@todo _tcslwr() for Wine lwr_name.toLower();
_tcslwr((LPTSTR)lwr_name.c_str()); lwr_disp.toLower();
_tcslwr((LPTSTR)lwr_disp.c_str());
#endif
if (!_tcsstr(lwr_name,lwr_filter) && !_tcsstr(lwr_disp,lwr_filter)) if (!_tcsstr(lwr_name,lwr_filter) && !_tcsstr(lwr_disp,lwr_filter))
continue; continue;
@ -1548,7 +1544,6 @@ StartMenuRoot::StartMenuRoot(HWND hwnd)
try { try {
// insert directory "<user name>\Start Menu" // insert directory "<user name>\Start Menu"
ShellDirectory usr_startmenu(GetDesktopFolder(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd); ShellDirectory usr_startmenu(GetDesktopFolder(), SpecialFolderPath(CSIDL_STARTMENU, _hwnd), _hwnd);
_dirs.push_back(StartMenuDirectory(usr_startmenu, (LPCTSTR)SpecialFolderFSPath(CSIDL_PROGRAMS, _hwnd))); _dirs.push_back(StartMenuDirectory(usr_startmenu, (LPCTSTR)SpecialFolderFSPath(CSIDL_PROGRAMS, _hwnd)));
} catch(COMException&) { } catch(COMException&) {
@ -2217,9 +2212,7 @@ void FavoritesMenu::AddEntries()
super::AddEntries(); super::AddEntries();
String lwr_filter = _create_info._filter; String lwr_filter = _create_info._filter;
#ifndef __WINE__ ///@todo _tcslwr() for Wine lwr_filter.toLower();
_tcslwr((LPTSTR)lwr_filter.c_str());
#endif
for(BookmarkList::iterator it=_bookmarks.begin(); it!=_bookmarks.end(); ++it) { for(BookmarkList::iterator it=_bookmarks.begin(); it!=_bookmarks.end(); ++it) {
BookmarkNode& node = *it; BookmarkNode& node = *it;
@ -2246,11 +2239,9 @@ void FavoritesMenu::AddEntries()
String lwr_desc = bookmark._description; String lwr_desc = bookmark._description;
String lwr_url = bookmark._url; String lwr_url = bookmark._url;
#ifndef __WINE__ ///@todo _tcslwr() for Wine lwr_name.toLower();
_tcslwr((LPTSTR)lwr_name.c_str()); lwr_desc.toLower();
_tcslwr((LPTSTR)lwr_desc.c_str()); lwr_url.toLower();
_tcslwr((LPTSTR)lwr_url.c_str());
#endif
if (!_tcsstr(lwr_name,lwr_filter) && !_tcsstr(lwr_desc,lwr_filter) && !_tcsstr(lwr_url,lwr_filter)) if (!_tcsstr(lwr_name,lwr_filter) && !_tcsstr(lwr_desc,lwr_filter) && !_tcsstr(lwr_url,lwr_filter))
continue; continue;

View file

@ -555,7 +555,7 @@ int NotifyArea::Notify(int id, NMHDR* pnmh)
static ResString sShowIcons(IDS_SHOW_HIDDEN_ICONS); static ResString sShowIcons(IDS_SHOW_HIDDEN_ICONS);
static ResString sHideIcons(IDS_HIDE_ICONS); static ResString sHideIcons(IDS_HIDE_ICONS);
pdi->lpszText = (LPTSTR)(_show_hidden? sHideIcons: sShowIcons).c_str(); pdi->lpszText = (_show_hidden? sHideIcons: sShowIcons).str();
} else { } else {
NotifyIconSet::iterator found = IconHitTest(pt); NotifyIconSet::iterator found = IconHitTest(pt);
@ -565,7 +565,7 @@ int NotifyArea::Notify(int id, NMHDR* pnmh)
// enable multiline tooltips (break at CR/LF and for very long one-line strings) // enable multiline tooltips (break at CR/LF and for very long one-line strings)
SendMessage(pnmh->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 400); SendMessage(pnmh->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 400);
pdi->lpszText = (LPTSTR)entry._tipText.c_str(); pdi->lpszText = entry._tipText.str();
} }
} }
} }
@ -974,24 +974,24 @@ void TrayNotifyDlg::Refresh()
tv.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE; tv.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
ResString str_cur(IDS_ITEMS_CUR); ResString str_cur(IDS_ITEMS_CUR);
tv.pszText = (LPTSTR)str_cur.c_str(); tv.pszText = str_cur.str();
tv.iSelectedImage = tv.iImage = 0; // IDI_DOT tv.iSelectedImage = tv.iImage = 0; // IDI_DOT
_hitemCurrent = TreeView_InsertItem(_tree_ctrl, &tvi); _hitemCurrent = TreeView_InsertItem(_tree_ctrl, &tvi);
ResString str_conf(IDS_ITEMS_CONFIGURED); ResString str_conf(IDS_ITEMS_CONFIGURED);
tv.pszText = (LPTSTR)str_conf.c_str(); tv.pszText = str_conf.str();
tv.iSelectedImage = tv.iImage = 2; // IDI_DOT_RED tv.iSelectedImage = tv.iImage = 2; // IDI_DOT_RED
_hitemConfig = TreeView_InsertItem(_tree_ctrl, &tvi); _hitemConfig = TreeView_InsertItem(_tree_ctrl, &tvi);
tvi.hParent = _hitemCurrent; tvi.hParent = _hitemCurrent;
ResString str_visible(IDS_ITEMS_VISIBLE); ResString str_visible(IDS_ITEMS_VISIBLE);
tv.pszText = (LPTSTR)str_visible.c_str(); tv.pszText = str_visible.str();
tv.iSelectedImage = tv.iImage = 0; // IDI_DOT tv.iSelectedImage = tv.iImage = 0; // IDI_DOT
_hitemCurrent_visible = TreeView_InsertItem(_tree_ctrl, &tvi); _hitemCurrent_visible = TreeView_InsertItem(_tree_ctrl, &tvi);
ResString str_hidden(IDS_ITEMS_HIDDEN); ResString str_hidden(IDS_ITEMS_HIDDEN);
tv.pszText = (LPTSTR)str_hidden.c_str(); tv.pszText = str_hidden.str();
tv.iSelectedImage = tv.iImage = 1; // IDI_DOT_TRANS tv.iSelectedImage = tv.iImage = 1; // IDI_DOT_TRANS
_hitemCurrent_hidden = TreeView_InsertItem(_tree_ctrl, &tvi); _hitemCurrent_hidden = TreeView_InsertItem(_tree_ctrl, &tvi);
@ -1075,7 +1075,7 @@ void TrayNotifyDlg::InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyI
tv.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; tv.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
tv.lParam = (LPARAM)idx; tv.lParam = (LPARAM)idx;
tv.pszText = (LPTSTR)txt.c_str(); tv.pszText = txt.str();
tv.iSelectedImage = tv.iImage = ImageList_AddAlphaIcon(_himl, hicon, GetStockBrush(WHITE_BRUSH), hdc); tv.iSelectedImage = tv.iImage = ImageList_AddAlphaIcon(_himl, hicon, GetStockBrush(WHITE_BRUSH), hdc);
(void)TreeView_InsertItem(_tree_ctrl, &tvi); (void)TreeView_InsertItem(_tree_ctrl, &tvi);
} }

View file

@ -798,6 +798,8 @@ struct String
operator wstring() const {WCHAR b[BUFFER_LEN]; return wstring(b, MultiByteToWideChar(CP_ACP, 0, c_str(), -1, b, BUFFER_LEN)-1);} operator wstring() const {WCHAR b[BUFFER_LEN]; return wstring(b, MultiByteToWideChar(CP_ACP, 0, c_str(), -1, b, BUFFER_LEN)-1);}
#endif #endif
LPTSTR str() {return (LPTSTR)data();} /// return modifyable character string pointer
String& printf(LPCTSTR fmt, ...) String& printf(LPCTSTR fmt, ...)
{ {
va_list l; va_list l;
@ -839,6 +841,12 @@ struct String
return *this; return *this;
} }
void toLower()
{
if (!empty())
CharLower(str());
}
}; };
#define _STRING_DEFINED #define _STRING_DEFINED