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

隨筆 - 224  文章 - 41  trackbacks - 0
<2012年6月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

享受編程

常用鏈接

留言簿(11)

隨筆分類(159)

隨筆檔案(224)

文章分類(2)

文章檔案(4)

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

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

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

發(fā)布了多個平臺,生成和解析plist文件,這里只給出windows平臺下的應(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 : 定義控制臺應(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) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發(fā)表評論。
網(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>
            久热精品视频在线| 麻豆精品91| 国产精品日韩在线| 性欧美长视频| 性久久久久久久久久久久| 国产午夜亚洲精品不卡| 久久裸体视频| 欧美国产一区在线| 亚洲网站在线| 欧美一区日韩一区| 亚洲欧洲日本一区二区三区| 亚洲精品久久久久久下一站| 欧美日韩免费高清| 久久精品国产一区二区电影| 久热综合在线亚洲精品| 日韩亚洲国产精品| 午夜精品久久久久久久白皮肤| 狠狠色狠色综合曰曰| 亚洲黄色免费网站| 国产精品久久一卡二卡| 久久综合久久久| 欧美日韩精品二区| 久久九九99| 欧美激情一区二区三区| 午夜久久久久久| 蜜桃久久av一区| 亚洲欧美日韩直播| 裸体歌舞表演一区二区| 午夜精品视频网站| 欧美va亚洲va香蕉在线| 欧美中文在线视频| 欧美理论电影在线观看| 久久精品一级爱片| 国产精品xxx在线观看www| 麻豆成人av| 国产精品久久久久久一区二区三区 | 美日韩精品视频| 性久久久久久久久| 欧美不卡三区| 久久只精品国产| 国产精品日本| 99视频精品全国免费| 亚洲国产精品毛片| 欧美在线观看网站| 午夜久久久久久久久久一区二区| 嫩草成人www欧美| 久久久亚洲国产天美传媒修理工 | 国产在线高清精品| 一本色道久久综合亚洲精品小说 | 日韩一本二本av| 久久久久久网| 久久精品在这里| 国产精品专区第二| 国产精品99久久久久久有的能看| 亚洲欧洲一区二区三区在线观看| 久久不射中文字幕| 久久国产精品99国产精| 国产精品一区二区在线| 亚洲视频在线一区| 亚洲一区二区三区中文字幕| 欧美精品一区二区久久婷婷| 欧美波霸影院| 尤物99国产成人精品视频| 性感少妇一区| 久久野战av| 在线精品国产成人综合| 久久黄色级2电影| 久热精品视频| 亚洲国产综合在线看不卡| 久久综合影音| 亚洲国产精品电影| 亚洲免费电影在线观看| 欧美精品一区在线观看| 99国产精品视频免费观看| 亚洲一区欧美一区| 国产精品一区=区| 久久精品国产精品| 欧美寡妇偷汉性猛交| 亚洲精品久久久蜜桃| 欧美金8天国| 中文欧美字幕免费| 久久成人免费| 亚洲第一天堂av| 欧美日本国产| 亚洲欧美另类中文字幕| 久久三级视频| 一二三区精品| 国产欧美日韩在线播放| 久久躁狠狠躁夜夜爽| 亚洲精品护士| 久久久久欧美| 夜夜爽www精品| 国产麻豆精品久久一二三| 久久久人人人| 亚洲最黄网站| 久久伊人精品天天| 99re成人精品视频| 国产午夜精品一区理论片飘花 | 国产亚洲一本大道中文在线| 久久精品盗摄| av成人免费在线| 久久久久久一区| 一本色道久久综合亚洲二区三区| 国产精品一区二区久久久| 美女视频黄 久久| 亚洲视频导航| 亚洲激情网站| 久久青草久久| 午夜久久一区| 一本一本大道香蕉久在线精品| 国产精品亚洲一区| 欧美精品亚洲二区| 久久黄金**| 亚洲私人影院在线观看| 欧美寡妇偷汉性猛交| 欧美一区二区日韩| 在线一区二区视频| 亚洲国产二区| 国产一区二三区| 国产精品午夜视频| 欧美日韩精品免费观看| 巨乳诱惑日韩免费av| 午夜精品免费在线| 中日韩高清电影网| 亚洲精品视频啊美女在线直播| 美女脱光内衣内裤视频久久网站| 亚洲在线1234| 中日韩美女免费视频网址在线观看| 影音先锋欧美精品| 国产欧美一区二区在线观看| 欧美日韩免费一区二区三区| 免费在线观看日韩欧美| 久久久成人精品| 久久精品毛片| 欧美一区免费| 久久超碰97中文字幕| 亚洲欧美久久久久一区二区三区| 亚洲美女黄色片| 99精品国产在热久久婷婷| 亚洲第一精品夜夜躁人人爽| 免费欧美在线视频| 欧美成人久久| 亚洲国产福利在线| 亚洲黄色成人网| 亚洲精品一区二区三区不| 亚洲国产精品久久久| 亚洲国产老妈| 亚洲精品一区二区三| 亚洲精品一区二区三区不| 亚洲美女毛片| 亚洲一二三区视频在线观看| 亚洲影院免费| 欧美影院精品一区| 久久婷婷国产综合尤物精品| 久久国内精品自在自线400部| 久久久999精品视频| 巨胸喷奶水www久久久免费动漫| 久久久久久一区二区三区| 久久综合色一综合色88| 欧美国产极速在线| 国产精品黄色| 黄色日韩精品| 亚洲精品五月天| 亚洲伊人观看| 久久亚洲春色中文字幕| 欧美国产亚洲视频| 夜夜嗨av一区二区三区四季av | 久热综合在线亚洲精品| 欧美护士18xxxxhd| 国产精品欧美风情| 在线观看成人av| 99精品热6080yy久久| 午夜影院日韩| 免费在线日韩av| 中文国产亚洲喷潮| 久久蜜桃精品| 欧美日韩免费观看一区| 国产一区二区你懂的| 亚洲二区在线| 亚洲欧美在线免费观看| 欧美xart系列在线观看| 亚洲天堂网在线观看| 久久久亚洲人| 国产精品呻吟| 亚洲毛片播放| 葵司免费一区二区三区四区五区| 91久久精品一区二区别| 欧美夜福利tv在线| 欧美日韩你懂的| 亚洲高清一区二| 欧美一级视频精品观看| 亚洲精品免费观看| 久久久久久9999| 国产日韩1区| 亚洲伊人一本大道中文字幕| 欧美1区视频| 欧美一区二区在线免费播放| 欧美日韩卡一卡二| 亚洲精品美女免费| 久热精品视频在线观看一区|