<?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[Programm zur Log Auswertung]]></title><description><![CDATA[<p>Hallo liebe Community,</p>
<p>ich bin gerade dabei eine Programm zu schreiben, welches das Log eines Games ausliest.<br />
Leider habe ich bis jetzt nur wenig c++ Erfahrung und hoffe ihr könnt mir ein wenig weiter helfen.</p>
<p>Zunächst mal die Text Datei, welche eingelesen und später bewertet werden soll.</p>
<blockquote>
<p>21:39:51.992|Respektlos|Tobiasvon|Salvation|1295|H|<br />
21:39:51.992|Respektlos|Schlitzohr|Salvation|725|H|<br />
21:39:52.271|Respektlos|Tribunus|Rejuvenate|760|H|<br />
21:39:53.007|Tobia|Eleraana|Salvation|725|H|<br />
21:39:53.007|Tobi|Racta|Salvation|1283|H|<br />
21:39:53.007|Tobi|Sephone|Salvation|1283|H|<br />
21:39:53.007|Respektlos|Respektlos|Salvation|783|H|<br />
21:39:53.008|Respektlos|Tribunus|Salvation|1258|H|<br />
21:39:53.008|Tobi|Tobiasvon|Salvation|747|H|<br />
21:39:53.008|Tobi|Schlitzohr|Salvation|725|H|<br />
21:39:54.074|Respektlos|Racta|Salvation|1283|H|<br />
21:39:54.074|Respektlos|Eleraana|Salvation|725|H|<br />
21:39:54.074|Respektlos|Sephone|Salvation|740|H|<br />
21:39:54.075|Respektlos|Respektlos|Salvation|1357|H|<br />
21:39:54.075|Respektlos|Tribunus|Salvation|725|H|<br />
21:39:54.075|Respektlos|Tobi|Salvation|747|H|<br />
21:39:54.075|Respektlos|Schlitzohr|Salvation|725|H|<br />
21:39:54.305|Respektlos|Respektlos|ExitCombat||EC|</p>
</blockquote>
<p>Das sind zunächst einmal nur dummi Werte. Die Text Datei hat allerdings immer die selbe Strucktur, sprich in ersten Teil befindet sich die Zeit, anschließend ein Spielername, danach wieder ein Spielername ect.</p>
<p>Bis jetzt habe ich die Textdatei einlesen können und den String in verschiedene Daten wandeln.<br />
Jedoch finde ich meine Lösung alles andere als elegant und ich habe Probleme die Daten weiter zu verarbeiten.<br />
Im folgenden Schritt müsste ich für sämtliche Spieler die in &quot;name1&quot; stehen nun alle Werte der Variable &quot;wert&quot; addieren.<br />
Damit komme ich leider nicht weiter.<br />
Ein anderes Problem ist die Zeit, die ich auch noch nicht vernünftig einlesen kann.</p>
<p>Hier mal mein Programm soweit</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;iostream&quot;
#include &quot;string&quot;
#include &quot;fstream&quot;
#include &quot;cstring&quot;
#include &quot;sstream&quot;
#include &quot;time.h&quot;

using namespace std;

int main(void)
{	
string puffer1;
string einezeile[200];
string newlog;
//char a1[100];
int i=1,j =1;

	ifstream log(&quot;C:\\Users\\Philipp\\Desktop\\out.txt&quot;);

	if( log.is_open() != true){ cerr &lt;&lt; &quot;cannot open data&quot;
	&lt;&lt; endl;
	return 1 ;
	}

	while(getline(log,puffer1,'|')) 
	{
einezeile[i]=puffer1;

i++;
j++;
	} 

	double x;
	char name1[20];
	char name2[20];
	char skillname[20];
	int wert;
	int k=0,l=0,ö=0;
	char dpsorheal[4];
	const char *charpointer1;
	const char *charpointer2;
	const char *charpointer3;
	const char *charpointer4;
	stringstream strs1;
	stringstream strs2;
	bool spielervorhanden;
	//char *pointer1
	for(l=0;l&lt;11;l++)
	{

	///////////////////////////////////////////
	x=atof(einezeile[1+k].c_str());

	///////////////////////////////////////////
	charpointer1=einezeile[2+k].c_str();
	strcpy(name1,charpointer1);

	///////////////////////////////////////////
	charpointer2=einezeile[3+k].c_str();
	strcpy(name2,charpointer2);

         //////////////////////////////////////////	
	charpointer3 =einezeile[4+k].c_str();
	strcpy(skillname,charpointer3);

	//////////////////////////////////////////
	wert =atoi(einezeile[5+k].c_str());

	///////////////////////////////////////////
	charpointer4 = einezeile[6+k].c_str();
	strcpy(dpsorheal,charpointer4);

	k=k+6;

cout &lt;&lt;x&lt;&lt;' '&lt;&lt; name1&lt;&lt;' ' &lt;&lt;name2 &lt;&lt;' '&lt;&lt; skillname&lt;&lt;' '&lt;&lt;wert&lt;&lt;' '&lt;&lt;dpsorheal &lt;&lt;  endl;
	}

}
</code></pre>
<p>Um eure Hilfe wäre ich sehr Dankbar,<br />
vielleicht könnt ihr mir ja auch eine elegantere Möglichkeit aufzeigen, die mir Hilft das Programm zu erstellen.</p>
<p>Vielen Dank im voraus<br />
Grüße Phil</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/319282/programm-zur-log-auswertung</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Jul 2026 10:10:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/319282.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 13 Aug 2013 06:26:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Programm zur Log Auswertung on Tue, 13 Aug 2013 06:26:48 GMT]]></title><description><![CDATA[<p>Hallo liebe Community,</p>
<p>ich bin gerade dabei eine Programm zu schreiben, welches das Log eines Games ausliest.<br />
Leider habe ich bis jetzt nur wenig c++ Erfahrung und hoffe ihr könnt mir ein wenig weiter helfen.</p>
<p>Zunächst mal die Text Datei, welche eingelesen und später bewertet werden soll.</p>
<blockquote>
<p>21:39:51.992|Respektlos|Tobiasvon|Salvation|1295|H|<br />
21:39:51.992|Respektlos|Schlitzohr|Salvation|725|H|<br />
21:39:52.271|Respektlos|Tribunus|Rejuvenate|760|H|<br />
21:39:53.007|Tobia|Eleraana|Salvation|725|H|<br />
21:39:53.007|Tobi|Racta|Salvation|1283|H|<br />
21:39:53.007|Tobi|Sephone|Salvation|1283|H|<br />
21:39:53.007|Respektlos|Respektlos|Salvation|783|H|<br />
21:39:53.008|Respektlos|Tribunus|Salvation|1258|H|<br />
21:39:53.008|Tobi|Tobiasvon|Salvation|747|H|<br />
21:39:53.008|Tobi|Schlitzohr|Salvation|725|H|<br />
21:39:54.074|Respektlos|Racta|Salvation|1283|H|<br />
21:39:54.074|Respektlos|Eleraana|Salvation|725|H|<br />
21:39:54.074|Respektlos|Sephone|Salvation|740|H|<br />
21:39:54.075|Respektlos|Respektlos|Salvation|1357|H|<br />
21:39:54.075|Respektlos|Tribunus|Salvation|725|H|<br />
21:39:54.075|Respektlos|Tobi|Salvation|747|H|<br />
21:39:54.075|Respektlos|Schlitzohr|Salvation|725|H|<br />
21:39:54.305|Respektlos|Respektlos|ExitCombat||EC|</p>
</blockquote>
<p>Das sind zunächst einmal nur dummi Werte. Die Text Datei hat allerdings immer die selbe Strucktur, sprich in ersten Teil befindet sich die Zeit, anschließend ein Spielername, danach wieder ein Spielername ect.</p>
<p>Bis jetzt habe ich die Textdatei einlesen können und den String in verschiedene Daten wandeln.<br />
Jedoch finde ich meine Lösung alles andere als elegant und ich habe Probleme die Daten weiter zu verarbeiten.<br />
Im folgenden Schritt müsste ich für sämtliche Spieler die in &quot;name1&quot; stehen nun alle Werte der Variable &quot;wert&quot; addieren.<br />
Damit komme ich leider nicht weiter.<br />
Ein anderes Problem ist die Zeit, die ich auch noch nicht vernünftig einlesen kann.</p>
<p>Hier mal mein Programm soweit</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;iostream&quot;
#include &quot;string&quot;
#include &quot;fstream&quot;
#include &quot;cstring&quot;
#include &quot;sstream&quot;
#include &quot;time.h&quot;

using namespace std;

int main(void)
{	
string puffer1;
string einezeile[200];
string newlog;
//char a1[100];
int i=1,j =1;

	ifstream log(&quot;C:\\Users\\Philipp\\Desktop\\out.txt&quot;);

	if( log.is_open() != true){ cerr &lt;&lt; &quot;cannot open data&quot;
	&lt;&lt; endl;
	return 1 ;
	}

	while(getline(log,puffer1,'|')) 
	{
einezeile[i]=puffer1;

i++;
j++;
	} 

	double x;
	char name1[20];
	char name2[20];
	char skillname[20];
	int wert;
	int k=0,l=0,ö=0;
	char dpsorheal[4];
	const char *charpointer1;
	const char *charpointer2;
	const char *charpointer3;
	const char *charpointer4;
	stringstream strs1;
	stringstream strs2;
	bool spielervorhanden;
	//char *pointer1
	for(l=0;l&lt;11;l++)
	{

	///////////////////////////////////////////
	x=atof(einezeile[1+k].c_str());

	///////////////////////////////////////////
	charpointer1=einezeile[2+k].c_str();
	strcpy(name1,charpointer1);

	///////////////////////////////////////////
	charpointer2=einezeile[3+k].c_str();
	strcpy(name2,charpointer2);

         //////////////////////////////////////////	
	charpointer3 =einezeile[4+k].c_str();
	strcpy(skillname,charpointer3);

	//////////////////////////////////////////
	wert =atoi(einezeile[5+k].c_str());

	///////////////////////////////////////////
	charpointer4 = einezeile[6+k].c_str();
	strcpy(dpsorheal,charpointer4);

	k=k+6;

cout &lt;&lt;x&lt;&lt;' '&lt;&lt; name1&lt;&lt;' ' &lt;&lt;name2 &lt;&lt;' '&lt;&lt; skillname&lt;&lt;' '&lt;&lt;wert&lt;&lt;' '&lt;&lt;dpsorheal &lt;&lt;  endl;
	}

}
</code></pre>
<p>Um eure Hilfe wäre ich sehr Dankbar,<br />
vielleicht könnt ihr mir ja auch eine elegantere Möglichkeit aufzeigen, die mir Hilft das Programm zu erstellen.</p>
<p>Vielen Dank im voraus<br />
Grüße Phil</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2345416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2345416</guid><dc:creator><![CDATA[Phill4563]]></dc:creator><pubDate>Tue, 13 Aug 2013 06:26:48 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Tue, 13 Aug 2013 08:11:38 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>was soll der ganze C-Kram hier?</p>
<p>Du verwendest doch schon std::string und std::getline, diese kannst du gleich für's Einlesen der einzelnen Werte nutzen:</p>
<pre><code class="language-cpp">string date_time, name1, name2, skillname;
int value;
string dummy, dpsorheal;

while(getline(log, date_time, '|'))
{
  getline(log, name1, '|');
  getline(log, name2, '|');
  getline(log, skillname, '|');
  log &gt;&gt; value;
  getline(log, dummy, '|');
  getline(log, dpsorheal, '|');
}
</code></pre>
<p>Um die Werte (je Name) zu speichern, bietet sich eine std::map&lt;std::string, int&gt; an:</p>
<pre><code class="language-cpp">std::map&lt;std::string, int&gt; name_value_map;

// in obiger Schleife (nach dem Einlesen des Wertes)
name_value_map[name1] += value;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2345453</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2345453</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Tue, 13 Aug 2013 08:11:38 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Tue, 13 Aug 2013 13:13:36 GMT]]></title><description><![CDATA[<p>Hallo,<br />
viele Dank für die schnelle Antwort, ich bin noch ein wenig am probieren.<br />
Dabei bin ich auf diesen beitrag gestoßen, der mein problem eigentlich ganz gut beschreibt.<br />
<a href="http://www.c-plusplus.net/forum/310076-full" rel="nofollow">http://www.c-plusplus.net/forum/310076-full</a></p>
<p>Leider konnte ich den Code noch nicht so umbasteln damit er bei mir funktioniert.<br />
Ich habe versucht einen iterator einzufügen, das hat leider nur bedingt funktioniert, hier nochmal der code.<br />
So bekomme ich nur 2 Zeilen ausgegeben. Wenn ich die Zeile</p>
<pre><code>// m.insert((name1, value));
</code></pre>
<p>verwende bekomme ich eine fehlermeldung</p>
<pre><code>// Parser.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
//

#include &quot;stdafx.h&quot;
#include &quot;iostream&quot;
#include &quot;string&quot;
#include &quot;fstream&quot;
#include &quot;cstring&quot;
#include &quot;sstream&quot;
#include &quot;time.h&quot;
#include &quot;map&quot;

using namespace std;

 map&lt;string, int&gt; m;
 map&lt;string, int&gt;::iterator iter; 

int main(void)
{    

string puffer1;
string einezeile[1000];
string newlog;
//int stringcounter[200];
//char a1[100];
int i=1,j=1, ö=1;

    ifstream log(&quot;C:\\Users\\Philipp\\Desktop\\out.txt&quot;);

    if( log.is_open() != true){ cerr &lt;&lt; &quot;cannot open data&quot;
    &lt;&lt; endl;
    return 1 ;
    }

string date_time, name1, name2, skillname;
int value;
string dummy, dpsorheal;

while(getline(log, date_time, '|'))
{
  getline(log, name1, '|');
  getline(log, name2, '|');
  getline(log, skillname, '|');
  log &gt;&gt; value;
  getline(log, dummy, '|');
  getline(log, dpsorheal, '|');

  // m.insert((name1, value));
     m[name1]+=value;

}
log.close();
for(iter=m.begin(); iter!=m.end(); iter++)
{
cout &lt;&lt; iter-&gt;first &lt;&lt; iter-&gt;second &lt;&lt; endl;
}
}
</code></pre>
<p>grüße phil</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2345508</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2345508</guid><dc:creator><![CDATA[Phill4563]]></dc:creator><pubDate>Tue, 13 Aug 2013 13:13:36 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Tue, 13 Aug 2013 17:16:13 GMT]]></title><description><![CDATA[<p>Hallo Phil,</p>
<p>zunächst einmal solltest Du nur lesen was Du brauchst. Die Zeit brauchst Du nach Deiner Problembeschreibung nicht; aber</p>
<p>Phill4563 schrieb:</p>
<blockquote>
<p>Ein anderes Problem ist die Zeit, die ich auch noch nicht vernünftig einlesen kann.</p>
</blockquote>
<p>.. wenn Du die Zeit doch benötigst, so mache Dir eine kleine Struktur - wie genau das geht? frag' nochmal nach.<br />
Ansonsten würde ich Dir empfehlen, einfach alles zu ignorieren, was Du nicht benötigst. Das geht u.a. mit <a href="http://www.cplusplus.com/reference/istream/istream/ignore/" rel="nofollow">ignore</a>. Verpackt in ein Helferlein <code>skip&lt;&gt;</code> (s.u.) wird es dann übersichtlich in der Handhabung.</p>
<p>Außerdem kannst Du alle Lese-Befehle hintereinander schreiben und (wichtig!) nach dem letzten Lesen prüfen, ob der Stream nicht in den Fehlerzustand gegangen ist. Alles zusammen:</p>
<pre><code>#include &quot;iostream&quot;
#include &quot;string&quot;
#include &quot;fstream&quot;
#include &quot;cstring&quot;
// #include &quot;sstream&quot; // wird hier nicht benötigt
#include &quot;ctime&quot; // ctime ist C++-Standard
#include &quot;map&quot;
#include &quot;limits&quot; // numeric_limits

using namespace std;

template&lt; char C &gt;
std::istream&amp; skip( std::istream&amp; in )
{
    return in.ignore( std::numeric_limits&lt; std::streamsize &gt;::max(), C );
}

int main()
{    
    map&lt;string, int&gt; m; // Variablen so lokal wie möglich anlegen

    // ifstream log(&quot;C:\\Users\\Philipp\\Desktop\\out.txt&quot;);
    ifstream log(&quot;input.txt&quot;);
    if( log.is_open() != true)
    { 
        cerr &lt;&lt; &quot;cannot open data&quot; &lt;&lt; endl;
        return 1 ;
    }
    string name1;
    int value;
    while( getline( log &gt;&gt; skip&lt;'|'&gt;, name1, '|' ) &gt;&gt; skip&lt;'|'&gt; &gt;&gt; skip&lt;'|'&gt; &gt;&gt; value &gt;&gt; skip&lt;'\n'&gt; )
        m[name1]+=value;
    // log.close(); // unnötig, das erledigt der Destruktor von ifstream
    for(map&lt;string, int&gt;::iterator iter=m.begin(); iter!=m.end(); ++iter)
    {
        cout &lt;&lt; iter-&gt;first &lt;&lt; iter-&gt;second &lt;&lt; endl;
    }
}
</code></pre>
<p>macht das gleiche, was schon Dein Programm tut, ist nur kürzer und übersichtlicher.</p>
<p>Phill4563 schrieb:</p>
<blockquote>
<p>Wenn ich die Zeile</p>
<pre><code>// m.insert((name1, value));
</code></pre>
<p>verwende bekomme ich eine fehlermeldung</p>
</blockquote>
<p>Korrekt müsste es heißen</p>
<pre><code>m.insert(make_pair(name1, value));
</code></pre>
<p>, aber das willst Du gar nicht, denn sobald ein Element mit dem Key &quot;Respektlos&quot; eigefügt hast, kannst Du keinen zweiten mit dem gleichem Key einfügen.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2345575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2345575</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Tue, 13 Aug 2013 17:16:13 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Wed, 14 Aug 2013 08:56:47 GMT]]></title><description><![CDATA[<p>Hallo Werner,<br />
vielen Dank für deine Hilfe.<br />
Die Skip fkt. ist echt super <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Das mit dem Zeit Struckt schau ich mir selbst nochmal an und würde mich nochmal melden</p>
<p>Einzig die Zeile</p>
<pre><code>while( getline( log &gt;&gt; skip&lt;'|'&gt;, name1, '|' ) &gt;&gt; skip&lt;'|'&gt; &gt;&gt; skip&lt;'|'&gt; &gt;&gt; value &gt;&gt; skip&lt;'\n'&gt; )
</code></pre>
<p>verstehe ich nohc nicht so ganz, vielleicht koenntest du mir nochmal kurz erläutern was hier passiert</p>
<p>Zusätzlich sollten die Werte für &quot;value&quot; nur dann addiert werden wenn sich in der letzten Spalte ein 'H' befindet.</p>
<p>Grüße Philipp</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2345666</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2345666</guid><dc:creator><![CDATA[Phill4563]]></dc:creator><pubDate>Wed, 14 Aug 2013 08:56:47 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Wed, 14 Aug 2013 10:20:03 GMT]]></title><description><![CDATA[<p>Phill4563 schrieb:</p>
<blockquote>
<p>Einzig die Zeile</p>
<pre><code>while( getline( log &gt;&gt; skip&lt;'|'&gt;, name1, '|' ) &gt;&gt; skip&lt;'|'&gt; &gt;&gt; skip&lt;'|'&gt; &gt;&gt; value &gt;&gt; skip&lt;'\n'&gt; )
</code></pre>
<p>verstehe ich nohc nicht so ganz, vielleicht koenntest du mir nochmal kurz erläutern was hier passiert</p>
</blockquote>
<p>Hallo Philipp</p>
<p>genau wie dieser Code</p>
<pre><code>int a = 14;
    int b = 78;
    cout &lt;&lt; &quot;Die Summe von &quot; &lt;&lt; a &lt;&lt; &quot; und &quot; &lt;&lt; b &lt;&lt; &quot; ist &quot; &lt;&lt; (a+b) &lt;&lt; endl;
</code></pre>
<p>das gleiche macht wie</p>
<pre><code>int a = 14;
    int b = 78;
    cout &lt;&lt; &quot;Die Summe von &quot;;
    cout &lt;&lt; a;
    cout &lt;&lt; &quot; und &quot;;
    cout &lt;&lt; b;
    cout &lt;&lt; &quot; ist &quot;;
    cout &lt;&lt; (a+b);
    cout &lt;&lt; endl;
</code></pre>
<p>macht dieser Code:</p>
<pre><code>string name1;
    int value;
    // Format:       &quot; &lt;Zeit&gt;    |   &lt;name1&gt;  |   &lt;name2&gt;   |&lt;skillname&gt; |     &lt;value&gt; ..Rest..EOL&quot;
    while( getline( log &gt;&gt; skip&lt;'|'&gt;, name1, '|' ) &gt;&gt; skip&lt;'|'&gt; &gt;&gt; skip&lt;'|'&gt; &gt;&gt; value &gt;&gt; skip&lt;'\n'&gt; )
    {
        cout &lt;&lt; name1 &lt;&lt; &quot; -&gt; &quot; &lt;&lt; value &lt;&lt; endl;
    }
</code></pre>
<p>das selbe wie:</p>
<pre><code>string name1;
    int value;
    for(;;) // Beenden der Schleife s.u.
    {
        log &gt;&gt; skip&lt;'|'&gt;;           // skip &lt;Zeit&gt;
        getline( log, name1, '|' ); // read &lt;name1&gt;
        log &gt;&gt; skip&lt;'|'&gt;;           // skip &lt;name1&gt;
        log &gt;&gt; skip&lt;'|'&gt;;           // skip &lt;skillname&gt;
        log &gt;&gt; value;               // read &lt;value&gt;
        log &gt;&gt; skip&lt;'\n'&gt;;          // skip all until EOL (End Of Line)
        if( log.fail() )
            break;  // &lt;== hier wird die Schleife ggf. beendet

        cout &lt;&lt; name1 &lt;&lt; &quot; -&gt; &quot; &lt;&lt; value &lt;&lt; endl;
    }
</code></pre>
<p>.. das alles einen Ausdruck zu schreiben, sieht vielleicht erst mal kryptisch aus, aber das ist reine Gewöhnung.</p>
<p>Phill4563 schrieb:</p>
<blockquote>
<p>Zusätzlich sollten die Werte für &quot;value&quot; nur dann addiert werden wenn sich in der letzten Spalte ein 'H' befindet.</p>
</blockquote>
<p>kein Problem, lies es einfach mit ein:</p>
<pre><code>string name1;
    int value;
    string dpsorheal; // was ist das? WoW?
    // Format:                &quot; &lt;Zeit&gt;    |   &lt;name1&gt;  |   &lt;name2&gt;   |&lt;skillname&gt; |     &lt;value&gt;         |   &lt;dpsorheal&gt;  | ..Rest..EOL&quot;
    while( getline( getline( log &gt;&gt; skip&lt;'|'&gt;, name1, '|' ) &gt;&gt; skip&lt;'|'&gt; &gt;&gt; skip&lt;'|'&gt; &gt;&gt; value &gt;&gt; skip&lt;'|'&gt;, dpsorheal, '|' ) &gt;&gt; skip&lt;'\n'&gt; )
    {
        if( dpsorheal == &quot;H&quot; )
            m[name1]+=value;
    }
</code></pre>
<p>Bem.: das letzte <code>skip&lt;'\n'&gt;</code> wäre hier nicht mehr notwendig, da kein '|' hinter dem zuletzt gelesenen '|' steht.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2345707</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2345707</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Wed, 14 Aug 2013 10:20:03 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Wed, 14 Aug 2013 10:54:54 GMT]]></title><description><![CDATA[<p>Danke für deine Antwort<br />
ne ist für swtor, nicht für wow <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>danke nochmals</p>
<p>Grüße Phill</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2345718</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2345718</guid><dc:creator><![CDATA[Phill4563]]></dc:creator><pubDate>Wed, 14 Aug 2013 10:54:54 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Wed, 14 Aug 2013 10:55:04 GMT]]></title><description><![CDATA[<p>PS.: Hups - ich habe gerade gesehen, dass die Spalte 'value' nicht immer einen Zahlenwert enthält, dann bricht das Lesen natürlich mit Fehler ab ... melde mich später dazu noch mal.</p>
<p>Phill4563 schrieb:</p>
<blockquote>
<blockquote>
<p>21:39:54.305|Respektlos|Respektlos|ExitCombat||EC|</p>
</blockquote>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2345719</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2345719</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Wed, 14 Aug 2013 10:55:04 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Thu, 15 Aug 2013 20:14:19 GMT]]></title><description><![CDATA[<p>Werner Salomon schrieb:</p>
<blockquote>
<p>ich habe gerade gesehen, dass die Spalte 'value' nicht immer einen Zahlenwert enthält, ...</p>
</blockquote>
<p>Hallo Philipp,</p>
<p>so ein Problem löst man z.B. dadurch, dass man nicht direkt eine Zahl (hier ein int) einliest, sondern ein Objekt einer selbst geschriebenen Klasse, welches erst mal prüft, ob das was da kommt eine Zahl sein könnte oder eben nicht. Ich nenne den Typ eines solchen Objekts mal ' <code>opt</code> ' für 'optional' und dann sähe das so aus:</p>
<pre><code>struct opt // opt für optional; liest ein int, wenn eine Zahl kommt, sonst wird der Wert =0 gesetzt
{
    explicit opt( int&amp; value )
        : value_( value )
    {}
    friend std::istream&amp; operator&gt;&gt;( std::istream&amp; in, opt o ) // Lesefunktion für den Wrapper 'opt'
    {
        char c;
        if( in &gt;&gt; c &amp;&amp; in.putback( c ) ) // lese das nächste Zeichen 'c' und stelle es auch gleich zurück!
        {
            if( ('0' &lt;= c &amp;&amp; c &lt;= '9') || c == '-' || c == '+' ) // könnte eine Zahl sein
                in &gt;&gt; o.value_; // dann lese die Zahl
            else
                o.value_ = 0; // sonst definiert auf 0 setzen
        }
        return in;
    }
private:
    int&amp; value_;
};
</code></pre>
<p>anschließend muss man die Einlesesequenz nur um das ' <code>opt</code> ' erweitern - ergo:</p>
<pre><code>string name1;
    int value;
    string dpsorheal;                                                            //&lt;-- hier optional lesen --&gt;
    // Format:                &quot; &lt;Zeit&gt;    |   &lt;name1&gt;  |   &lt;name2&gt;   |&lt;skillname&gt; |       [&lt;value&gt;]          |   &lt;dpsorheal&gt;  | ..Rest..EOL&quot;
    while( getline( getline( log &gt;&gt; skip&lt;'|'&gt;, name1, '|' ) &gt;&gt; skip&lt;'|'&gt; &gt;&gt; skip&lt;'|'&gt; &gt;&gt; opt(value) &gt;&gt; skip&lt;'|'&gt;, dpsorheal, '|' ) &gt;&gt; skip&lt;'\n'&gt; )
    { // usw.
</code></pre>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346194</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Thu, 15 Aug 2013 20:14:19 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Thu, 15 Aug 2013 20:54:38 GMT]]></title><description><![CDATA[<p>das opt Objekt der Einlesefunktion müsste doch eien Referenz sein, oder irre ich mich da Werner?</p>
<pre><code>friend std::istream&amp; operator&gt;&gt;( std::istream&amp; in, opt &amp; /*&lt;-- Referenz*/ o )
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2346208</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346208</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Thu, 15 Aug 2013 20:54:38 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Thu, 15 Aug 2013 21:07:23 GMT]]></title><description><![CDATA[<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>das opt Objekt der Einlesefunktion müsste doch eien Referenz sein, oder irre ich mich da Werner?</p>
<pre><code>friend std::istream&amp; operator&gt;&gt;( std::istream&amp; in, opt &amp; /*&lt;-- Referenz*/ o )
</code></pre>
</blockquote>
<p>.. probier's mal aus! wenn Du nicht gerade einen MSVC6-Compiler verwendest, sollte der Code dann gar nicht übersetzt werden. Der Ausdruck 'opt(value)' in dem while-Statemant erzeugt ein temporäres Objekt!<br />
wenn Referenz, dann</p>
<pre><code>friend std::istream&amp; operator&gt;&gt;( std::istream&amp; in, const opt&amp; /*&lt;-- const Referenz*/ o )
</code></pre>
<p>Das opt-Objekt selbst wird ja gar nicht verändert!</p>
<p>.. hätte ich vielleicht gleich dazu schreiben sollen, weil diese Nachfrage kommt fast immer.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346211</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346211</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Thu, 15 Aug 2013 21:07:23 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Fri, 16 Aug 2013 07:42:36 GMT]]></title><description><![CDATA[<p>Das nicht, aber wird es nicht kopiert? Das ist ja nur ein Call-By-Value. Und Strukturen, die eine Referenz als Member halten sind doch nicht kopierbarbar.</p>
<p>Wieso geht das dann?<br />
Oder anders gefragt, warum ergibt das keinen Fehler, kompiliert aber mit Referenz nicht?</p>
<p><a href="http://ideone.com/axsFrh" rel="nofollow">mit Referenz</a><br />
<a href="http://ideone.com/7cF6PZ" rel="nofollow">Ohne Referenz</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346252</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346252</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 16 Aug 2013 07:42:36 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Mon, 19 Aug 2013 05:50:45 GMT]]></title><description><![CDATA[<p>Vielen Dank für die Hilfe Werner.</p>
<p>Grüße<br />
Phill</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2346962</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2346962</guid><dc:creator><![CDATA[Phill4563]]></dc:creator><pubDate>Mon, 19 Aug 2013 05:50:45 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Mon, 19 Aug 2013 20:13:56 GMT]]></title><description><![CDATA[<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>Das nicht, aber wird es nicht kopiert? Das ist ja nur ein Call-By-Value. Und Strukturen, die eine Referenz als Member halten sind doch nicht kopierbarbar.</p>
</blockquote>
<p>doch kopierbar sind sie; nur nicht zuweisbar. Zumindest nicht ohne dass man einen eigenen Zuweisungsoperator schreibt.</p>
<p>Skym0sh0 schrieb:</p>
<blockquote>
<p>.. kompiliert aber mit Referenz nicht?</p>
</blockquote>
<p>weil der Standard es schlicht nicht zulässt. Ich finde die Stelle, wo das steht, eben nicht wieder. Aber eine non-const reference auf ein temporäres Objekt ist nicht zulässig. Und deshalb compiliert es mit Referenz nicht - so der Compiler die Regel beherzigt.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2347101</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2347101</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Mon, 19 Aug 2013 20:13:56 GMT</pubDate></item><item><title><![CDATA[Reply to Programm zur Log Auswertung on Tue, 20 Aug 2013 05:56:55 GMT]]></title><description><![CDATA[<blockquote>
<p>Ich finde die Stelle, wo das steht, eben nicht wieder.</p>
</blockquote>
<p>§8.5.3 schrieb:</p>
<blockquote>
<p><strong>4.</strong><br />
Given types “cv1 T1” and “cv2 T2,” “cv1 T1” is reference-related to “cv2 T2” if T1 is the same type as T2, or T1 is a base class of T2. “cv1 T1” is reference-compatible with “cv2 T2” if T1 is reference-related to T2 and cv1 is the same cv-qualification as, or greater cv-qualification than, cv2.</p>
<p><strong>5.</strong><br />
A reference to type “cv1 T1” is initialized by an expression of type “cv2 T2” as follows:<br />
If the reference is an lvalue reference and the initializer expression</p>
<ul>
<li>is an lvalue (but is not a bit-field), and “cv1 T1” is reference-compatible with “cv2 T2,” or</li>
<li>has a class type (i.e., T2 is a class type), where T1 is not reference-related to T2, and can be implicitly converted to an lvalue of type “cv3 T3,” where “cv1 T1” is reference-compatible with “cv3 T3”106 (this conversion is selected by enumerating the applicable conversion functions (13.3.1.6) and choosing the best one through overload resolution (13.3)),</li>
</ul>
<p>then the reference is bound to the initializer expression lvalue in the first case and to the lvalue result of the conversion in the second case (or, in either case, to the appropriate base class subobject of the object).</p>
</blockquote>
<p>Eine non-const lvalue-Referenz muss also immer zu einem non-const lvalue gebunden werden.<br />
Das waren die gewöhnlichen Semantiken für lvalue-Referenzen.</p>
<p>Erst im nächsten Abschnitt wird dann für <code>const-lvalue</code> -Referenzen erklärt..</p>
<blockquote>
<p>Otherwise, the reference shall be an lvalue reference to a non-volatile const type (i.e., cv1 shall be const), or the reference shall be an rvalue reference.<br />
If the initializer expression</p>
<ul>
<li>is an xvalue, class prvalue, array prvalue or function lvalue and “cv1 T1” is reference compatible with “cv2 T2”, or</li>
<li>has a class type (i.e., T2 is a class type), where T1 is not reference-related to T2, and can be implicitly converted to an xvalue, class prvalue, or function lvalue of type “cv3 T3”, where “cv1 T1” is reference-compatible with “cv3 T3”</li>
</ul>
<p><strong>then the reference is bound to the value of the initializer expression</strong> in the first case and to the result of the conversion in the second case (or, in either case, to an appropriate base class subobject). [...]</p>
<p><strong>Otherwise, a temporary of type “cv1 T1” is created and initialized from the initializer expression using the rules for a non-reference copy-initialization (8.5). The reference is then bound to the temporary.</strong></p>
</blockquote>
<p>Achtung: Die letzten beiden Sätze treffen nicht immer zu.<br />
schreibt, dann trifft das auf die obige Erklärung zu;</p>
<pre><code>std::string const&amp; = std::string{};
</code></pre>
<p>Wenn man jedoch</p>
<pre><code>std::string const&amp; = &quot;ABC&quot;;
</code></pre>
<p>Dann trifft es auf die letzte Erklärung zu.</p>
<blockquote>
<p>Zumindest nicht ohne dass man einen eigenen Zuweisungsoperator schreibt.</p>
</blockquote>
<p>Wie sollen sie dann zuweisbar sein? Es ist klar festgelegt, dass eine Referenz ihren Referenten nicht ändern kann:</p>
<blockquote>
<p>A reference cannot be changed to refer to another object after initialization. Note that initialization of a reference is treated very differently from assignment to it.</p>
</blockquote>
<p>Daher ist in Klassen immer ein Zeiger besser aufgehoben. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2347135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2347135</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Tue, 20 Aug 2013 05:56:55 GMT</pubDate></item></channel></rss>