From f385722728b5f2ac5bbe2fc57b9953d21f76b7eb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 7 Nov 2002 13:16:29 +0000 Subject: [PATCH] made SameAs() and operator==() const, added operator!=() and docs for it git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17756 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/filename.tex | 18 ++++++++++++++---- include/wx/filename.h | 21 ++++++++++++++------- src/common/filename.cpp | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/docs/latex/wx/filename.tex b/docs/latex/wx/filename.tex index f56df752b3..5c85079447 100644 --- a/docs/latex/wx/filename.tex +++ b/docs/latex/wx/filename.tex @@ -598,7 +598,7 @@ Deletes the specified directory from the file system. \membersection{wxFileName::SameAs}\label{wxfilenamesameas} -\func{bool}{SameAs}{\param{const wxFileName\& }{filepath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} +\constfunc{bool}{SameAs}{\param{const wxFileName\& }{filepath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}} Compares the filename using the rules of this platform. @@ -674,9 +674,19 @@ Assigns the new value to this filename object. \membersection{wxFileName::operator==}\label{wxfilenameoperatorequal} -\func{bool operator}{operator==}{\param{const wxFileName\& }{filename}} +\constfunc{bool operator}{operator==}{\param{const wxFileName\& }{filename}} -\func{bool operator}{operator==}{\param{const wxString\& }{filename}} +\constfunc{bool operator}{operator==}{\param{const wxString\& }{filename}} -Returns {\tt TRUE} if the filenames are equal for the native file format. +Returns {\tt TRUE} if the filenames are equal. The string {\it filenames} is +interpreted as a path in the native filename format. + +\membersection{wxFileName::operator!=}\label{wxfilenameoperatornotequal} + +\constfunc{bool operator}{operator!=}{\param{const wxFileName\& }{filename}} + +\constfunc{bool operator}{operator!=}{\param{const wxString\& }{filename}} + +Returns {\tt TRUE} if the filenames are different. The string {\it filenames} +is interpreted as a path in the native filename format. diff --git a/include/wx/filename.h b/include/wx/filename.h index 491e7deecc..38e6645e06 100644 --- a/include/wx/filename.h +++ b/include/wx/filename.h @@ -274,14 +274,21 @@ public: // Comparison - // compares with the rules of this platform - bool SameAs(const wxFileName &filepath, - wxPathFormat format = wxPATH_NATIVE); + // compares with the rules of the given platforms format + bool SameAs(const wxFileName& filepath, + wxPathFormat format = wxPATH_NATIVE) const; - // uses the current platform settings - bool operator==(const wxFileName& filename) { return SameAs(filename); } - bool operator==(const wxString& filename) - { return *this == wxFileName(filename); } + // compare with another filename object + bool operator==(const wxFileName& filename) const + { return SameAs(filename); } + bool operator!=(const wxFileName& filename) const + { return !SameAs(filename); } + + // compare with a filename string interpreted as a native file name + bool operator==(const wxString& filename) const + { return SameAs(wxFileName(filename)); } + bool operator!=(const wxString& filename) const + { return !SameAs(wxFileName(filename)); } // are the file names of this type cases sensitive? static bool IsCaseSensitive( wxPathFormat format = wxPATH_NATIVE ); diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 63d3a482bf..f56ec3d5ef 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -1022,7 +1022,7 @@ bool wxFileName::MakeRelativeTo(const wxString& pathBase, wxPathFormat format) // filename kind tests // ---------------------------------------------------------------------------- -bool wxFileName::SameAs(const wxFileName &filepath, wxPathFormat format) +bool wxFileName::SameAs(const wxFileName& filepath, wxPathFormat format) const { wxFileName fn1 = *this, fn2 = filepath;