473,387 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

Aug 15 '06 #1
2 2789
"no***********@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
Aug 16 '06 #2

<no***********@gmail.comwrote in message
news:11********************@h48g2000cwc.googlegrou ps.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

Aug 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Paul | last post by:
I'm porting a C++ function which reads a file in binary mode, sometimes reading 2 bytes into an unsigned short, 4 bytes into a long, etc into a C# implementation. When using the FileStream.Read...
4
by: Nadav | last post by:
Hi, I hope this post will find it's way to some MS technical authority... I am experienced with bought Unmanaged C++ and Managed code ( C# ), There are some issues with the .NET framework that...
4
by: repstat | last post by:
Hi I have a project which is going to be doing some string manipulation which needs to be pretty fast. The user interface is going to be written in C#. I am going to write the string handling...
1
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
3
by: Tommy Svensson \(InfoGrafix\) | last post by:
I've been instructed to work againt a huge unmanaged C++ API from a C# application. Now, the only way, as I've understood it, is to go the Managed Extensions for C++ way. This means I have to...
7
by: Tim | last post by:
When there is a need to pass some dynamic information between 2 managed assemblies, the "Dictionary object" in Generic form can be used as a method parameter to pass the information. The...
2
by: Kevin Sun | last post by:
I have a problem about non-managed code and managed code.Could you like to give me some suggestion? In a non-managed MFC application project, I add some managed codes and these files are setted...
5
by: achutha.sridhar | last post by:
I've a pretty basic question on managed code. I read through couple of.net documentation, and reached a state where I know that managed code would be run by the .Net run time and it has so and so...
2
by: ian.cross | last post by:
Hi everyone, If a multi-threaded .NET program creates a race condition updating a List (for example), could this cause a memory leak/overwritten memory/ access to another objects' private...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.