]> git.saurik.com Git - wxWidgets.git/commitdiff
Extract wxPipeInputStream and wxPipeOutputStream in a header.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 3 Jul 2013 00:26:38 +0000 (00:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 3 Jul 2013 00:26:38 +0000 (00:26 +0000)
No real changes, just put these classes in a private header. They're still not
part of the public API but at least it will be easier to reuse them inside the
library itself in the upcoming commits.

See #10258.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74336 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/private/pipestream.h [new file with mode: 0644]
include/wx/private/pipestream.h [new file with mode: 0644]
include/wx/unix/pipe.h
include/wx/unix/private/pipestream.h [new file with mode: 0644]
src/msw/utilsexc.cpp
src/unix/utilsunx.cpp

diff --git a/include/wx/msw/private/pipestream.h b/include/wx/msw/private/pipestream.h
new file mode 100644 (file)
index 0000000..839084d
--- /dev/null
@@ -0,0 +1,51 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/msw/private/pipestream.h
+// Purpose:     MSW wxPipeInputStream and wxPipeOutputStream declarations
+// Author:      Vadim Zeitlin
+// Created:     2013-06-08 (extracted from src/msw/utilsexc.cpp)
+// RCS-ID:      $Id$
+// Copyright:   (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_MSW_PRIVATE_PIPESTREAM_H_
+#define _WX_MSW_PRIVATE_PIPESTREAM_H_
+
+class wxPipeInputStream : public wxInputStream
+{
+public:
+    wxEXPLICIT wxPipeInputStream(HANDLE hInput);
+    virtual ~wxPipeInputStream();
+
+    // returns true if the pipe is still opened
+    bool IsOpened() const { return m_hInput != INVALID_HANDLE_VALUE; }
+
+    // returns true if there is any data to be read from the pipe
+    virtual bool CanRead() const;
+
+protected:
+    virtual size_t OnSysRead(void *buffer, size_t len);
+
+protected:
+    HANDLE m_hInput;
+
+    wxDECLARE_NO_COPY_CLASS(wxPipeInputStream);
+};
+
+class wxPipeOutputStream: public wxOutputStream
+{
+public:
+    wxEXPLICIT wxPipeOutputStream(HANDLE hOutput);
+    virtual ~wxPipeOutputStream() { Close(); }
+    bool Close();
+
+protected:
+    size_t OnSysWrite(const void *buffer, size_t len);
+
+protected:
+    HANDLE m_hOutput;
+
+    wxDECLARE_NO_COPY_CLASS(wxPipeOutputStream);
+};
+
+#endif // _WX_MSW_PRIVATE_PIPESTREAM_H_
diff --git a/include/wx/private/pipestream.h b/include/wx/private/pipestream.h
new file mode 100644 (file)
index 0000000..4cf5c30
--- /dev/null
@@ -0,0 +1,30 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/private/pipestream.h
+// Purpose:     Declares wxPipeInputStream and wxPipeOutputStream.
+// Author:      Vadim Zeitlin
+// Modified by: Rob Bresalier
+// Created:     2013-04-27
+// RCS-ID:      $Id$
+// Copyright:   (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
+//              (c) 2013 Rob Bresalier
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_PRIVATE_PIPESTREAM_H_
+#define _WX_PRIVATE_PIPESTREAM_H_
+
+#include "wx/platform.h"
+
+// wxPipeInputStream is a platform-dependent input stream class (i.e. deriving,
+// possible indirectly, from wxInputStream) for reading from a pipe, i.e. a
+// pipe FD under Unix or a pipe HANDLE under MSW. It provides a single extra
+// IsOpened() method.
+//
+// wxPipeOutputStream is similar but has no additional methods at all.
+#ifdef __UNIX__
+    #include "wx/unix/private/pipestream.h"
+#elif defined(__WINDOWS__) && !defined(__WXWINCE__)
+    #include "wx/msw/private/pipestream.h"
+#endif
+
+#endif // _WX_PRIVATE_PIPESTREAM_H_
index e4799024edb7f4d274c3dd0fa8893a4a6db0acdb..1a33302259080966c6e5269c3c38c1412ce285ee 100644 (file)
@@ -98,41 +98,5 @@ private:
     int m_fds[2];
 };
 
