473,324 Members | 2,417 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,324 software developers and data experts.

how to import STL vector to STL

How can I import the following COM interface to C#?

DECLARE_INTERFACE_(IVertices, IUnknown)
{
STDMETHOD(get_vertices) (THIS_ vector<POINT>& vertices) PURE;

STDMETHOD(set_vertices) (THIS_ vector<POINTvertices) PURE;
};

Is it possible to import STL containers to C# at all?
Dec 3 '07 #1
2 2740
On Dec 3, 4:45 pm, Builder <peter.gej...@gmail.comwrote:
How can I import the following COM interface to C#?

DECLARE_INTERFACE_(IVertices, IUnknown)
{
STDMETHOD(get_vertices) (THIS_ vector<POINT>& vertices) PURE;

STDMETHOD(set_vertices) (THIS_ vector<POINTvertices) PURE;
};

Is it possible to import STL containers to C# at all?
Not that I know of. When crossing from COM to managed code you will
probably want to copy the elements from the STL container to (one or
more) arrays on the COM side, then copy from the arrays to
System.Collections (.*) on the managed side.

You'll have to tell .NET the layout of non-primitive array elements;
one way to do this is to define them in the IDL (inside the library)
so that the type library importer will automatically create managed
equivalents for you.
Dec 3 '07 #2
Builder... If you want to stick to STL you can convert a standard STL
Vector to a STL/CLI Vector in C++/CLI.

// test standard STL to STL/CLI
std::vector<std::stringstdVector;
stdVector.reserve(2);
stdVector.push_back("Hello");
stdVector.push_back("World");

vector<String^cliVector;
cliVector.reserve(2);

std::vector<std::string>::iterator it3= stdVector.begin();
for(;it3 != stdVector.end();it3++) {
cliVector.push_back(Util::ConvertCS2MS(*it3));
}

vector<String^>::iterator it4= cliVector.begin();
for(;it4 != cliVector.end();it4++) {
Console::WriteLine(*it4);
}

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Dec 4 '07 #3

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

Similar topics

9
by: {AGUT2}=IWIK= | last post by:
Hello all, It's my fisrt post here and I am feeling a little stupid here, so go easy.. :) (Oh, and I've spent _hours_ searching...) I am desperately trying to read in an ASCII...
9
by: luigi | last post by:
Hi, I am trying to speed up the perfomance of stl vector by allocating/deallocating blocks of memory manually. one version of the code crashes when I try to free the memory. The other version...
7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
7
by: cppaddict | last post by:
I'd like to avoid typing std::string and std::vector without resorting to the "using namespace std" directive, which will import the entire standard namespace. Is there a way to import only...
34
by: Adam Hartshorne | last post by:
Hi All, I have the following problem, and I would be extremely grateful if somebody would be kind enough to suggest an efficient solution to it. I create an instance of a Class A, and...
10
by: Bob | last post by:
Here's what I have: void miniVector<T>::insertOrder(miniVector<T>& v,const T& item) { int i, j; T target; vSize += 1; T newVector; newVector=new T;
8
by: Ross A. Finlayson | last post by:
I'm trying to write some C code, but I want to use C++'s std::vector. Indeed, if the code is compiled as C++, I want the container to actually be std::vector, in this case of a collection of value...
16
by: Martin Jørgensen | last post by:
Hi, I get this using g++: main.cpp:9: error: new types may not be defined in a return type main.cpp:9: note: (perhaps a semicolon is missing after the definition of 'vector') main.cpp:9:...
6
by: zl2k | last post by:
hi, there I am using a big, sparse binary array (size of 256^3). The size may be changed in run time. I first thought about using the bitset but found its size is unchangeable. If I use the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.