|
|
|
date: Thu, 26 Jan 2006 19:00:51 -0800,
group: microsoft.public.platformsdk.com_ole
back
Re: Passing Strings Around is BSTR still in fashion?
Hi Scott,
> What is the current best way to pass around a string?
> I'm picking up COM and working from Essential COM, but it is quite
> dated
> and obliviously Microsoft Java isn't a platform to be concerned with
> about compatibility? Is there a updated chart about IDL Types and
> various support for current languages floating around?
It depends.
BSTR is the only string type supported for automation clients (i.e. VBScript,
JScript and to some extent VB), and it's definitely the type with best cross-language
mapping.
If you only have C++ clients, you might as well go with straight OLE strings,
i.e. wide-char C strings.
I haven't done any measurements, but the BSTR is length-prefixed, so for
huge strings, it may be faster to get the length from a BSTR than from a
C-style NUL-suffixed string, where the entire string has to be traversed
to find the length.
Also, I know the BSTR allocator (SysAllocString and friends) has some heavy-duty
caching in place, so it may be more efficient than CoTaskMemAlloc. Again,
I haven't tried to measure this.
--
Best Regards,
Kim Grsman
date: Sat, 28 Jan 2006 10:08:35 +0000 (UTC)
author: Kim Gräsman
Re: Passing Strings Around is BSTR still in fashion?
Kim Grsman wrote:
> Hi Scott,
>
>> What is the current best way to pass around a string?
>> I'm picking up COM and working from Essential COM, but it is quite
>> dated
>> and obliviously Microsoft Java isn't a platform to be concerned with
>> about compatibility? Is there a updated chart about IDL Types and
>> various support for current languages floating around?
>
> It depends.
>
> BSTR is the only string type supported for automation clients (i.e.
> VBScript, JScript and to some extent VB), and it's definitely the type
> with best cross-language mapping.
> If you only have C++ clients, you might as well go with straight OLE
> strings, i.e. wide-char C strings.
>
> I haven't done any measurements, but the BSTR is length-prefixed, so for
> huge strings, it may be faster to get the length from a BSTR than from a
> C-style NUL-suffixed string, where the entire string has to be traversed
> to find the length.
>
> Also, I know the BSTR allocator (SysAllocString and friends) has some
> heavy-duty caching in place, so it may be more efficient than
> CoTaskMemAlloc. Again, I haven't tried to measure this.
>
> --
> Best Regards,
> Kim Grsman
>
>
Thanks, one of the goals is provide access to the library from as many
languages as possible.
-Scott Markwell
date: Tue, 31 Jan 2006 13:04:31 -0800
author: Scott Markwell scott.markwell[a|t]gmail.com
|
|