-#if wxUSE_STREAMS && wxUSE_FILE
-
-#include "wx/wfstream.h"
-
-// ----------------------------------------------------------------------------
-// wxPipeInputStream: stream for reading from a pipe
-// ----------------------------------------------------------------------------
-
-class wxPipeInputStream : public wxFileInputStream
-{
-public:
-    wxPipeInputStream(int fd) : wxFileInputStream(fd) { }
-
-    // return TRUE if the pipe is still opened
-    bool IsOpened() const { return !Eof(); }
-
-    // return TRUE if we have anything to read, don't block
-    virtual bool CanRead() const;
-};
-
-// ----------------------------------------------------------------------------
-// wxPipeOutputStream: stream for writing to a pipe
-// ----------------------------------------------------------------------------
-
-class wxPipeOutputStream : public wxFileOutputStream
-{
-public:
-    wxPipeOutputStream(int fd) : wxFileOutputStream(fd) { }
-
-    // Override the base class version to ignore "pipe full" errors: this is
-    // not an error for this class.
-    size_t OnSysWrite(const void *buffer, size_t size);
-};
-
-#endif // wxUSE_STREAMS && wxUSE_FILE
-
 #endif // _WX_UNIX_PIPE_H_
 
diff --git a/include/wx/unix/private/pipestream.h b/include/wx/unix/private/pipestream.h
new file mode 100644 (file)
index 0000000..e57b4d3
--- /dev/null
@@ -0,0 +1,38 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        wx/unix/private/pipestream.h
+// Purpose:     Unix wxPipeInputStream and wxPipeOutputStream declarations
+// Author:      Vadim Zeitlin
+// Created:     2013-06-08 (extracted from wx/unix/pipe.h)
+// RCS-ID:      $Id$
+// Copyright:   (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_UNIX_PRIVATE_PIPESTREAM_H_
+#define _WX_UNIX_PRIVATE_PIPESTREAM_H_
+
+#include "wx/wfstream.h"
+
+class wxPipeInputStream : public wxFileInputStream
+{
+public:
+    wxEXPLICIT wxPipeInputStream(int fd) : wxFileInputStream(fd) { }
+
+    // return true if the pipe is still opened
+    bool IsOpened() const { return !Eof(); }
+
+    // return true if we have anything to read, don't block
+    virtual bool CanRead() const;
+};
+
+class wxPipeOutputStream : public wxFileOutputStream
+{
+public:
+    wxPipeOutputStream(int fd) : wxFileOutputStream(fd) { }
+
+    // Override the base class version to ignore "pipe full" errors: this is
+    // not an error for this class.
+    size_t OnSysWrite(const void *buffer, size_t size);
+};
+
+#endif // _WX_UNIX_PRIVATE_PIPESTREAM_H_
index 9c959de05ed4231c672ab89a6c4f8ea036943bc9..cd4f5b86b244bff86a89dec885fabd8f00d8d3f4 100644 (file)
@@ -201,46 +201,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxExecuteModule, wxModule)
 
 #if wxUSE_STREAMS && !defined(__WXWINCE__)
 
-// ----------------------------------------------------------------------------
-// wxPipeStreams
-// ----------------------------------------------------------------------------
-
-class wxPipeInputStream: public wxInputStream
-{
-public:
-    wxPipeInputStream(HANDLE hInput);
-    virtual ~wxPipeInputStream();
-
-    // returns true if the pipe is still opened
-    bool IsOpened() const { return m_hInput != INVALID_HANDLE_VALUE; }
-
-    // returns true if there is any data to be read from the pipe
-    virtual bool CanRead() const;
-
-protected:
-    size_t OnSysRead(void *buffer, size_t len);
-
-protected:
-    HANDLE m_hInput;
-
-    wxDECLARE_NO_COPY_CLASS(wxPipeInputStream);
-};
-
-class wxPipeOutputStream: public wxOutputStream
-{
-public:
-    wxPipeOutputStream(HANDLE hOutput);
-    virtual ~wxPipeOutputStream() { Close(); }
-    bool Close();
-
-protected:
-    size_t OnSysWrite(const void *buffer, size_t len);
-
-protected:
-    HANDLE m_hOutput;
-
-    wxDECLARE_NO_COPY_CLASS(wxPipeOutputStream);
-};
+#include "wx/private/pipestream.h"
 
 // define this to let wxexec.cpp know that we know what we're doing
 #define _WX_USED_BY_WXEXECUTE_
index bba1eb7be5cf7d2c9cdc210bf40698f377061cbd..fb2854f847177fa5fdd13cfd8c9969f68255b271 100644 (file)
@@ -63,6 +63,8 @@
 
 #if HAS_PIPE_STREAMS
 
+#include "wx/private/pipestream.h"
+
 // define this to let wxexec.cpp know that we know what we're doing
 #define _WX_USED_BY_WXEXECUTE_
 #include "../common/execcmn.cpp"