青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆 - 224  文章 - 41  trackbacks - 0
<2010年3月>
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

享受編程

常用鏈接

留言簿(11)

隨筆分類(159)

隨筆檔案(224)

文章分類(2)

文章檔案(4)

經(jīng)典c++博客

搜索

  •  

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

大師:https://github.com/animetrics/PlistCpp

發(fā)布了多個(gè)平臺(tái),生成和解析plist文件,這里只給出windows平臺(tái)下的應(yīng)用。下載
使用方法如下:

read a plist from disk whose root node is a
dictionary:

map<string, boost::any> dict; 
Plist::readPlist("binaryExample1.plist", dict);
 
 
To write a plist, e.g. dictionary

map<string, boost::any> dict;
populateDictionary(dict);
Plist::writePlistXML("xmlExampleWritten.plist", dict);
 
// PListCpp.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
//

#include 
"stdafx.h"
#include 
"Plist.hpp"
#include 
<iostream>
#include 
<fstream>
#include 
<iterator>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    map
<string, boost::any> dict; 
    Plist::readPlist(
"XMLExample1.plist", dict);

    map
<string,boost::any>::iterator it;
    
for(it=dict.begin();it!=dict.end();++it)
    
{
        cout
<<"key: "<<it->first <<endl;
    }


    
const vector<boost::any>& plistArray = boost::any_cast<const vector<boost::any>& >(dict.find("testArray")->second);
    cout
<<boost::any_cast<const int64_t&>(plistArray[0])<<endl;
    cout
<<boost::any_cast<const string&>(plistArray[1]).c_str()<<endl;

    
//

    
return 0;
}



