瀏覽代碼

Tested with one streambuf for input and output, and inheriting from

iostream.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@79 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 9 年之前
父節點
當前提交
dc9620460c
共有 2 個文件被更改,包括 16 次插入9 次删除
  1. 2
    1
      child.cpp
  2. 14
    8
      child.hpp

+ 2
- 1
child.cpp 查看文件

@@ -473,7 +473,7 @@ namespace CodeDweller {
#endif
}
ChildStream::ChildStreambuf::ChildStreambuf(std::size_t bufferSize) :
ChildStream::ChildStreambuf::ChildStreambuf(std::size_t bufSize) :
#ifdef _WIN32
inputHandle(0),
outputHandle(0),
@@ -481,6 +481,7 @@ namespace CodeDweller {
inputFileDescriptor(-1),
outputFileDescriptor(-1),
#endif
bufferSize(bufSize),
readBuffer(bufferSize + 1),
writeBuffer(bufferSize + 1) {

+ 14
- 8
child.hpp 查看文件

@@ -70,10 +70,13 @@ namespace CodeDweller {

/// Constructor.
//
// \param[in] bufferSize is the size in bytes of the input
// \param[in] bufSize is the size in bytes of the input
// buffer and output buffer.
//
explicit ChildStreambuf(std::size_t bufferSize = 4096);
explicit ChildStreambuf(std::size_t bufSize = 4096);

/// Thread start function to send data to the child.
void sendToChild();

#ifdef _WIN32

@@ -141,12 +144,6 @@ namespace CodeDweller {
/// Override streambuf::sync().
int sync();

/// Copy constructor not implemented.
ChildStreambuf(const ChildStreambuf &) = delete;

/// Assignment operator not implemented.
ChildStreambuf &operator=(const ChildStreambuf &) = delete;

/// Input and output handles.
#ifdef _WIN32
HANDLE inputHandle;
@@ -156,12 +153,21 @@ namespace CodeDweller {
int outputFileDescriptor;
#endif

/// Size of buffers.
std::size_t bufferSize;

/// Read buffer.
std::vector<char> readBuffer;

/// Write buffer.
std::vector<char> writeBuffer;

/// Copy constructor not implemented.
ChildStreambuf(const ChildStreambuf &) = delete;

/// Assignment operator not implemented.
ChildStreambuf &operator=(const ChildStreambuf &) = delete;

};

/// Stream buffer for reading from the stdout and writing to the

Loading…
取消
儲存