0

We have experimented GNSDK api with "C" code and "Console Application", it's OK, now, we are experimenting GNSDK wrappers with "C++" code and Qt 5.1, we are stopped by this simple line :

gracenote::GnString s_MyString = "another string";

How to make this line correct ?

Roger Rowland
  • 25,885
  • 11
  • 72
  • 113
Decfi
  • 3
  • 2
  • Please define "we are stopped"... – Leeor Dec 11 '13 at 12:27
  • After initialize gracenote::gnsdk ok, we have generate a windows file containing a string generated by a previous RegisterUser. Now we have reloaded this file (with Qt5.1 QFile::read) and we are trying to convert "QString from QT" to a gracenote::GnString. Here our application crashs without message !!! gracenote::GnString skeyuser = (gracenote::GnString)0; // ok // Below fatal instruction skeyuser = (gracenote::GnString) buf.data(); // CRASH !!! – Decfi Dec 11 '13 at 15:10
  • Please don't add "SOLVED" to the title - if you have an answer, accept it, or if you've solved it yourself and the answer may be useful to others, answer it yourself, then accept it. [See here](http://meta.stackexchange.com/a/116105/218740) for a relevant discussion. – Roger Rowland Dec 12 '13 at 09:16

1 Answers1

0

The GnString from GNSDK is only used for managed strings coming out of the SDK. There are only a few instances where it is used, returning serialized GnUser data being one. All other strings to and from GNSDK are 'C' strings (direct string pointers). GNSDK types these as gnsdk_cstr_t.

For passing the serialized string into RegisterUser just give it the 'C' string (but ensure it is UTF8 encoded).

From QString, you should be able to do this:

gnsdk_cstr_t serializedUser = text.toUtf8().constData();

You can pass this serializedUser into RegisterUser.

In short, you should not have to create GnString for use in your app. It's only there for certain output values from GNSDK.

PQuinn
  • 992
  • 6
  • 11