Connecting Tech Pros Worldwide Forums | Help | Site Map

Noob question about parsing a BSTR

joseph_mueller@yahoo.com
Guest
 
Posts: n/a
#1: May 11 '06
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?


Victor Bazarov
Guest
 
Posts: n/a
#2: May 11 '06

re: Noob question about parsing a BSTR


joseph_mueller@yahoo.com wrote:[color=blue]
> I have a BSTR[/color]

What's a "BSTR"?
[color=blue]
> 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?[/color]

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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


mlimber
Guest
 
Posts: n/a
#3: May 11 '06

re: Noob question about parsing a BSTR


joseph_mueller@yahoo.com wrote:[color=blue]
> 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?[/color]

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-lit...t.html#faq-5.9

Cheers! --M

Phlip
Guest
 
Posts: n/a
#4: May 11 '06

re: Noob question about parsing a BSTR


joseph_mueller@yahoo.com wrote:
[color=blue]
> 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?[/color]

<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...

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
Marcus Kwok
Guest
 
Posts: n/a
#5: May 11 '06

re: Noob question about parsing a BSTR


joseph_mueller@yahoo.com wrote:[color=blue]
> 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?[/color]

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).

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Closed Thread