Browse Source

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 years ago
parent
commit
dc9620460c
2 changed files with 16 additions and 9 deletions
  1. 2
    1
      child.cpp
  2. 14
    8
      child.hpp

+ 2
- 1
child.cpp View File

#endif #endif
} }
ChildStream::ChildStreambuf::ChildStreambuf(std::size_t bufferSize) :
ChildStream::ChildStreambuf::ChildStreambuf(std::size_t bufSize) :
#ifdef _WIN32 #ifdef _WIN32
inputHandle(0), inputHandle(0),
outputHandle(0), outputHandle(0),
inputFileDescriptor(-1), inputFileDescriptor(-1),
outputFileDescriptor(-1), outputFileDescriptor(-1),
#endif #endif
bufferSize(bufSize),
readBuffer(bufferSize + 1), readBuffer(bufferSize + 1),
writeBuffer(bufferSize + 1) { writeBuffer(bufferSize + 1) {

+ 14
- 8
child.hpp View File



/// Constructor. /// 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. // 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 #ifdef _WIN32


/// Override streambuf::sync(). /// Override streambuf::sync().
int sync(); int sync();


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

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

/// Input and output handles. /// Input and output handles.
#ifdef _WIN32 #ifdef _WIN32
HANDLE inputHandle; HANDLE inputHandle;
int outputFileDescriptor; int outputFileDescriptor;
#endif #endif


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

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


/// Write buffer. /// Write buffer.
std::vector<char> writeBuffer; 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 /// Stream buffer for reading from the stdout and writing to the

Loading…
Cancel
Save