<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          libpropertiesC++的Properties讀寫(xiě)庫(kù)

          聯(lián)合創(chuàng)作 · 2023-09-28 21:09

          libproperties 提供一個(gè)簡(jiǎn)單易用的C++類(lèi)Properties用以讀寫(xiě)基于xml格式的配置文件, 從而實(shí)現(xiàn)類(lèi)似java中Properties類(lèi)的作用。兩者生成的xml文件可以互通。Xml時(shí)代據(jù)說(shuō)已經(jīng)到來(lái)了,現(xiàn)在的程序流行使用xml配置文件。如果你使用過(guò)java中的Properties類(lèi),你會(huì)發(fā)現(xiàn)它的方便。很多時(shí)候我們并不 需要多么龐大的類(lèi)庫(kù),我們僅僅需要從xml文件中提取“key-value”形式 的配置參數(shù)或?qū)⑵鋵?xiě)入。我們需要易于使用的盡可能小的類(lèi)庫(kù)。

          示例代碼:

          Properties p;
          p.setProperty("sid","harite");
          p.setProperty("port","1521");
          p.setProperty("userpassword","12y3_aer65");
          p.setProperty("host","127.0.0.1");
          p.setProperty("username","system");
          p.storeToXML("connectsetting.xml");
          p.clear();

          if(!p.loadFromXML("connectsetting.xml"))
          {
                  cout << "falue" << endl;
          }
          else
          {
                  for(Properties::const_iterator it = p.begin()
                          ; it!=p.end() ;
                          ++it)
                  {
                          cout << (*it).first << "-->" << (*it).second
                          << endl;
                  }
                  cout << "use getProperty" << endl;
                  cout << p.getProperty("sid", "") << endl;
                  cout << p.getProperty("username", "") << endl;
                  cout << p.getProperty("port", "") << endl;
                  cout << p.getProperty("notexist", "defaultvalue")
                       << endl;
                  p.clear();
          }

          瀏覽 22
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  大鸡吧一区 | 三级做爱视频 | 国产一级无码Av片在线观看 | 无码1234 | 淫秽视频在线观看 |