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

隨筆 - 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>
            国产伪娘ts一区| 欧美午夜精品久久久久免费视 | 久久婷婷一区| 在线视频欧美日韩| 在线观看av不卡| 国产免费成人av| 欧美片在线观看| 美女精品在线观看| 欧美在线观看www| 亚洲视频网站在线观看| 亚洲国产精品va在线看黑人| 欧美中文字幕在线| 亚洲一卡二卡三卡四卡五卡| 亚洲精品一级| 亚洲福利视频网站| 激情另类综合| 黑人操亚洲美女惩罚| 国产精品麻豆成人av电影艾秋| 欧美日韩国产经典色站一区二区三区| 久久综合色88| 久久亚洲视频| 久久精品国产免费观看| 欧美一区二区三区的| 亚洲欧美一区二区精品久久久| 一区二区三区久久精品| 亚洲伦理在线观看| 亚洲精品中文字幕女同| 亚洲乱码国产乱码精品精98午夜| 亚洲国产欧美日韩精品| 亚洲激情在线| 亚洲美女91| 夜夜精品视频一区二区| 一区二区冒白浆视频| 一本不卡影院| 亚洲愉拍自拍另类高清精品| 亚洲一区黄色| 欧美亚洲综合在线| 久久精品国产清高在天天线| 久久国产天堂福利天堂| 久久精品一本| 老色鬼久久亚洲一区二区| 久久综合中文字幕| 欧美va天堂| 欧美理论电影在线播放| 欧美视频一区在线| 国产精品欧美风情| 国产亚洲视频在线观看| 伊人久久大香线| 91久久精品国产91久久| 一本色道久久综合狠狠躁篇的优点| 在线一区二区三区四区五区| 亚洲欧美精品在线观看| 久久国产精品72免费观看| 麻豆成人综合网| 亚洲国产精品一区二区久| 日韩视频在线观看一区二区| 亚洲在线观看免费视频| 久久理论片午夜琪琪电影网| 欧美风情在线| 国产伦精品一区二区三区照片91| 黑人巨大精品欧美一区二区小视频 | 国产欧美日韩在线播放| 狠狠色香婷婷久久亚洲精品| 亚洲国产精品悠悠久久琪琪| 一本一本久久a久久精品牛牛影视| 亚洲欧美在线磁力| 麻豆成人精品| 日韩一区二区精品葵司在线| 性欧美xxxx大乳国产app| 麻豆freexxxx性91精品| 欧美视频免费在线观看| 好看的亚洲午夜视频在线| 日韩一级在线观看| 久久国产精品久久国产精品| 欧美国产精品久久| 亚洲午夜精品一区二区| 久久综合五月天婷婷伊人| 欧美日韩在线观看视频| 黄网站色欧美视频| 亚洲午夜视频在线观看| 麻豆久久婷婷| 这里只有精品电影| 久久综合久久久久88| 国产精品视频xxx| 亚洲激情黄色| 欧美一区二区三区免费观看视频| 欧美寡妇偷汉性猛交| 亚洲欧美日韩中文视频| 欧美极品在线视频| 黄色亚洲在线| 午夜激情综合网| 亚洲国产欧美日韩另类综合| 久久av一区二区三区漫画| 欧美日韩久久不卡| 亚洲福利视频一区二区| 欧美在线观看网址综合| 亚洲美女视频在线观看| 免费成人高清视频| 国产精品视频一区二区高潮| 亚洲另类一区二区| 美国十次成人| 欧美一区91| 国产精品福利av| 亚洲美女啪啪| 欧美jizz19性欧美| 新狼窝色av性久久久久久| 欧美日韩在线一区二区三区| 亚洲国产成人在线| 久热国产精品视频| 亚洲欧美日韩在线综合| 国产精品v片在线观看不卡| 亚洲精品综合久久中文字幕| 免费中文日韩| 久久人人爽国产| 国内精品久久久久久久97牛牛| 亚洲欧美另类国产| 夜夜精品视频一区二区| 欧美日韩亚洲免费| 亚洲最新在线| 亚洲免费av网站| 欧美美女日韩| 一区二区欧美精品| 亚洲精品久久久久久久久久久 | 美女精品在线观看| 久久国产精品第一页| 国产色视频一区| 久久精品国产亚洲5555| 亚洲欧美日韩另类| 国产麻豆午夜三级精品| 午夜欧美视频| 性高湖久久久久久久久| 国产亚洲人成a一在线v站| 久久久久久久久久久一区| 久久国产视频网站| 在线观看成人小视频| 欧美夫妇交换俱乐部在线观看| 老司机午夜精品视频在线观看| 亚洲国产精品va在线看黑人动漫 | 欧美精品一区二区在线观看 | 老司机午夜免费精品视频| 久久精品成人一区二区三区| 国模一区二区三区| 麻豆久久婷婷| 欧美www在线| 一区二区三区日韩在线观看| 亚洲免费福利视频| 国产精品一区二区三区乱码| 久久精品人人做人人爽电影蜜月 | 国产精品激情偷乱一区二区∴| 午夜日韩电影| 久久九九精品| 亚洲精品看片| 夜夜精品视频一区二区| 国产视频不卡| 欧美aaaaaaaa牛牛影院| 欧美日韩国产精品专区| 性色av香蕉一区二区| 久久精品免费播放| 亚洲美女av网站| 一本到高清视频免费精品| 国产日韩欧美在线播放| 欧美成人精品影院| 欧美视频一区二区三区在线观看 | 欧美深夜福利| 久久久www成人免费毛片麻豆| 蜜臀久久99精品久久久画质超高清 | 午夜性色一区二区三区免费视频| 激情另类综合| 亚洲精选一区二区| 国产欧美日韩中文字幕在线| 欧美韩日视频| 国产麻豆成人精品| 亚洲第一视频| 国产女主播视频一区二区| 欧美韩日视频| 国产精品一区二区三区免费观看 | 亚洲国产日韩欧美综合久久 | 久久综合网络一区二区| 亚洲一本大道在线| 开心色5月久久精品| 亚洲欧美电影院| 欧美h视频在线| 久久精品国产99| 欧美日韩亚洲一区二区三区| 久久米奇亚洲| 国产精品久久7| 欧美激情在线观看| 国产欧美1区2区3区| 亚洲人成久久| 狠狠色丁香婷婷综合久久片| 亚洲视频免费观看| 亚洲欧洲在线视频| 久久精品99无色码中文字幕| 亚洲性av在线| 欧美国产欧美综合| 欧美77777| 狠狠色噜噜狠狠色综合久| 亚洲午夜精品视频| 国产精品99久久久久久久女警| 久久亚洲精品一区|