You could always have your class implement ZeroCopyInputStream and *contain*
an implementation of CopyingInputStream, like:
  class MyStream : public ZeroCopyInputStream {
    virtual ~MyStream();

    CopyingInputStream* AsCopyingInputStream() {
      return &copying_stream_;


    class MyCopyingInputStreamAdaptor : public CopyingInputStream {
      MyCopyingInputStreamAdaptor(MyStream* stream);
    MyCopyingInputStreamAdaptor copying_stream_;

This way you do not need to implement both interfaces with a single class.

On Mon, Oct 20, 2008 at 7:18 PM, <[EMAIL PROTECTED]> wrote:

> Hi,
> The ZeroCopyInputStream and CopyingInputStream classes both define a
> Skip() function, but one returns a bool and the other returns an int.
> Because of this, they are not compatible, so I can't write a class
> that implements both interfaces for example.
> It is sometimes useful to be able to implement both interfaces.  I
> wrote a zero copy socket input stream, and having the ability to use
> the copying interface is desirable for ease of use (and testing).  So
> I wrote a Read() function that calls Next()/BackUp() then do a
> memcpy.  This can even be a generic function in the "abstract"
> interface.  This is what Java does for example:
> It feels wrong to me that the two interfaces are incompatible by
> design, and it would be really cool if I can write something that
> implements both (so I can have a Skip() function for one).
> Making the ZeroCopy version of Skip() returns an int instead of bool
> would make this possible.  What do you think?
> Frank
> >

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to