]> git.saurik.com Git - wxWidgets.git/commitdiff
replace changes of r49890 by defining more compatibility operators in wxCmdLineArgsAr...
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 13 Nov 2007 13:27:30 +0000 (13:27 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 13 Nov 2007 13:27:30 +0000 (13:27 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49902 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cmdargs.h
src/common/appbase.cpp
src/common/stdpbase.cpp

index e3dbd16a3683ca554966fc8a12a1c836f2469a00..e3d74c031ab3558f1bb28cc2e0ae0719b28863bd 100644 (file)
@@ -26,7 +26,7 @@
 // as it's used for compatibility, it tries to look as much as traditional
 // (char **) argv as possible, in particular it provides implicit conversions
 // to "char **" and also array-like operator[]
-class wxCmdLineArgsArray
+class WXDLLIMPEXP_BASE wxCmdLineArgsArray
 {
 public:
     wxCmdLineArgsArray() { m_argsA = NULL; m_argsW = NULL; }
@@ -80,6 +80,12 @@ public:
         return !m_args.empty();
     }
 
+    // and the same for "if ( !argv )" checks
+    bool operator!() const
+    {
+        return m_args.empty();
+    }
+
     wxString operator[](size_t n) const
     {
         return m_args[n];
@@ -92,9 +98,13 @@ public:
         return m_args[n];
     }
 
-    // this is the only method of this class which doesn't exist solely for
-    // compatibility purposes: it allows to access the arguments as a
-    // convenient array of wxStrings
+
+    // convenience methods, i.e. not existing only for backwards compatibility
+
+    // do we have any arguments at all?
+    bool IsEmpty() const { return m_args.empty(); }
+
+    // access the arguments as a convenient array of wxStrings
     const wxArrayString& GetArguments() const { return m_args; }
 
     ~wxCmdLineArgsArray()
@@ -129,6 +139,13 @@ private:
     DECLARE_NO_COPY_CLASS(wxCmdLineArgsArray)
 };
 
+// provide global operator overload for compatibility with the existing code
+// doing things like "if ( condition && argv )"
+inline operator&&(bool cond, const wxCmdLineArgsArray& array)
+{
+    return cond && !array.IsEmpty();
+}
+
 #endif // wxUSE_UNICODE
 
 #endif // _WX_CMDARGS_H_
index 27fa04d6b3fd58af6cebe62d0d21151c072a9b01..66297871a4375928766f395b6ed7bb024a8b29ec 100644 (file)
@@ -177,7 +177,7 @@ bool wxAppConsoleBase::Initialize(int& argcOrig, wxChar **argvOrig)
 #endif
 
 #ifndef __WXPALMOS__
-    if ( m_appName.empty() && (bool) argv )
+    if ( m_appName.empty() && argv )
     {
         // the application name is, by default, the name of its executable file
         wxFileName::SplitPath(argv[0], NULL, &m_appName, NULL);
index 198486075d18ad2ebb09946036dc353f84862c10..6d0609e118d33dd4eaa2786bd21c0c195ea76c68 100644 (file)
@@ -53,7 +53,7 @@ wxStandardPathsBase& wxStandardPathsBase::Get()
 
 wxString wxStandardPathsBase::GetExecutablePath() const
 {
-    if ( !wxTheApp || ! (bool) wxTheApp->argv )
+    if ( !wxTheApp || !wxTheApp->argv )
         return wxEmptyString;
 
     wxString argv0 = wxTheApp->argv[0];