<?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[3-dimensionale map]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe in einer Klasse eine Konfiguration als map&lt;string,string&gt; realisiert.<br />
nun versuche ich eine dritte dimension hinzuzufügen (section einer Ini-Datei als int [index in einer 2. map&lt;int,string&gt;])</p>
<p>map selbst versteht scheinbar nur 2 Elemente, wie könnte ich das anders realisieren?</p>
<p>Gruß Frank</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/294774/3-dimensionale-map</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 15:43:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/294774.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 01 Nov 2011 10:24:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 3-dimensionale map on Tue, 01 Nov 2011 10:24:36 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe in einer Klasse eine Konfiguration als map&lt;string,string&gt; realisiert.<br />
nun versuche ich eine dritte dimension hinzuzufügen (section einer Ini-Datei als int [index in einer 2. map&lt;int,string&gt;])</p>
<p>map selbst versteht scheinbar nur 2 Elemente, wie könnte ich das anders realisieren?</p>
<p>Gruß Frank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138628</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138628</guid><dc:creator><![CDATA[_frank_]]></dc:creator><pubDate>Tue, 01 Nov 2011 10:24:36 GMT</pubDate></item><item><title><![CDATA[Reply to 3-dimensionale map on Tue, 01 Nov 2011 10:30:45 GMT]]></title><description><![CDATA[<p>Ich verstehe nicht, was du bzgl map&lt;string,string&gt; mit &quot;eine dritte dimension hinzufügen&quot; meinst.</p>
<p>Ich rate einfach mal:</p>
<p>- map&lt; string, pair&lt;int,string&gt; &gt;<br />
- map&lt; pair&lt;string,int&gt;, string &gt;<br />
- map&lt; string, map&lt;int, string&gt; &gt;<br />
- ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138630</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138630</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Tue, 01 Nov 2011 10:30:45 GMT</pubDate></item><item><title><![CDATA[Reply to 3-dimensionale map on Tue, 01 Nov 2011 10:33:22 GMT]]></title><description><![CDATA[<p>Die straightforward Lösung wäre wohl eine <code>map&lt;string, map&lt;string, string&gt;&gt;</code> .<br />
Ansonsten würde ich mir überlegen, ob du den Sectionname nicht einfach vorne an den Key dranhängen kannst. Außerdem würd ich mir überlegen, ob ich nicht eher eine unordered_map will.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138631</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138631</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Tue, 01 Nov 2011 10:33:22 GMT</pubDate></item><item><title><![CDATA[Reply to 3-dimensionale map on Tue, 01 Nov 2011 10:55:25 GMT]]></title><description><![CDATA[<p>danke für die schnellen Antworten</p>
<p>ich wusste gar nicht, dass sowas geht...</p>
<p>in meinem Fall wäre das dann ja</p>
<p>map&lt; int, map&lt;string, string&gt; &gt;</p>
<p>wobei int der index (bzw. iterator) des sectionnamens in einer 2. map (zuweisung zu einem Sectionnamen)</p>
<p>könnte zwar auch einen vector nehmen, aber dann habe ich probleme mit dem index, wenn ich da werte lösche..ich brauche einen unveränderlichen index.</p>
<p>wenn ich den Sectionnamen bei jedem Item hinterlege (map&lt; string, map&lt;string, string&gt; &gt; ) habe ich einen massiven speicherverbrauch (auch wenn das bei aktuellen Speichergrößen kaum ins Gewicht fallen würde)</p>
<p>was wäre die unordered map?<br />
wie gesagt, ich will in die Struktur eine Ini-datei laden/rekonstruieren</p>
<p>Gruß Frank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138640</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138640</guid><dc:creator><![CDATA[_frank_]]></dc:creator><pubDate>Tue, 01 Nov 2011 10:55:25 GMT</pubDate></item><item><title><![CDATA[Reply to 3-dimensionale map on Tue, 01 Nov 2011 11:30:31 GMT]]></title><description><![CDATA[<p><em>frank</em> schrieb:</p>
<blockquote>
<p>wenn ich den Sectionnamen bei jedem Item hinterlege (map&lt; string, map&lt;string, string&gt; &gt; ) habe ich einen massiven speicherverbrauch (auch wenn das bei aktuellen Speichergrößen kaum ins Gewicht fallen würde)</p>
</blockquote>
<p>Da vertust Du Dich massiv bzgl &quot;massiven Speicherverbrauch&quot;. Der Sectionsname würde in der Datenstruktur nur 1mal pro Sektion gespeichert.</p>
<p>Vor einem Jahr habe ich das auch mal per map&lt;string,map&lt;string,string&gt; &gt; gemacht. Im Nachhinein stellte ich aber fest, dass &quot;Ini&quot; zu wenig hierarchisch ist und ich tiefere Ebenen &quot;frickeln&quot; musste. Hätte ich mal lieber XML verwenden sollen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138672</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138672</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Tue, 01 Nov 2011 11:30:31 GMT</pubDate></item><item><title><![CDATA[Reply to 3-dimensionale map on Tue, 01 Nov 2011 11:32:52 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">typedef std::string Key;
typedef std::string Value;
typedef std::string SectionKey;
typedef std::map&lt;Key, Value&gt; Section;
typedef std::map&lt;SectionKey, Section&gt; IniFile;
</code></pre>
<p>Ich würde aber überlegen das in einer Klasse zu kapseln, um die Zugriffe etwas lesbarer zu machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138673</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Tue, 01 Nov 2011 11:32:52 GMT</pubDate></item><item><title><![CDATA[Reply to 3-dimensionale map on Tue, 01 Nov 2011 17:20:23 GMT]]></title><description><![CDATA[<p>ah, jetzt seh ichs auch, dass der sectionname nur einmal gespeichert wird <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>ich baue dass schon in eine Klasse, alleine schon wegen der parsing-routinen</p>
<p>auf den ersten Blick macht das construct map&lt;string,map&lt;string,string&gt;&gt; das ganze einfacher, besonders, weil ich mir die zuordnung der section zu einer index-variable spare</p>
<p>nur wie muss der äußere interator aussehen?<br />
der innere bleibt ja bei &quot;std::map&lt;std::string, std::string&gt;::iterator value_iter;&quot;...nur der äußere müsste als 2.Element eine map beinhalten.</p>
<p>//edit:</p>
<p>folgendes compiliert ohne Fehler...ist es auch richtig?</p>
<pre><code class="language-cpp">//g++ -Wall inifile.cpp -o inifile

# include &lt;string&gt; //cpp-string

#include &lt;map&gt; //for config

using namespace std;

typedef std::string IniKey;
typedef std::string IniValue;
typedef std::string IniSectionKey;
typedef std::map&lt;IniKey, IniValue&gt; IniSection;
typedef std::map&lt;IniSectionKey, IniSection&gt; IniFile;

int main(int argc, char *argv[])
{
  IniFile ini;
  //std::map&lt;std::string,std::string&gt;
  std::map&lt;std::string, IniSection&gt;::iterator section_iter;
  std::map&lt;std::string, std::string&gt;::iterator value_iter;
  for (section_iter = ini.begin(); section_iter != ini.end(); section_iter++) 
  {
    std::string section_name=section_iter-&gt;first;
    IniSection section=section_iter-&gt;second;
    for (value_iter = section.begin(); value_iter != section.end(); value_iter++) 
    {
      std::string value_name=value_iter-&gt;first;
      std::string value_value=value_iter-&gt;second;
    }
  }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2138712</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138712</guid><dc:creator><![CDATA[_frank_]]></dc:creator><pubDate>Tue, 01 Nov 2011 17:20:23 GMT</pubDate></item><item><title><![CDATA[Reply to 3-dimensionale map on Wed, 02 Nov 2011 16:58:43 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe es mittlerweile soweit, dass das parsing der Datei funktioniert, aber etweder wird nichts hinzugefügt, oder das auslesen ist falsch...</p>
<p>hier mal mein Code:</p>
<pre><code class="language-cpp">typedef std::string tIniKey;
typedef std::string tIniValue;
typedef std::string tIniSectionKey;

typedef std::map&lt;tIniKey, tIniValue&gt; tIniSection;
typedef std::map&lt;tIniSectionKey, tIniSection&gt; tIniFile;

std::map&lt;std::string, tIniSection&gt;::iterator section_iter;
std::map&lt;std::string, std::string&gt;::iterator value_iter;

//private der klasse:
tIniSection fSection;

//zuweisung in methode
fSection=fIniFile[section];
fSection[key]=value;

//auslesen in anderer methode
  for (section_iter = fIniFile.begin(); section_iter != fIniFile.end(); section_iter++)
  {
    fSection=section_iter-&gt;second;
    for (value_iter = fSection.begin(); value_iter != fSection.end(); value_iter++) 
    {
      cout &lt;&lt; &quot;[Section]:&quot; &lt;&lt; section_iter-&gt;first &lt;&lt; &quot;Key:&quot; &lt;&lt; value_iter-&gt;first.c_str() &lt;&lt; &quot;,Value:&quot; &lt;&lt; value_iter-&gt;second.c_str() &lt;&lt; endl;
    }
  }
</code></pre>
<p>sieht jemand den Fehler? für mich scheint alles zu passen</p>
<p>so wie es aussieht, wird die Section erstellt, aber die untermap nicht (oder sie wird irgendwo wieder freigegeben)</p>
<p>ich habe den kompletten code mal hier hochgeladen: <a href="http://nopaste.info/6e393da13f.html" rel="nofollow">http://nopaste.info/6e393da13f.html</a></p>
<p>Gruß Frank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2139418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2139418</guid><dc:creator><![CDATA[_frank_]]></dc:creator><pubDate>Wed, 02 Nov 2011 16:58:43 GMT</pubDate></item><item><title><![CDATA[Reply to 3-dimensionale map on Wed, 02 Nov 2011 18:38:12 GMT]]></title><description><![CDATA[<p>Wir wärs mit boost::multi_index ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2139489</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2139489</guid><dc:creator><![CDATA[nurf]]></dc:creator><pubDate>Wed, 02 Nov 2011 18:38:12 GMT</pubDate></item><item><title><![CDATA[Reply to 3-dimensionale map on Thu, 03 Nov 2011 13:44:55 GMT]]></title><description><![CDATA[<p>möchte ungern fremde libs verwenden, wenn die funktionalität durch die STL verfügbar ist.</p>
<p>wenn ich ein neues Item so anlege, funktioniert es:</p>
<pre><code class="language-cpp">fIniFile[section][key]=value;
</code></pre>
<p>in hinblick auf case-insensitive Zugriffe und Vermeidung von doppelten Sections/Keys, möchte ich aber nach der section suchen, ggf. erstellen und falls sie existiert hat, den key suchen.</p>
<p>das geht als Einzeiler nach der Schreibweise oben nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2139819</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2139819</guid><dc:creator><![CDATA[_frank_]]></dc:creator><pubDate>Thu, 03 Nov 2011 13:44:55 GMT</pubDate></item><item><title><![CDATA[Reply to 3-dimensionale map on Sat, 05 Nov 2011 07:41:40 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe es hinbekommen...ich suche nach der Section/dem Key case-insensitive und nutze den vorhandenen Namen (wenn existiert, sonst den parameter) um den Wert zu setzen.</p>
<pre><code class="language-cpp">void SetValue(string section,string key,string value)

    {

      section=trim(section);

      key=trim(key);

      value=trim(value);

      string existing_section=section_find(section);

      if (existing_section==&quot;&quot;)

      { //section does not exist

        fIniFile[section][key]=value;

      } else

      {

        string existing_key=key_find(section,key);

        if (existing_key == &quot;&quot;)

        { //key does not exist in existing section

          fIniFile[existing_section][key]=value;

        } else

          fIniFile[existing_section][existing_key]=value;

      }

    }
</code></pre>
<p>somit ist meine INI-Klasse soweit komplett. Sie ist mit ca. 300 Zeilen recht klein und funktioniert unter linux und windows...man muss nur die entsprechende fileexists-Funktion aktivieren.</p>
<p>Wer interesse hat...ich habe sie unter <a href="http://www.fw-web.de/download.php?file=cpp/inifile.cpp" rel="nofollow">http://www.fw-web.de/download.php?file=cpp/inifile.cpp</a> hochgeladen</p>
<p>Gruß Frank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2140573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2140573</guid><dc:creator><![CDATA[_frank_]]></dc:creator><pubDate>Sat, 05 Nov 2011 07:41:40 GMT</pubDate></item></channel></rss>