Noob question about parsing a BSTR

J

joseph_mueller

I have a BSTR something like this

firstHalf.secondHalf

I want to parse this string using the "." as the delimeter, so I will
end up with two different BSTRs, one for the stuff before the "." and
one for the stuff after it. How can I do this?
 
V

Victor Bazarov

I have a BSTR

What's a "BSTR"?
something like this

firstHalf.secondHalf

I want to parse this string using the "." as the delimeter, so I will
end up with two different BSTRs, one for the stuff before the "." and
one for the stuff after it. How can I do this?

Since "BSTR" is not defined in C++, you might want to specify first
what "BSTR" is. If it's some kind of string, then you should be using
string manipulation functions to (a) search the string for '.' and (b)
extract a substring from the beginning of it to the '.' position (not
including the '.') or to the end if '.' is not found, and if '.' is
found, then also extract a substring from after the '.' to the end.
What functions to use and how to use them depends on what "BSTR" is.

V
 
M

mlimber

I have a BSTR something like this

firstHalf.secondHalf

I want to parse this string using the "." as the delimeter, so I will
end up with two different BSTRs, one for the stuff before the "." and
one for the stuff after it. How can I do this?

BSTRs are part of a non-standard library provided by Microsoft. If you
can rephrase this question in the terms of the standard C++ language
and libraries, we can help you here. If not, you should ask in a
Microsoft newsgroup. For details on what is on-topic here and for a
list of some other groups you could try, see this FAQ:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M
 
P

Phlip

I have a BSTR something like this

firstHalf.secondHalf

I want to parse this string using the "." as the delimeter, so I will
end up with two different BSTRs, one for the stuff before the "." and
one for the stuff after it. How can I do this?

<off-topic>
Put it into a _bstr_t. Then use strdup() to put it into a character string
buffer. Then...
</off-topic>

Use strtok(string, ".").

You will get the best answers about BSTR on a forum that covers COM
programming. This forum is only qualified to answer questions about C++
itself. For example, that forum might be able to hook you up with a Regexp
class that works with BSTRs directly, so you don't need all those
conversions. And use _bstr_t wherever possible...
 
M

Marcus Kwok

I have a BSTR something like this

firstHalf.secondHalf

I want to parse this string using the "." as the delimeter, so I will
end up with two different BSTRs, one for the stuff before the "." and
one for the stuff after it. How can I do this?

I don't know anything of BSTR and I'm pretty sure it's not defined by
the C++ language. If you were using std::strings, you could look into
using string::find_first_of() (or one of its variants).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,362
Latest member
ChandaWagn

Latest Threads

Top