[futurebasic] Re: [FB] FBtoC: CFStringInitInlineBuffer

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2009 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Sat, 31 Oct 2009 18:11:19 +1300
Waverly wrote:

> Is there a way to use CFStringInitInlineBuffer from CFString.h ?
> It is actually a macro that I would like to use.  Is this possible?

#if ndef _DEFINEDINCARBON
begin record CFStringInlineBuffer
dim opaque.152 // cheap hack
end record
#endif

toolbox CFStringInitInlineBuffer( CFStringRef str,  
CFStringInlineBuffer *buf, CFRange range )
toolbox fn CFStringGetCharacterFromInlineBuffer( CFStringInlineBuffer  
*buf, CFIndex idx ) = UniChar



// demo
dim as CFIndex              length, j
dim as CFStringInlineBuffer myBuf
dim as CFStringRef          str
dim as UniChar              ch

str = @"Hello"
length = fn CFStringGetLength( str )
CFStringInitInlineBuffer( str, @myBuf, fn CFRangeMake( 0, length ) )
for j = 0 to length - 1
ch = fn CFStringGetCharacterFromInlineBuffer( @myBuf, j )
// do something with ch
next


Robert P.