How to manage DLL with complex parameters?
-
I have a compiled DLL by VC6.0, in with:
#include "argedit.h" #include "allocpool.h" template class StreamARGLoader: public ARGEdit { public: typedef Allocator NodeAllocator; typedef Allocator EdgeAllocator; StreamARGLoader(NodeAllocator *nalloc, EdgeAllocator *ealloc, istream &in); static void write(ostream &out, ARGraph &g); static void write(ostream &out, ARGLoader &g); private: enum { MAX_LINE=512 }; void readLine(istream &in, char *line); int readCount(istream &in); void readNode(NodeAllocator *alloc, istream &in); void readEdge(EdgeAllocator *alloc, istream &in); };
instruction file :int main() { // Create the allocators NewAllocator node_allocator; NullAllocator edge_allocator; // Open the file ifstream in("graph.txt"); // Create the ARGLoader StreamARGLoader loader(&node_allocator, &edge_allocator, in); // Build the graph ARGraph graph(&loader); //......
And finally hihi i don't know how to using it in C#, i face problem about NodeAllocator and istream &in Is this "StreamARGLoader" a void or a function? [DllImport("GraphMatching270606.dll", EntryPoint="StreamARGLoader",CharSet=CharSet.Auto)] public static extern void StreamARGLoader(NodeAllocator *nalloc, EdgeAllocator *ealloc, istream &in); -
I have a compiled DLL by VC6.0, in with:
#include "argedit.h" #include "allocpool.h" template class StreamARGLoader: public ARGEdit { public: typedef Allocator NodeAllocator; typedef Allocator EdgeAllocator; StreamARGLoader(NodeAllocator *nalloc, EdgeAllocator *ealloc, istream &in); static void write(ostream &out, ARGraph &g); static void write(ostream &out, ARGLoader &g); private: enum { MAX_LINE=512 }; void readLine(istream &in, char *line); int readCount(istream &in); void readNode(NodeAllocator *alloc, istream &in); void readEdge(EdgeAllocator *alloc, istream &in); };
instruction file :int main() { // Create the allocators NewAllocator node_allocator; NullAllocator edge_allocator; // Open the file ifstream in("graph.txt"); // Create the ARGLoader StreamARGLoader loader(&node_allocator, &edge_allocator, in); // Build the graph ARGraph graph(&loader); //......
And finally hihi i don't know how to using it in C#, i face problem about NodeAllocator and istream &in Is this "StreamARGLoader" a void or a function? [DllImport("GraphMatching270606.dll", EntryPoint="StreamARGLoader",CharSet=CharSet.Auto)] public static extern void StreamARGLoader(NodeAllocator *nalloc, EdgeAllocator *ealloc, istream &in);STreamArgLoader is a template class. You're gonna have one helluva time trying to expose that to C#. It's basically impossible, AFAIK. What you *can* do, though, is write a C++/CLI class that does the manipulation of the StreamARGLoader class instance. C++/CLI methods are automatically exposed to all .NET assemblies, including C#, and can still deal with regular native C++ classes including template classes. That's what I would do: write a C++/CLI shim that does whatever your C# code needs to do to the StreamARGLoader.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Goof around music jam with my brothers (with video) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango