<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Serialization]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich muss serializierten String in eine MySQL Datenbank speichern. Bin nun am überlegen, wie ich das realisieren kann und ob das im C++ (gcc linux) überhaupt so möglich ist wie im PHP. Ich hoffe mir kann da jemand weiterhelfen.</p>
<p>PHP:<br />
-------</p>
<p>$a = array(</p>
<p>'KUNDEN' =&gt; array(<br />
'0' =&gt; array(<br />
'WERT1' =&gt; 'Franz',<br />
'WERT2' =&gt; 'Mustermann'<br />
),<br />
'1' =&gt; array(<br />
'WERT1' =&gt; 'Susann',<br />
'WERT2' =&gt; 'Musterfrau'<br />
)<br />
),</p>
<p>'TIERE' =&gt; array(<br />
'0' =&gt; array(<br />
'WERT1' =&gt; 'Hund',<br />
'WERT2' =&gt; 'Blacky'<br />
),<br />
'1' =&gt; array(<br />
'WERT1' =&gt; 'Katze',<br />
'WERT2' =&gt; 'Domina'<br />
)<br />
)</p>
<p>);<br />
echo serialize($a);</p>
<p>Serialize - welcher in die DB geschreiben werden muss:<br />
a:2:{s:6:&quot;KUNDEN&quot;;a:2:{i:0;a:2:{s:5:&quot;WERT1&quot;;s:5:&quot;Franz&quot;;s:5:&quot;WERT2&quot;;s:10:&quot;Mustermann&quot;;}i:1;a:2:{s:5:&quot;WERT1&quot;;s:6:&quot;Susann&quot;;s:5:&quot;WERT2&quot;;s:10:&quot;Musterfrau&quot;;}}s:5:&quot;TIERE&quot;;a:2:{i:0;a:2:{s:5:&quot;WERT1&quot;;s:4:&quot;Hund&quot;;s:5:&quot;WERT2&quot;;s:6:&quot;Blacky&quot;;}i:1;a:2:{s:5:&quot;WERT1&quot;;s:5:&quot;Katze&quot;;s:5:&quot;WERT2&quot;;s:6:&quot;Domina&quot;;}}}</p>
<p>----------------------------------------------------------------------------</p>
<p>Doch wie kann ich unter C++ ein Array serializieren (serialization von Boost??), wobei es ja auch unter c++ keine assoziierte arrays gibt. Irgendwie befürchte ich, das könnte ein größeres Problem werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196984/serialization</link><generator>RSS for Node</generator><lastBuildDate>Wed, 30 Sep 2026 18:59:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196984.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Nov 2007 12:28:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Serialization on Mon, 05 Nov 2007 12:28:01 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich muss serializierten String in eine MySQL Datenbank speichern. Bin nun am überlegen, wie ich das realisieren kann und ob das im C++ (gcc linux) überhaupt so möglich ist wie im PHP. Ich hoffe mir kann da jemand weiterhelfen.</p>
<p>PHP:<br />
-------</p>
<p>$a = array(</p>
<p>'KUNDEN' =&gt; array(<br />
'0' =&gt; array(<br />
'WERT1' =&gt; 'Franz',<br />
'WERT2' =&gt; 'Mustermann'<br />
),<br />
'1' =&gt; array(<br />
'WERT1' =&gt; 'Susann',<br />
'WERT2' =&gt; 'Musterfrau'<br />
)<br />
),</p>
<p>'TIERE' =&gt; array(<br />
'0' =&gt; array(<br />
'WERT1' =&gt; 'Hund',<br />
'WERT2' =&gt; 'Blacky'<br />
),<br />
'1' =&gt; array(<br />
'WERT1' =&gt; 'Katze',<br />
'WERT2' =&gt; 'Domina'<br />
)<br />
)</p>
<p>);<br />
echo serialize($a);</p>
<p>Serialize - welcher in die DB geschreiben werden muss:<br />
a:2:{s:6:&quot;KUNDEN&quot;;a:2:{i:0;a:2:{s:5:&quot;WERT1&quot;;s:5:&quot;Franz&quot;;s:5:&quot;WERT2&quot;;s:10:&quot;Mustermann&quot;;}i:1;a:2:{s:5:&quot;WERT1&quot;;s:6:&quot;Susann&quot;;s:5:&quot;WERT2&quot;;s:10:&quot;Musterfrau&quot;;}}s:5:&quot;TIERE&quot;;a:2:{i:0;a:2:{s:5:&quot;WERT1&quot;;s:4:&quot;Hund&quot;;s:5:&quot;WERT2&quot;;s:6:&quot;Blacky&quot;;}i:1;a:2:{s:5:&quot;WERT1&quot;;s:5:&quot;Katze&quot;;s:5:&quot;WERT2&quot;;s:6:&quot;Domina&quot;;}}}</p>
<p>----------------------------------------------------------------------------</p>
<p>Doch wie kann ich unter C++ ein Array serializieren (serialization von Boost??), wobei es ja auch unter c++ keine assoziierte arrays gibt. Irgendwie befürchte ich, das könnte ein größeres Problem werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397978</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397978</guid><dc:creator><![CDATA[fettyteddy2]]></dc:creator><pubDate>Mon, 05 Nov 2007 12:28:01 GMT</pubDate></item><item><title><![CDATA[Reply to Serialization on Mon, 05 Nov 2007 12:37:46 GMT]]></title><description><![CDATA[<p>Klar gibt es unter C++ assoziative Arrays - die nennen sich &quot;map&lt;&gt;&quot;. Und zur Serialisierung mußt du nur Schlüssel und Wert aller Elemente so unterbringen, daß du sie später wieder auslesen kannst - dabei kannst du dich durchaus an dem PHP-Ansatz orientieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397987</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 05 Nov 2007 12:37:46 GMT</pubDate></item><item><title><![CDATA[Reply to Serialization on Mon, 05 Nov 2007 12:58:22 GMT]]></title><description><![CDATA[<p>okay map&lt;&gt; kann ich verwenden stimmt. Das Problem besteht allerdings darin, dass der gespeicherte serialisierte String auch von PHP wieder ausgelesen werden muss. Also das Format des Strings gleich dem von PHP sein muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1398001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1398001</guid><dc:creator><![CDATA[fettyteddy2]]></dc:creator><pubDate>Mon, 05 Nov 2007 12:58:22 GMT</pubDate></item><item><title><![CDATA[Reply to Serialization on Mon, 05 Nov 2007 13:03:00 GMT]]></title><description><![CDATA[<p>Das lässt sich einrichten - du mußt nur das PHP-Format nachbilden. Die Größe einer map&lt;&gt; bekommst du über size(), die einzelnen Elemente über Iteratoren (Schlüssel und Wert sind zu einem pair&lt;&gt; zusammengefasst). Der Rest ist halt eine Frage des Formats.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1398006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1398006</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 05 Nov 2007 13:03:00 GMT</pubDate></item></channel></rss>