<?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[TMemoryStream zu String [gelöst]]]></title><description><![CDATA[<p>Hallo,</p>
<p>hab hier vermutlich eine absolute Anfängerfrage.... hab schon gesucht und probiert aber komme auf keinen grünen Zweig.</p>
<p>Das Problem:</p>
<p>Ich habe einen TMemoryStream bzw. Daten darin und möchte diese in einen String ablegen. (Der TMemoryStream kommt von einem IdHTTP-&gt;Post und enthält den Rückgabewert des Servers...)</p>
<p>Hoffe mir kann da jemand weiterhelfen - vielen Dank schonmal!</p>
<p>Gruß,<br />
Wolfgang</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/273415/tmemorystream-zu-string-gelöst</link><generator>RSS for Node</generator><lastBuildDate>Fri, 28 Aug 2026 05:13:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/273415.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 06 Sep 2010 19:46:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to TMemoryStream zu String [gelöst] on Tue, 07 Sep 2010 20:43:58 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>hab hier vermutlich eine absolute Anfängerfrage.... hab schon gesucht und probiert aber komme auf keinen grünen Zweig.</p>
<p>Das Problem:</p>
<p>Ich habe einen TMemoryStream bzw. Daten darin und möchte diese in einen String ablegen. (Der TMemoryStream kommt von einem IdHTTP-&gt;Post und enthält den Rückgabewert des Servers...)</p>
<p>Hoffe mir kann da jemand weiterhelfen - vielen Dank schonmal!</p>
<p>Gruß,<br />
Wolfgang</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1948961</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1948961</guid><dc:creator><![CDATA[Babblfish]]></dc:creator><pubDate>Tue, 07 Sep 2010 20:43:58 GMT</pubDate></item><item><title><![CDATA[Reply to TMemoryStream zu String [gelöst] on Mon, 06 Sep 2010 20:00:11 GMT]]></title><description><![CDATA[<p>TMemoryStream scheint wohl so ein Borland-Kram zu sein... da es ein Stream ist, wird es wohl eine Read-Methode geben, mit der du die Daten da rauskriegst. Direkt mit std::string wird das nichts, aber mit einem vector&lt;char&gt; vielleicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1948967</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1948967</guid><dc:creator><![CDATA[Nukularfüsiker]]></dc:creator><pubDate>Mon, 06 Sep 2010 20:00:11 GMT</pubDate></item><item><title><![CDATA[Reply to TMemoryStream zu String [gelöst] on Mon, 06 Sep 2010 20:18:56 GMT]]></title><description><![CDATA[<p>Ja, ist wohl Borland Kram. Ist das RAD Studio...</p>
<p>bin absoluter Anfänger und kann mit vector&lt;char&gt; grad nicht viel anfangen - werd erstmal nachlesen.</p>
<p>Vorher war das Ding halt so gelöst:</p>
<pre><code class="language-cpp">Memo1-&gt;Lines-&gt;LoadFromStream(InStream);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1948986</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1948986</guid><dc:creator><![CDATA[Babblfish]]></dc:creator><pubDate>Mon, 06 Sep 2010 20:18:56 GMT</pubDate></item><item><title><![CDATA[Reply to TMemoryStream zu String [gelöst] on Mon, 06 Sep 2010 20:24:14 GMT]]></title><description><![CDATA[<p>Was kann denn vector&lt;char&gt;, was std::string nicht kann? Ist doch quasi das gleich minus die Stringmanipulationsmethoden.</p>
<p>@Threadersteller: Kann dir leider auch nicht helfen, weil ich ebenfalls nicht weiß, was TMemoryStream genau ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1948990</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1948990</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Mon, 06 Sep 2010 20:24:14 GMT</pubDate></item><item><title><![CDATA[Reply to TMemoryStream zu String [gelöst] on Tue, 07 Sep 2010 00:33:15 GMT]]></title><description><![CDATA[<p>ich kenne IdHTTP zwar nicht, aber ich bin mir sicher, dass man die daten in einem TStream kriegt.</p>
<p>Dan kann man die Sache einfach machen und anstatt TMemoryStream, TStringStream nutzen.<br />
Durch die Funktion ReadString kriegst du dan einen String zurück.</p>
<p>sonst halt über einen Buffer;<br />
zB</p>
<pre><code class="language-cpp">const int Max_Length = 20;
char Buffer[Max_Length];
Stream-&gt;Read(&amp;Buffer,Max_Length);
AnsiString String1 = Buffer;
std::string String2 = Buffer;
</code></pre>
<p>auch hier nachzulesen<br />
<a href="http://docwiki.embarcadero.com/VCL/de/Classes.TStream" rel="nofollow">http://docwiki.embarcadero.com/VCL/de/Classes.TStream</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1949053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1949053</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Tue, 07 Sep 2010 00:33:15 GMT</pubDate></item><item><title><![CDATA[Reply to TMemoryStream zu String [gelöst] on Tue, 07 Sep 2010 13:38:06 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Was kann denn vector&lt;char&gt;, was std::string nicht kann? Ist doch quasi das gleich minus die Stringmanipulationsmethoden.</p>
<p>@Threadersteller: Kann dir leider auch nicht helfen, weil ich ebenfalls nicht weiß, was TMemoryStream genau ist.</p>
</blockquote>
<p>Man kann ihn direkt als Buffer für irgendwelche Read-Operationen benutzen:<br />
<code>KomischerStreamTypOhneIteratoren.read(&amp;vec[0], vec.size()</code> . Mit einem <code>std::string</code> sollte man das nicht machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1949277</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1949277</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Tue, 07 Sep 2010 13:38:06 GMT</pubDate></item><item><title><![CDATA[Reply to TMemoryStream zu String [gelöst] on Tue, 07 Sep 2010 13:39:13 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Was kann denn vector&lt;char&gt;, was std::string nicht kann?</p>
</blockquote>
<p>Einen <code>char*</code> liefern.</p>
<p>Edit: Mensch, Tachyon.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1949278</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1949278</guid><dc:creator><![CDATA[Nukularfüsiker]]></dc:creator><pubDate>Tue, 07 Sep 2010 13:39:13 GMT</pubDate></item><item><title><![CDATA[Reply to TMemoryStream zu String [gelöst] on Tue, 07 Sep 2010 20:41:33 GMT]]></title><description><![CDATA[<p>Danke an alle für die Hilfe - besonders an BigNeal - der Hinweis mit dem Buffer hat geholfen.</p>
<p>IdHTTP-&gt;Post arbeitet offensichtlich _nicht_ mit TStream</p>
<p>Für all diejenigen die es interessiert hier die Funktion in ihrer Gesamtheit:</p>
<pre><code class="language-cpp">String Tsms_sender::CheckCash(String username, String password)
{
  String params = &quot;id=&quot; + username + &quot;&amp;pw=&quot; + password;
  TMemoryStream *InStream=new TMemoryStream();
  TMemoryStream *OutStream=new TMemoryStream();

  OutStream-&gt;Write(UnicodeString(params).c_str(), params.Length());

  IdHTTP1-&gt;Request-&gt;ContentType=&quot;application/x-www-form-urlencoded&quot;;

  try
  {
	IdHTTP1-&gt;Post(&quot;http://me.local/rad/konto.php&quot;, OutStream, InStream);
  }
  catch(...)
  {
	sms_text-&gt;Lines-&gt;Add(&quot;Hinweis: Exception von IdHTTP&quot;);
  }

  InStream-&gt;Position=0;
  const int Max_Length = 20;
  char Buffer[Max_Length];
  InStream-&gt;Read(&amp;Buffer,Max_Length);
  String inas = Buffer;
  delete OutStream;
  delete InStream;
  return inas;
}
</code></pre>
<p>Achja, auch der Link auf embarcadero war super, hier hab ich nämlich das gefunden:<br />
<a href="http://docwiki.embarcadero.com/VCL/de/Classes.TMemoryStream" rel="nofollow">http://docwiki.embarcadero.com/VCL/de/Classes.TMemoryStream</a> - TMemoryStream ist also eine abgeleitete Klasse aus TStream.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1949447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1949447</guid><dc:creator><![CDATA[Babblfish]]></dc:creator><pubDate>Tue, 07 Sep 2010 20:41:33 GMT</pubDate></item><item><title><![CDATA[Reply to TMemoryStream zu String [gelöst] on Tue, 07 Sep 2010 23:44:00 GMT]]></title><description><![CDATA[<p>Babblfish schrieb:</p>
<blockquote>
<p>IdHTTP-&gt;Post arbeitet offensichtlich _nicht_ mit TStream</p>
</blockquote>
<p>versuch einfach mal</p>
<pre><code class="language-cpp">String Tsms_sender::CheckCash(String username, String password)
{
  String params = &quot;id=&quot; + username + &quot;&amp;pw=&quot; + password;
  TStringStream *InStream=new TStringStream();
  TStringStream *OutStream=new TStringStream();

  OutStream-&gt;WriteString(UnicodeString(params));

  IdHTTP1-&gt;Request-&gt;ContentType=&quot;application/x-www-form-urlencoded&quot;;

  try
  {
	IdHTTP1-&gt;Post(&quot;http://me.local/rad/konto.php&quot;, OutStream, InStream);
  }
  catch(...)
  {
	sms_text-&gt;Lines-&gt;Add(&quot;Hinweis: Exception von IdHTTP&quot;);
  }

  InStream-&gt;Position=0;
  const int Max_Length = 20;

  String inas = InStream-&gt;ReadString(Max_Length);

  String inas = Buffer;
  delete OutStream;
  delete InStream;
  return inas;
}
</code></pre>
<p>und Max_Length kann man natürlich auch dynamisch machen, indem man die grösse vom Stream ausliesst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1949502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1949502</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Tue, 07 Sep 2010 23:44:00 GMT</pubDate></item><item><title><![CDATA[Reply to TMemoryStream zu String [gelöst] on Wed, 08 Sep 2010 11:40:23 GMT]]></title><description><![CDATA[<p>Danke für den Hinweis... funktioniert. Hatte es vorher direkt mit TStream versucht - und das ging schief (erzeugte eine Zugriffsverletzung).</p>
<p>Nun sieht es so aus:</p>
<pre><code class="language-cpp">String Tsms_sender::CheckCash(String username, String password)
{
  String params = &quot;id=&quot; + username + &quot;&amp;pw=&quot; + password;
  TStringStream *InStream=new TStringStream();
  TStringStream *OutStream=new TStringStream();
  OutStream-&gt;WriteString(UnicodeString(params));
  IdHTTP1-&gt;Request-&gt;ContentType=&quot;application/x-www-form-urlencoded&quot;;
  try
  {
	IdHTTP1-&gt;Post(&quot;http://me.local/rad/konto.php&quot;, OutStream, InStream);
  }
  catch(...)
  {
    sms_text-&gt;Lines-&gt;Add(&quot;Hinweis: Exception von IdHTTP&quot;);
  }
  InStream-&gt;Position=0;
  String inas = InStream-&gt;ReadString(InStream-&gt;Size);
  delete OutStream;
  delete InStream;
  return inas;
}
</code></pre>
<p>Hatte auch schon vorher versucht mit InStream-&gt;Size zu arbeiten aber leider funktionierte das nicht da er für char Buffer einen konstanten Ausdruck erwartete (hat sich ja jetzt durch den Verzicht auf Buffer erledigt!)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1949640</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1949640</guid><dc:creator><![CDATA[Babblfish]]></dc:creator><pubDate>Wed, 08 Sep 2010 11:40:23 GMT</pubDate></item></channel></rss>