stdout/iobuf - managed code equivalent

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • noel.phillips@gmail.com

    #1

    stdout/iobuf - managed code equivalent

    Hi,

    I am porting a C++ console application to managed C++ dll - for now
    basically wrapping it in a class. The console app has the option to
    write to a file or stdout using fwrite.

    So, how do I bridge the managed gap? I really want to be able to pass
    a BinaryStream to the managed C++ code from the calling C# code...can
    this be done, and how do I go about modifying the C++ code to handle
    it?

    Any pointers would be appreciated...

    Many thanks,
    Noel

  • Pavel A.

    #2
    RE: stdout/iobuf - managed code equivalent

    "noel.phillips@ gmail.com" wrote:
    Hi,
    >
    I am porting a C++ console application to managed C++ dll - for now
    basically wrapping it in a class. The console app has the option to
    write to a file or stdout using fwrite.
    >
    So, how do I bridge the managed gap? I really want to be able to pass
    a BinaryStream to the managed C++ code from the calling C# code...can
    this be done, and how do I go about modifying the C++ code to handle
    it?
    >
    Any pointers would be appreciated...
    >
    Many thanks,
    Noel
    By common sense, stdin etc are text, not binary?

    If you really need to pipeline binary objects, have look at the Monad,
    aka "power shell"
    http://www.microsoft.com/windowsserv...l/default.mspx

    --PA


    Comment

    • Ben Voigt

      #3
      Re: stdout/iobuf - managed code equivalent


      <noel.phillips@ gmail.comwrote in message
      news:1155676048 .182540.4130@h4 8g2000cwc.googl egroups.com...
      Hi,
      >
      I am porting a C++ console application to managed C++ dll - for now
      basically wrapping it in a class. The console app has the option to
      write to a file or stdout using fwrite.
      >
      So, how do I bridge the managed gap? I really want to be able to pass
      a BinaryStream to the managed C++ code from the calling C# code...can
      this be done, and how do I go about modifying the C++ code to handle
      it?
      If it's determined to use fwrite, then you will have to capture the data
      with a pipe. A combination of _pipe, _fdopen will give you a FILE* that the
      existing code can fwrite to. Then you can either wrap the other end of the
      pipe in a BinaryStream and give that to your C# code, or else read from the
      pipe, writing into the BinaryStream provided by the C# code.

      But fwrite's interface is so simple, you should probably just
      #define fwrite streamwrite
      and write your own size_t streamwrite( const void * buffer, size_t size,
      size_t count, FILE * stream ) function that puts the data where you want it.
      >
      Any pointers would be appreciated...
      >
      Many thanks,
      Noel
      >

      Comment

      Working...