<?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: The ModulData datastore type in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224664#M2749</link>
    <description>That's up to you - ModulData simply stores the requested number of bytes of data. What you put there is up to you. We serialise objects as XML for storage.</description>
    <pubDate>Wed, 04 Mar 2020 13:16:55 GMT</pubDate>
    <dc:creator>Ralph Wessel</dc:creator>
    <dc:date>2020-03-04T13:16:55Z</dc:date>
    <item>
      <title>The ModulData datastore type</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224663#M2748</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;How does ModulData store complex structures or classes&lt;BR /&gt;Hope someone can reply, thank you&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Sep 2021 10:38:35 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224663#M2748</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-15T10:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: The ModulData datastore type</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224664#M2749</link>
      <description>That's up to you - ModulData simply stores the requested number of bytes of data. What you put there is up to you. We serialise objects as XML for storage.</description>
      <pubDate>Wed, 04 Mar 2020 13:16:55 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224664#M2749</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-03-04T13:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: The ModulData datastore type</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224665#M2750</link>
      <description>Is&lt;B&gt; MemoryOChannel&lt;/B&gt; the only way to apply for storage space？&lt;BR /&gt;
I observed some code in the &lt;B&gt;ModulData_Manager&lt;/B&gt; case in the API.
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;class CustomerData {
public:
	GS::Guid			guid;
	GS::UniString		name;
	GS::UniString		city;
	GS::UniString		country;
	double				aa;
	int					ii;
	bool				modified;
	bool				markedAsDeleted;

	CustomerData () : modified (false), markedAsDeleted (false) { }

	CustomerData (const API_ModulData&amp;amp; modulData, const GS::UniString&amp;amp; modulName) : modified (false), markedAsDeleted (false)
	{
		guid.ConvertFromString (modulName);
		if (modulData.dataHdl != nullptr &amp;amp;&amp;amp; modulData.dataVersion == 1) {
			IO::MemoryIChannel memChannel (*modulData.dataHdl, BMGetHandleSize (modulData.dataHdl));
			if (modulData.platformSign != GS::Act_Platform_Sign) {
				GS::PlatformSign ps = (modulData.platformSign == GS::Win_Platform_Sign) ? GS::Win_Platform_Sign :
									  ((modulData.platformSign == GS::Mac_Platform_Sign) ? GS::Mac_Platform_Sign : GS::Mactel_Platform_Sign);
				IO::SetPlatformIProtocol (memChannel, ps);
			}
			Read (memChannel);
		}
	}

	GSErrCode	Read (GS::IChannel&amp;amp; ic)
	{
		name.Read (ic);
		city.Read (ic);
		country.Read (ic);
		
		return ic.GetInputStatus ();
	}

	GSErrCode	Write (GS::OChannel&amp;amp; oc) const
	{
		name.Write (oc);
		city.Write (oc);
		country.Write (oc);
		return oc.GetOutputStatus ();
	}

	void	GenerateRandomContent (void)
	{
		static const char firstNames[10][32] = { "Albert", "Alex", "Alfred", "Amy", "Andrew", "Angelina", "Anne", "Anthony", "Arnold", "Arthur" };
		static const char familyNames[10][32] = { "Smith", "Johnson", "Williams", "Brown", "Jones", "Miller", "Davis", "Garcia", "Rodriguez", "Wilson" };
		static const char cities[10][32] = { "San Francisco", "Budapest", "Amsterdam", "Venezia", "Helsinki", "Limassol", "Tokyo", "Barcelona", "Abuja", "Auckland" };
		static const char countries[10][32] = { "United States", "Hungary", "Netherlands", "Italy", "Finland", "Cyprus", "Japan", "Spain", "Nigeria", "New Zeeland" };

		Int32 firstNameIndex = rand () % 10;
		Int32 familyNameIndex = rand () % 10;
		Int32 locationIndex = rand () % 10;
		name = GS::UniString (firstNames[firstNameIndex]) + " " + GS::UniString (familyNames[familyNameIndex]);
		city = GS::UniString (cities[locationIndex]);
		country = GS::UniString (countries[locationIndex]);
	}
};
&lt;/PRE&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;static void ConvertModulesFromOldFormat (void)
{
	GS::Array&amp;lt;GS::UniString&amp;gt; modulNameList;
	ACAPI_ModulData_GetList (&amp;amp;modulNameList);

	for (GS::Array&amp;lt;GS::UniString&amp;gt;::ConstIterator it = modulNameList.Enumerate (); it != nullptr; ++it) {
		const GS::UniString&amp;amp; oldModulName = *it;
		API_ModulData oldModulData;
		BNZeroMemory (&amp;amp;oldModulData, sizeof (API_ModulData));
		if (ACAPI_ModulData_GetInfo (&amp;amp;oldModulData, oldModulName) == NoError) {
			if (oldModulData.dataVersion &amp;lt; 1) {						// old version (all customers stored in the same moduldata)
				if (ACAPI_ModulData_Get (&amp;amp;oldModulData, oldModulName) == NoError) {
					IO::MemoryIChannel oldModulMemChannel (*oldModulData.dataHdl, BMGetHandleSize (oldModulData.dataHdl));
					if (oldModulData.platformSign != GS::Act_Platform_Sign) {
						GS::PlatformSign ps = (oldModulData.platformSign == GS::Win_Platform_Sign) ? GS::Win_Platform_Sign :
											  ((oldModulData.platformSign == GS::Mac_Platform_Sign) ? GS::Mac_Platform_Sign : GS::Mactel_Platform_Sign);
						IO::SetPlatformIProtocol (oldModulMemChannel, ps);
					}
					USize nObjects = 0;
					oldModulMemChannel.Read (nObjects);
					for (USize i = 0; i &amp;lt; nObjects; i++) {
						CustomerData customerData;
						customerData.guid.Generate ();
						customerData.Read (oldModulMemChannel);

						API_ModulData modulData;
						BNZeroMemory (&amp;amp;modulData, sizeof (API_ModulData));
						modulData.dataVersion = 1;
						modulData.platformSign = GS::Act_Platform_Sign;
						IO::MemoryOChannel memChannel;
						if (customerData.Write (memChannel) == NoError) {
							BMPtrToHandle (memChannel.GetDestination (), &amp;amp;modulData.dataHdl, memChannel.GetDataSize ());
							ACAPI_ModulData_Store (&amp;amp;modulData, customerData.guid.ToUniString ());	// store converted
							BMKillHandle (&amp;amp;modulData.dataHdl);
						}
					}
				}
				BMKillHandle (&amp;amp;oldModulData.dataHdl);
				ACAPI_ModulData_Delete (oldModulName);												// delete old format
			}
		}
	}
}		// ConvertModulesFromOldFormat
&lt;/PRE&gt;
This code uses the classes IChannel and OChannel to read and write to the class data.&lt;BR /&gt;
If you want to store your data, whether you need to follow case way to deal with.&lt;BR /&gt;
I don't quite understand this place, Please give me a hand, thank you very much.</description>
      <pubDate>Thu, 05 Mar 2020 05:03:35 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224665#M2750</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-05T05:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: The ModulData datastore type</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224666#M2751</link>
      <description>Sorry, I can't tell you much about the API functionality for serialisation or buffering. We wrote classes for that long before it existed in the API and the documentation for this part of the API is thin.&lt;BR /&gt;
&lt;BR /&gt;
At a basic level, take a look at the structure of &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;API_ModulData&lt;E&gt;&lt;/E&gt;. Your data is stored in &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;API_ModulData .dataHdl&lt;E&gt;&lt;/E&gt;, which is of type &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;GSHandle&lt;E&gt;&lt;/E&gt;. You can allocate the space for a handle using &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;BMAllocateHandle&lt;E&gt;&lt;/E&gt;. Once space is allocated, you can copy data into it.&lt;BR /&gt;
&lt;BR /&gt;
Using memory buffer and serialisation classes takes a lot of the pain out of this process by providing a 'black box' that simply reads and writes objects while concealing the low-level data management.</description>
      <pubDate>Thu, 05 Mar 2020 10:49:39 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224666#M2751</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2020-03-05T10:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: The ModulData datastore type</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224667#M2752</link>
      <description>Thank you very much. It helped me a lot. Thank you &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;</description>
      <pubDate>Mon, 09 Mar 2020 02:26:20 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/The-ModulData-datastore-type/m-p/224667#M2752</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-09T02:26:20Z</dc:date>
    </item>
  </channel>
</rss>

