<?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 Re: Saving std::map / std::pair in local user preferences in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/340452#M1488</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, the std::map doesn't know how to serialize itself to a GS::Channel, so you'll have to "teach" it by writing the input/output code yourself. GS::Channel just has support for basic types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also write the number of items to the channel upfront, so you'll know how many items you are dealing with when you read the info back.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, GS::HashTable is equivalent to std::map; is there a good reason why you store a map inside another map?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best, Akos&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jun 2022 11:05:30 GMT</pubDate>
    <dc:creator>Akos Somorjai</dc:creator>
    <dc:date>2022-06-07T11:05:30Z</dc:date>
    <item>
      <title>Saving std::map / std::pair in local user preferences</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/339013#M1485</link>
      <description>&lt;P&gt;Hi. Is there a way to save std::map or std::pair (or any other pairing or nesting datatype) in the local preferences file by an addon?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2022 07:44:39 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/339013#M1485</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2022-05-21T07:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Saving std::map / std::pair in local user preferences</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/339814#M1486</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, it is possible, but you have to write the serialization yourself.&lt;/P&gt;
&lt;P&gt;There is another way, though: use GS containers:&lt;/P&gt;
&lt;P&gt;std::pair → GS::Pair&lt;/P&gt;
&lt;P&gt;std::map → GS::HashTable&lt;/P&gt;
&lt;P&gt;Most GS containers have methods to read from and write to Channels, which can be saved in preferences. Hint: use&amp;nbsp;GS::MemoryOChannel32 and&amp;nbsp;GS::MemoryIChannel32.&lt;/P&gt;
&lt;P&gt;Best, Akos&lt;/P&gt;</description>
      <pubDate>Mon, 30 May 2022 13:46:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/339814#M1486</guid>
      <dc:creator>Akos Somorjai</dc:creator>
      <dc:date>2022-05-30T13:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Saving std::map / std::pair in local user preferences</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/340386#M1487</link>
      <description>&lt;P&gt;&lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/7122"&gt;@Akos Somorjai&lt;/a&gt;, when I tried something like:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;GS&lt;/SPAN&gt;&lt;SPAN&gt;::HashTable&amp;lt;API_ElemTypeID, &lt;/SPAN&gt;&lt;SPAN&gt;std&lt;/SPAN&gt;&lt;SPAN&gt;::map&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;GS&lt;/SPAN&gt;&lt;SPAN&gt;::UniString, int&amp;gt;&amp;gt; myHashTable;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;myHashTable&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Read&lt;/SPAN&gt;&lt;SPAN&gt;(ic);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;I got the error:&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;'GS::Read': none of the 14 overloads could convert all the argument types.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So do we have to manually store each member of GS::HashTable too, by converting it to an acceptable type, like for std::map?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason to store a map directly is that its size (number of members) is dynamic and unknown, so while reading from preferences into an empty map, I don't know how much to iterate..&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 06 Jun 2022 20:23:35 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/340386#M1487</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2022-06-06T20:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Saving std::map / std::pair in local user preferences</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/340452#M1488</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, the std::map doesn't know how to serialize itself to a GS::Channel, so you'll have to "teach" it by writing the input/output code yourself. GS::Channel just has support for basic types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also write the number of items to the channel upfront, so you'll know how many items you are dealing with when you read the info back.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, GS::HashTable is equivalent to std::map; is there a good reason why you store a map inside another map?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best, Akos&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 11:05:30 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/340452#M1488</guid>
      <dc:creator>Akos Somorjai</dc:creator>
      <dc:date>2022-06-07T11:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Saving std::map / std::pair in local user preferences</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/340463#M1489</link>
      <description>&lt;P&gt;Hi Akos,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;You can also write the number of items to the channel upfront, so you'll know how many items you are dealing with when you read the info back.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I was thinking about that, but wanted to check if there was any better way to store a map without breaking it down to so many levels.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason I have a map within a map is because the data set is in the form of entities having pairs. Like: { Slab { {Flooring, Area}, {Ceiling, Area}, {Panel, Number} }, Wall { {Partition, Area}, {Exterior, Volume} } }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I figured a GS::HashTable is like std::map, but since you mentioned it, I just wanted to check if it was accepted as a valid type that could be saved directly.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 12:53:00 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Saving-std-map-std-pair-in-local-user-preferences/m-p/340463#M1489</guid>
      <dc:creator>dushyant</dc:creator>
      <dc:date>2022-06-07T12:53:00Z</dc:date>
    </item>
  </channel>
</rss>