/*
static void checkDictionary(const map<string, boost::any>& dict)
{
        string actualString = "hello there";
        double actualDouble = 1.34223;
        int actualInt = -3455;

        // checking byte array
        std::ifstream stream("testImage.png", std::ios::binary);
        if(!stream)
            throw std::runtime_error("Can't open file: testImage.png");

        int start = stream.tellg();
        stream.seekg(0, std::ifstream::end);
        int size = ((int) stream.tellg()) - start;
        std::vector<char> actualData(size);
        if(size > 0)
        {
            stream.seekg(0, std::ifstream::beg);
            stream.read( (char *)&actualData[0], size );
        }
        else
        {
            throw std::runtime_error("Can't read zero length data");
        }

#ifdef TEST_VERBOSE
        cout<<"   Checking data"<<endl<<"     length: "<<endl;
#endif


        const vector<char>& plistData = boost::any_cast<const vector<char>& >(dict.find("testImage")->second);

        // length
        CHECK_EQUAL(actualData.size(), plistData.size());
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl<<"     Data values: "<<endl;
#endif


        // data
        CHECK_ARRAY_EQUAL(actualData.data(), plistData.data(), actualData.size());
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl;
#endif


        // checking double

#ifdef TEST_VERBOSE
        cout<<"   Checking double "<<endl;
#endif


        CHECK_CLOSE(actualDouble,boost::any_cast<const double&>(dict.find("testDouble")->second), 1E-5); 
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl;
#endif


        // checking float 
        
#ifdef TEST_VERBOSE
        cout<<"   Checking float "<<endl;
#endif


        CHECK_CLOSE(actualDouble,boost::any_cast<const double&>(dict.find("testFloat")->second), 1E-5); 
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl;
#endif


        // checking int
#ifdef TEST_VERBOSE
        cout<<"   Checking int "<<endl;
#endif


        CHECK_EQUAL(actualInt, boost::any_cast<const int64_t&>(dict.find("testInt")->second));
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl;
#endif


        // checking string
#ifdef TEST_VERBOSE
        cout<<"   Checking string "<<endl;
#endif


        CHECK_ARRAY_EQUAL(actualString.c_str(),  boost::any_cast<const string&>(dict.find("testString")->second).c_str(), actualString.size());
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl;
#endif


        // checking array
#ifdef TEST_VERBOSE
        cout<<"   Checking array "<<endl;
#endif

        const vector<boost::any>& plistArray = boost::any_cast<const vector<boost::any>& >(dict.find("testArray")->second);
        int actualArrayItem0 = 34;
        string actualArrayItem1 = "string item in array";
        CHECK_EQUAL(actualArrayItem0, boost::any_cast<const int64_t&>(plistArray[0]));
        CHECK_ARRAY_EQUAL(actualArrayItem1.c_str(), boost::any_cast<const string&>(plistArray[1]).c_str(), actualArrayItem1.size());
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl;
#endif


        // checking long array (need to do this because there is different logic if
        // the length of the array is >= 15 elements
        
#ifdef TEST_VERBOSE
        cout<<"   Checking long array "<<endl;
#endif

        const vector<boost::any>& plistArrayLarge = boost::any_cast<const vector<boost::any>& >(dict.find("testArrayLarge")->second);
        int i = 0;
        for(vector<boost::any>::const_iterator it = plistArrayLarge.begin(); 
                i < 256;
                ++it, ++i)
            CHECK_EQUAL(i, boost::any_cast<const int64_t&>(*it));
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl;
#endif


        // checking long dict (need to do this because there is different logic if the length
        // of the dict is >= 15 elements
        
#ifdef TEST_VERBOSE
        cout<<"   Checking long dict "<<endl;
#endif

        const map<string, boost::any>& plistDictLarge = boost::any_cast<const map<string, boost::any>& >(dict.find("testDictLarge")->second);
        i = 0;
        for(map<string, boost::any>::const_iterator it = plistDictLarge.begin();
                i < 256;
                ++it, ++i)
            CHECK_EQUAL(i, boost::any_cast<const int64_t&>(it->second));
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl;
#endif


        // checking date

#ifdef TEST_VERBOSE
        cout<<"   Checking date "<<endl;
#endif


        int actualDate = 338610664;
        CHECK_EQUAL((int) actualDate, (int) boost::any_cast<const PlistDate&>(dict.find("testDate")->second).timeAsAppleEpoch());
//        cout<<"time as xml convention "<<boost::any_cast<const PlistDate&>(dict.find("testDate")->second).timeAsXMLConvention()<<endl;
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl;
#endif



        // checking bools

#ifdef TEST_VERBOSE
        cout<<"   Checking bools "<<endl;
#endif


        bool actualTrue = true;
        bool actualFalse = false;
        CHECK_EQUAL(actualTrue, boost::any_cast<const bool&>(dict.find("testBoolTrue")->second));
        CHECK_EQUAL(actualFalse, boost::any_cast<const bool&>(dict.find("testBoolFalse")->second));
#ifdef TEST_VERBOSE
        cout<<"                            done."<<endl;
#endif


//        cout<<"testString = "<<boost::any_cast<const string&>(dict.find("testString")->second)<<endl;
//        cout<<"testDouble = "<<boost::any_cast<const double&>(dict.find("testDouble")->second)<<endl;
//        cout<<"testInt = "<<boost::any_cast<const int&>(dict.find("testInt")->second)<<endl;
//        cout<<"testDate = "<<boost::any_cast<const PlistDate&>(dict.find("testDate")->second).timeAsXMLConvention()<<endl;
        //cout<<"testDate = "<<boost::any_cast<const PlistDate&>(dict.find("testDate")->second).timeAsAppleEpoch()<<endl;

}

SUITE(PLIST_TESTS)
{

    TEST(READ_XML)
    {
        map<string, boost::any> dict; 
        Plist::readPlist("XMLExample1.plist", dict);

#ifdef TEST_VERBOSE
        cout<<"READ_XML test"<<endl<<endl;
#endif

        checkDictionary(dict);
#ifdef TEST_VERBOSE
        cout<<endl<<"READ_XML test done"<<endl<<endl;
#endif

    }

    TEST(READ_BINARY)
    {
        map<string, boost::any> dict; 
        Plist::readPlist("binaryExample1.plist", dict);

#ifdef TEST_VERBOSE
        cout<<"READ_BINARY test"<<endl<<endl;
#endif

        checkDictionary(dict);
#ifdef TEST_VERBOSE
        cout<<endl<<"READ_BINARY test done"<<endl<<endl;
#endif

    }

    TEST(WRITE_BINARY)
    {
        map<string, boost::any> dict;
        createMessage(dict);
#ifdef TEST_VERBOSE
        cout<<"WRITE_BINARY test"<<endl<<endl;
#endif

        Plist::writePlistBinary("binaryExampleWritten.plist", dict);
        dict.clear();
        Plist::readPlist("binaryExampleWritten.plist", dict);
        checkDictionary(dict);
#ifdef TEST_VERBOSE
        cout<<endl<<"WRITE_BINARY test done"<<endl<<endl;
#endif

    }

    TEST(WRITE_XML)
    {
        map<string, boost::any> dict;
        createMessage(dict);
#ifdef TEST_VERBOSE
        cout<<"WRITE_XML test"<<endl<<endl;
#endif

        Plist::writePlistXML("xmlExampleWritten.plist", dict);
        dict.clear();
        Plist::readPlist("xmlExampleWritten.plist", dict);
        checkDictionary(dict);
#ifdef TEST_VERBOSE
        cout<<endl<<"WRITE_XML test done"<<endl<<endl;
#endif

    }

    TEST(WRITE_BINARY_TO_BYTE_ARRAY)
    {
#ifdef TEST_VERBOSE
        cout<<"WRITE_BINARY_TO_BYTE_ARRAY test"<<endl<<endl;
#endif

        vector<char> data;
        map<string, boost::any> dict;
        createMessage(dict);
        Plist::writePlistBinary(data, dict);
        map<string, boost::any> dictCheck;
        Plist::readPlist(&data[0], data.size(), dictCheck);
        checkDictionary(dictCheck);
#ifdef TEST_VERBOSE
        cout<<endl<<"WRITE_BINARY_TO_BYTE_ARRAY test done"<<endl<<endl;
#endif

    }

    TEST(WRITE_XML_TO_BYTE_ARRAY)
    {
#ifdef TEST_VERBOSE
        cout<<"WRITE_XML_TO_BYTE_ARRAY test"<<endl<<endl;
#endif

        vector<char> data;
        map<string, boost::any> dict;
        createMessage(dict);
        Plist::writePlistXML(data, dict);
        map<string, boost::any> dictCheck;
        Plist::readPlist(&data[0], data.size(), dictCheck);
        checkDictionary(dictCheck);
#ifdef TEST_VERBOSE
        cout<<endl<<"WRITE_XML_TO_BYTE_ARRAY test done"<<endl<<endl;
#endif

    }

    TEST(DATE)
    {
        PlistDate date;

        // check comparisons.

        double objectTime = date.timeAsAppleEpoch();

        PlistDate dateGreater(date);
        dateGreater.setTimeFromAppleEpoch(objectTime + 1);
        PlistDate dateLess(date);
        dateLess.setTimeFromAppleEpoch(objectTime - 1);

        CHECK_EQUAL(1, PlistDate::compare(dateGreater, dateLess));
        CHECK_EQUAL(-1, PlistDate::compare(dateLess, dateGreater));
        CHECK_EQUAL(0, PlistDate::compare(date, date));

        CHECK(dateGreater > dateLess);
        CHECK(dateLess < dateGreater);
        CHECK(date == date);

        dateGreater.setTimeFromAppleEpoch(objectTime + 100);

        time_t seconds = dateGreater.secondsSinceDate(date);

        CHECK_EQUAL(100, seconds);
    }

}
*/
 
