Xojo Conferences
XDCMay2019MiamiUSA

get Cstring (Real Studio Plugins Mailinglist archive)

Back to the thread list
Previous thread: REALproperty
Next thread: SharedProperty


macosx and unix paths   -   GOLD
  get Cstring   -   Bob Delaney
   Re: get Cstring   -   Alfred Van Hoek
   Re: get Cstring   -   Joe Ranieri
   Re: get Cstring   -   Bob Delaney
   Re: get Cstring   -   Alfred Van Hoek
    Re: get Cstring   -   Bob Delaney

get Cstring
Date: 03.05.13 02:30 (Thu, 2 May 2013 20:30:29 -0500)
From: Bob Delaney
How does one get a Cstring from a REALstringData object?

Bob

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: get Cstring
Date: 03.05.13 05:57 (Thu, 02 May 2013 22:57:54 -0600)
From: Alfred Van Hoek

On May 2, 2013, at 10:39 PM, Bob Delaney wrote:

> In my plugin I have for inputString as a REALstring:
>
> REALstringData *rsData;
>
> REALGetStringData(inputString, REALGetStringEncoding(inputString), rsData);
>
> For that last statement I get the warning: 'rsData' is used uninitialized in this function
>
> How do I initialize 'rsData'?

I would suggest to declare

REALstring rsData;

and then call REALGetStringData using the ampersand:

REALGetStringData(inputString, REALGetStringEncoding(inputString), &rsData);

>
> And I would appreciate it if someone would give me a good reference on these matters.

sticking to your issue: I would recommend to declare a struct as a variable, not a pointer to a struct. Uninitialized means that you don't provide allocated memory. Your way requires to malloc the pointer and later you need to dispose of this pointer.


- Alfred Van Hoek
<email address removed>
http://vanhoekplugins.com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: get Cstring
Date: 03.05.13 05:55 (Fri, 3 May 2013 00:55:52 -0400)
From: Joe Ranieri
On Fri, May 3, 2013 at 12:39 AM, Bob Delaney <<email address removed>> wrote:
> In my plugin I have for inputString as a REALstring:
>
> REALstringData *rsData;
>
> REALGetStringData(inputString, REALGetStringEncoding(inputString), rsData);
>
> For that last statement I get the warning: 'rsData' is used uninitialized in this function
>
> How do I initialize 'rsData'?
>
> And I would appreciate it if someone would give me a good reference on these matters.
>
> Bob

The idea behind REALGetStringData is that you want to get the string's
contents in an encoding that your code understands.

To give a real world example: we have a plugin internally that needs
to draw a string given to us by the user. Previously we would have had
to do an explicit encoding conversion, gotten the string's contents,
and then gone on with the work we actually cared about. The 'modern'
approach looks like this:
REALstringData title;
if (REALGetStringData( data->title, kTextEncodingUTF16LE, &title )) {
::DrawTextW( dc, (LPCWSTR)title.data, ... );
REALDisposeStringData( &title );
}

The sample projects that ship with the SDK may not have been updated,
so file a Feedback case if you see places where it needs changing.

Re: get Cstring
Date: 03.05.13 05:39 (Thu, 2 May 2013 23:39:30 -0500)
From: Bob Delaney
In my plugin I have for inputString as a REALstring:

REALstringData *rsData;

REALGetStringData(inputString, REALGetStringEncoding(inputString), rsData);

For that last statement I get the warning: 'rsData' is used uninitialized in this function

How do I initialize 'rsData'?

And I would appreciate it if someone would give me a good reference on these matters.

Bob

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: get Cstring
Date: 03.05.13 03:11 (Thu, 02 May 2013 20:11:47 -0600)
From: Alfred Van Hoek

On May 2, 2013, at 7:30 PM, Bob Delaney wrote:

> How does one get a Cstring from a REALstringData object?

Not sure what you would mean, given the REALstringData structs tells you so:

REALstringData* data;

const char* myCString = (const char*)data->data;

not sure if data->data is null terminated, but data->data represents the CString.

- Alfred Van Hoek
<email address removed>
http://vanhoekplugins.com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: get Cstring
Date: 03.05.13 04:47 (Thu, 2 May 2013 22:47:00 -0500)
From: Bob Delaney

On May 2, 2013, at 9:11 PM, Alfred Van Hoek <<email address removed>> wrote:

> const char* myCString = (const char*)data->data;

Thanks!

Bob

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>