472,791 Members | 1,075 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Passing a "str.basic_string" from C#

Hello,

I have some legacy C++ code that was re-written as a managed class. I made
a C++ class library with it and I want to use it in my C# program.

I created a reference to it and it instantiates the object ok, but when I go
to use one of it's methods I have a problem.

The method requires a "basic_string" from the std library. I do not know
what to do to get a basic_string from C# into this method. Here's the code
fragment:

Ini ini = new Ini(); // the C++ class library object
ini.Read(basic_string needed as argument); // Here's where I need the
basic_string.

I tried using string from C# to no avail, the compiler just wants a
basic_string. When I try to instantiate a basic_string such as;
std.basic_string<char> str (cstr1, 5);
the compiler barks at me on <char>
"Invalid expression term "char" "

Any one out there know how to do this??

Scott

Nov 16 '05 #1
1 2003

"ScottyO" <of*****@nswccd.navy.mil> wrote in message
news:u%****************@TK2MSFTNGP09.phx.gbl...
I have some legacy C++ code that was re-written as a managed class. I
made
a C++ class library with it and I want to use it in my C# program.


I assume you converted your C++ classes to __gc classes and build a managed
library, please correct me if I'm wrong.
Anyway, you can't use the stl lib in C# this is ONLY possible in C++ and
MC++.
So you need to rewrite your Read method, so it takes a System::String as
argument, the Read method can convert this String to a std string when
needed.
Willy.
Nov 16 '05 #2

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

Similar topics

7
by: ma740988 | last post by:
The string object value_f doesn't produce the right output. At issue, - I suspect - is the conversion from string to int with istringstream. An alternate approach? Thanks in advance #include...
2
by: Gianni Mariani | last post by:
I'm getting "multiply defined" errors on STL symbols. Isn't this a linker error ? By definition, doesn't the compiler/linker need to guarentee the "one definition rule". Linking... ...
1
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error:...
2
by: john | last post by:
In a query I have this expression: Expr1: "ZH"+Str() It should give me ZH1234 but it adds a space between the 2 parts so I get ZH 1234. What can I do to prevent this? Thanks, john
10
by: lovecreatesbea... | last post by:
Is it correct and safe to compare a string object with "", a pair of quotation marks quoted empty string?If the string object: s = ""; does s contain a single '\'? Is it better to use...
8
by: John Nagle | last post by:
The Python documentation for "str" says "str() : Return a string containing a nicely printable representation of an object." However, there's no mention of the fact that "str" of a Unicode...
1
by: bcwhite | last post by:
I'm writing a program and want to create a class that is derived from the "str" base type. When I do so, however, I have problems with the __init__ method. When I run the code below, it will call...
13
by: arnuld | last post by:
/* C++ Primer 4/e * section 3.2 - String Standard Library * exercise 3.10 * STATEMENT * write a programme to strip the punctation from the string. */ #include <iostream> #include...
3
by: Ge Chunyuan | last post by:
hi Group: Once use ActivePython latest version for Python 2.5.1. I happened to find function "str" is not callable, but it is available for Python 2.5. Can anybody give some comments about it?...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.