F
fade
Good afternoon,
I need some advice on the following:
I've got a class that has a member
std::vector<CString> m_vFileName and a member CString m_path;
The vector contains a bunch of filenames with no path included
(no C:\...) eg: my_file2.jpg, my_file1.bmp, etc...
and m_path stores the path, eg: C:\folder1
I want to sort this vector according to different criterion, such as
filename(asc, desc), date(asc, desc), size(asc, desc).
To sort the vector by filename I use this comparison function:
bool sortVectorByNameUp(CString s1, CString s2)
{ return (s1.CompareNoCase(s2) <= 0)? true : false; }
the call is std::sort(m_vFileName.begin(), m_vFileName.end(),
sortVectorByNameUp);
To sort this vector by date I need to obtain last access time for every
file, and for that, I need to read m_path
I can't pass m_path as a parameter because (I think), sortVectorByNameUp
must be a binary function.
If I make this function a member of my class
eg: bool Cteste8View::sortVectorByNameUp(CString s1, CString s2)
I get compilation errors:
..\teste8View.cpp(478) : error C3867: 'Cteste8View::sortVectorByNameUp':
function call missing argument list; use
'&Cteste8View::sortVectorByNameUp' to create a pointer to member
..\teste8View.cpp(478) : error C2780: 'void std::sort(_RanIt,_RanIt)' :
expects 2 arguments - 3 provided
C:\Program Files\Microsoft Visual Studio 8\VC\include\algorithm
(2751) : see declaration of 'std::sort'
I've tried making the call like this:
std::sort(m_vFileName.begin(), m_vFileName.end(),
&Cteste8View::sortVectorByNameUp);
but it doesn't work either
Is there a way to have access to m_path inside the comparison function,
besides using a global variable as intermediate?
And what is the best way to get size and last access time from a file?
Thanks a lot in advance
I need some advice on the following:
I've got a class that has a member
std::vector<CString> m_vFileName and a member CString m_path;
The vector contains a bunch of filenames with no path included
(no C:\...) eg: my_file2.jpg, my_file1.bmp, etc...
and m_path stores the path, eg: C:\folder1
I want to sort this vector according to different criterion, such as
filename(asc, desc), date(asc, desc), size(asc, desc).
To sort the vector by filename I use this comparison function:
bool sortVectorByNameUp(CString s1, CString s2)
{ return (s1.CompareNoCase(s2) <= 0)? true : false; }
the call is std::sort(m_vFileName.begin(), m_vFileName.end(),
sortVectorByNameUp);
To sort this vector by date I need to obtain last access time for every
file, and for that, I need to read m_path
I can't pass m_path as a parameter because (I think), sortVectorByNameUp
must be a binary function.
If I make this function a member of my class
eg: bool Cteste8View::sortVectorByNameUp(CString s1, CString s2)
I get compilation errors:
..\teste8View.cpp(478) : error C3867: 'Cteste8View::sortVectorByNameUp':
function call missing argument list; use
'&Cteste8View::sortVectorByNameUp' to create a pointer to member
..\teste8View.cpp(478) : error C2780: 'void std::sort(_RanIt,_RanIt)' :
expects 2 arguments - 3 provided
C:\Program Files\Microsoft Visual Studio 8\VC\include\algorithm
(2751) : see declaration of 'std::sort'
I've tried making the call like this:
std::sort(m_vFileName.begin(), m_vFileName.end(),
&Cteste8View::sortVectorByNameUp);
but it doesn't work either
Is there a way to have access to m_path inside the comparison function,
besides using a global variable as intermediate?
And what is the best way to get size and last access time from a file?
Thanks a lot in advance