<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic std::string -&amp;gt; GS::uchar_t gdl parameter in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/std-string-gt-GS-uchar-t-gdl-parameter/m-p/261208#M3123</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;Hi there!&lt;BR /&gt;&lt;BR /&gt;I think i have a simple problem, but i couldn't get over it by myself....&lt;BR /&gt;&lt;BR /&gt;I have an std::string parameter which is came from a csv file through ifstream::getline. And i have to change a library element string parameter, which is uchar_t *. But i couldn't get it converted...&lt;BR /&gt;&lt;BR /&gt;so here is what i tried:&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;//these are predefined
   std::string line;
   Int32 id;
   char paramname[32];

API_ChangeParamType  chgParam;

BNZeroMemory(&amp;amp;chgParam, sizeof(API_ChangeParamType));

chgParam.index = id;
strcpy(chgParam.name, paramname);
GS::ucscpy(chgParam.uStrValue, GS::UniString(line.c_str()).ToUStr().Get()); //GSReporter crash

&lt;/PRE&gt;
but it is crashing during ucscpy.&lt;BR /&gt;So how should i transfere my string to get it working? I always had issues with string especially unistrings/unichars.&lt;/DIV&gt;</description>
    <pubDate>Thu, 29 Sep 2022 08:10:09 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-09-29T08:10:09Z</dc:date>
    <item>
      <title>std::string -&gt; GS::uchar_t gdl parameter</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/std-string-gt-GS-uchar-t-gdl-parameter/m-p/261208#M3123</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi there!&lt;BR /&gt;&lt;BR /&gt;I think i have a simple problem, but i couldn't get over it by myself....&lt;BR /&gt;&lt;BR /&gt;I have an std::string parameter which is came from a csv file through ifstream::getline. And i have to change a library element string parameter, which is uchar_t *. But i couldn't get it converted...&lt;BR /&gt;&lt;BR /&gt;so here is what i tried:&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;//these are predefined
   std::string line;
   Int32 id;
   char paramname[32];

API_ChangeParamType  chgParam;

BNZeroMemory(&amp;amp;chgParam, sizeof(API_ChangeParamType));

chgParam.index = id;
strcpy(chgParam.name, paramname);
GS::ucscpy(chgParam.uStrValue, GS::UniString(line.c_str()).ToUStr().Get()); //GSReporter crash

&lt;/PRE&gt;
but it is crashing during ucscpy.&lt;BR /&gt;So how should i transfere my string to get it working? I always had issues with string especially unistrings/unichars.&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 Sep 2022 08:10:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/std-string-gt-GS-uchar-t-gdl-parameter/m-p/261208#M3123</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-29T08:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: std::string -&gt; GS::uchar_t gdl parameter</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/std-string-gt-GS-uchar-t-gdl-parameter/m-p/261209#M3124</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
This should work:
&lt;PRE&gt;GS::uchar_t bufferUStr[API_UAddParStrLen];
GS::ucsncpy (bufferUStr, GS::UniString (line.c_str()).ToUStr().Get(), API_UAddParStrLen - 1);
chgParam.uStrValue = bufferUStr;&lt;/PRE&gt;
Just make sure, that bufferUStr will live till you use the chgParam &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_wink.gif" style="display : inline;" /&gt; &lt;BR /&gt;
&lt;BR /&gt;
A little explanation:&lt;BR /&gt;
uStrValue is a simple pointer, it just points to somewhere. That's why you cannot write characters into it and you got crash report immediately. You have to set the pointer to an existing array of characters.</description>
      <pubDate>Tue, 08 Oct 2019 08:33:02 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/std-string-gt-GS-uchar-t-gdl-parameter/m-p/261209#M3124</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2019-10-08T08:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: std::string -&gt; GS::uchar_t gdl parameter</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/std-string-gt-GS-uchar-t-gdl-parameter/m-p/261210#M3125</link>
      <description>Thank you very much this is helped a lot to understand pointers as well because i didn't used a lot c++.</description>
      <pubDate>Tue, 08 Oct 2019 09:01:55 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/std-string-gt-GS-uchar-t-gdl-parameter/m-p/261210#M3125</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-10-08T09:01:55Z</dc:date>
    </item>
  </channel>
</rss>

