|
From: Don-Duong Q. <dj...@ya...> - 2002-09-29 18:22:23
|
Here's a code snippet from the managed C++ wrapper for gb::io::BinaryStream.
#include "gbio/binarystream.h" // C++ class#using <MSCORLIB.DLL>using namespace System::Runtime::InteropServices;namespace gb { namespace cs { namespace io { public __gc class BinaryStream { public: BinaryStream () { _p = new gb::io::BinaryStream (); } virtual ~BinaryStream () { delete _p; _p = 0; } int Open (System::String* s, int mode) { char *c_string = (char*)((void*)Marshal::StringToHGlobalAnsi (s)); // throws System.NullReferenceException int ret = _p->Open (c_string, mode); Marshal::FreeHGlobal ((System::IntPtr)((void*)c_string)); return ret; } void Close () { _p->Close (); } // ...more code ....// private: gb::io::BinaryStream* _p; };}// io}// cs}// gb
From "gbio/binarystream.h" int gb::io::BinaryStream::Open (const std::string& filename, int mode) { mMode = std::ios_base::binary; if (mode == READ) mMode |= std::ios::in; else if (mode == WRITE) mMode |= std::ios::out; else return 0; open (filename.c_str (), mMode); return good (); }
Thanks, Don
---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo! |