posted on 2012-06-05 17:09 漂漂 閱讀(4534) 評(píng)論(0)  編輯 收藏 引用

只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            雨宫琴音一区二区在线| 国产亚洲精品久久飘花| 亚洲精品一品区二品区三品区| 久久这里只精品最新地址| 久久国产精品久久w女人spa| 国产日韩专区| 狠狠88综合久久久久综合网| 国内精品久久久久国产盗摄免费观看完整版 | 欧美亚洲一区二区在线观看| 宅男66日本亚洲欧美视频| 国产精品嫩草影院一区二区| 校园激情久久| 久久久午夜精品| 99热这里只有精品8| 亚洲一区二区视频| 激情亚洲网站| 亚洲另类在线视频| 国产精品自在在线| 久久综合影音| 国产精品成人一区二区网站软件| 久久精品国产免费看久久精品| 久久久人成影片一区二区三区 | 久久久中精品2020中文| 亚洲欧美在线x视频| 好看不卡的中文字幕| 最新亚洲一区| 国产精品一二三四区| 麻豆国产精品va在线观看不卡| 欧美丰满高潮xxxx喷水动漫| 欧美一区国产二区| 欧美激情亚洲一区| 久久久久女教师免费一区| 欧美激情91| 久久成人久久爱| 欧美成人黄色小视频| 欧美影院视频| 欧美日韩情趣电影| 欧美刺激性大交免费视频| 国产精品久久久久久久久婷婷| 亚洲图片自拍偷拍| 国产午夜精品久久久| 亚洲国产欧美日韩| 国产亚洲va综合人人澡精品| 日韩视频不卡中文| 亚洲国产欧美日韩精品| 午夜精品福利一区二区三区av| 亚洲韩国精品一区| 久久精品二区三区| 欧美在线在线| 国产精品高清一区二区三区| 亚洲大胆女人| 狠狠色综合播放一区二区| 亚洲一区二区三区在线视频| 一本色道久久88精品综合| 久久久久久久久综合| 香蕉视频成人在线观看| 欧美日韩亚洲激情| 亚洲精品乱码视频| 亚洲美女91| 欧美黑人在线播放| 亚洲黄一区二区三区| 在线日本欧美| 久久综合久色欧美综合狠狠 | 亚洲免费中文字幕| 欧美日韩精品一本二本三本| 欧美高清视频免费观看| 在线观看欧美视频| 蜜臀久久久99精品久久久久久| 久久精品国产第一区二区三区最新章节 | 欧美成人一区在线| 亚洲成人资源| 欧美成人在线网站| 亚洲黄一区二区| 夜夜嗨av一区二区三区四季av| 欧美大色视频| 日韩视频一区二区| 亚洲欧美日本在线| 国产精品一区毛片| 欧美在线观看视频一区二区| 可以看av的网站久久看| 一区久久精品| 欧美精品97| 亚洲一区二区欧美| 久久精品2019中文字幕| 亚洲成人原创| 欧美全黄视频| 亚洲欧美影音先锋| 欧美成人一区二区三区在线观看| 亚洲人成高清| 国产精品狼人久久影院观看方式| 亚洲女同性videos| 欧美成人精品福利| 一片黄亚洲嫩模| 国产精品一区二区男女羞羞无遮挡| 亚洲欧美日韩视频一区| 免费久久99精品国产自| 一区二区精品国产| 国产色爱av资源综合区| 模特精品在线| 亚洲制服av| 欧美电影免费网站| 亚洲欧美日韩精品久久久久 | 欧美91视频| 亚洲一区二区三区精品在线观看| 久久久亚洲一区| 夜夜爽av福利精品导航 | 欧美精品在线播放| 午夜视频在线观看一区二区三区| 欧美电影免费观看大全| 亚洲欧美日韩区| 亚洲激情视频在线播放| 国产精品久在线观看| 欧美大片免费久久精品三p| 亚洲一区二区视频在线观看| 欧美电影打屁股sp| 久久精品综合| 亚洲综合色在线| 亚洲伦理在线免费看| 国产亚洲精品aa| 欧美日韩一区二区在线播放| 开心色5月久久精品| 午夜精品亚洲一区二区三区嫩草| 亚洲精品美女久久7777777| 麻豆91精品| 欧美一区二区三区久久精品茉莉花| 亚洲国产高清在线| 国产一区二区三区久久| 国产精品久久婷婷六月丁香| 欧美大片第1页| 久久夜精品va视频免费观看| 午夜日韩在线| 亚洲自拍偷拍视频| 亚洲午夜激情| a4yy欧美一区二区三区| 男女视频一区二区| 噜噜噜在线观看免费视频日韩| 国产精品三上| 久久久视频精品| 久久国产婷婷国产香蕉| 亚洲欧美国产视频| 国产精品99久久久久久久久久久久| 亚洲经典自拍| 亚洲国产日韩一区| 亚洲经典在线| 亚洲欧洲一二三| 一本一本a久久| 亚洲一级片在线观看| 中日韩高清电影网| 亚洲一品av免费观看| 亚洲午夜性刺激影院| 中文高清一区| 亚洲欧美一区在线| 久久精品视频播放| 久久综合久久久久88| 欧美激情成人在线视频| 欧美日韩精品系列| 国产精品福利久久久| 国产欧美精品日韩| 国产在线精品自拍| 亚洲国产精选| 亚洲视频在线播放| 欧美在线观看一区二区| 久久亚洲欧美| 男女精品网站| 亚洲精品美女在线| 亚洲午夜精品一区二区三区他趣 | 女生裸体视频一区二区三区| 狂野欧美一区| 亚洲精品欧美| 欧美一级播放| 欧美精品18| 国产精品女同互慰在线看| 国外成人网址| 一区二区欧美国产| 久久久久久久久伊人| 亚洲国产日韩在线| 亚洲资源av| 免费观看亚洲视频大全| 国产精品福利久久久| 亚洲大胆视频| 亚洲欧洲av一区二区| 免费精品99久久国产综合精品| 亚洲精品中文在线| 久久精品99无色码中文字幕| 欧美激情国产日韩| 国产一区在线视频| 亚洲视频1区2区| 欧美国产第一页| 亚洲欧洲av一区二区三区久久| 欧美成va人片在线观看| 国产女优一区| 一区二区三区欧美在线观看| 久久一区二区三区av| 一区二区三区免费网站| 美日韩精品免费观看视频| 国产精品嫩草久久久久| 亚洲乱码视频| 男人插女人欧美| 久久gogo国模裸体人体| 国产精品国产亚洲精品看不卡15|