Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STL basic_string

Status
Not open for further replies.

MarkRuse

Programmer
Aug 11, 1999
29
0
0
GB
Hi,

I need to populate a basic_string with keys supplied by a calling program. I put all these strings into a vector, then sort it. This has been working fine, and we are happy with performance. The problem has now arisen where the keys may sometimes have binary data within them. Will this affect the basic_string ? We have tried the code before with char *, and performance degrades significantly. Can anyone help ?
 
try an array of [tt]unsigned char[/tt] instead - this should be better.
tellis.gif

[sup]programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.[/sup]​
 
Hi,

We tried this approach but suffered from performance issues.
Do you have any other ideas ?

Mark
 
>> Will this affect the basic_string ?

it will effect the outcome if the binary data contains embeded null bytes. the basic_string instance in that case will only copy the data upto the first null byte.

>> We have tried the code before with char *, and
>> performance degrades significantly.

could u elaborate? this is confusing since basic_string is actually a collection of char or, code using char*. -There are only 10 types of people in the world, those who understand binary and those who don't-

-pete
 
Hi Pete,

We have now solved this problem, the problem is that when you put data into a basic_string, the data can be truncated if there is a null in the binary part of the string. By assigning the binary stream to the string, it appears to not work (in the watch windows, the string seems truncated), but if you examine it via the memory address, it is fine.

Thanks for your help with this


Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top