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

隨筆 - 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>
            毛片av中文字幕一区二区| 国产精品盗摄久久久| 中文精品在线| 久久精选视频| 欧美一级在线亚洲天堂| 久久精品视频免费播放| 欧美成ee人免费视频| 国产精品一区二区三区四区五区 | 免费日韩视频| 国产一区二区你懂的| 亚洲一区日韩在线| 一区二区三区波多野结衣在线观看| 久久婷婷丁香| 久久麻豆一区二区| 国产人成精品一区二区三| 中日韩美女免费视频网址在线观看| 亚洲精品久久7777| 免费成人av| 亚洲第一精品福利| 欧美一区二区在线看| 欧美一区二区三区视频| 1769国内精品视频在线播放| 午夜一区在线| 久久久久国产精品厨房| 国产日韩精品在线观看| 欧美亚洲免费| 亚洲精品美女免费| 在线综合亚洲欧美在线视频| 国产日韩精品入口| 欧美日韩国产欧美日美国产精品| 91久久极品少妇xxxxⅹ软件| 亚洲人被黑人高潮完整版| 免费一区二区三区| 亚洲国产精品成人va在线观看| 91久久夜色精品国产网站| 国产精品久久久久久久久久妞妞 | 校园春色综合网| 亚洲国产精品精华液2区45| 性欧美超级视频| 亚洲区在线播放| 国产亚洲精品久久飘花| 欧美色大人视频| 亚洲在线视频观看| 亚洲七七久久综合桃花剧情介绍| 欧美伊人影院| 亚洲在线观看| 国精产品99永久一区一区| 久久久久国产免费免费| 亚洲黄色免费网站| 久久久午夜电影| 亚洲在线免费观看| 亚洲美女中出| 国产色爱av资源综合区| 欧美视频中文一区二区三区在线观看 | 久久国产精品久久久久久| 麻豆freexxxx性91精品| 亚洲欧洲av一区二区三区久久| 国产综合色产在线精品| 国产精品国码视频| 欧美日韩一区三区| 欧美在线一二三四区| 亚洲国产免费看| 免费高清在线一区| 久久五月激情| 亚洲一区二区三区777| 国模套图日韩精品一区二区| 国产精品乱看| 国产精品第一页第二页第三页| 欧美精品午夜视频| 久久久久久久999精品视频| 午夜精品免费视频| 亚洲青涩在线| 亚洲人妖在线| 亚洲精品在线一区二区| 久久综合激情| 老司机免费视频一区二区三区| 久久不射网站| 午夜精品美女久久久久av福利| 亚洲一级黄色片| 亚洲欧美日韩中文视频| 亚洲欧洲日产国产网站| 亚洲精品国久久99热| 日韩午夜av电影| 在线精品一区| 亚洲黄网站在线观看| 国产乱码精品一区二区三区五月婷 | 免费日韩一区二区| 欧美高清视频一区二区三区在线观看| 亚洲一二区在线| 亚洲女同性videos| 久久精品道一区二区三区| 在线亚洲精品福利网址导航| 在线一区视频| 亚洲中无吗在线| 久久久91精品国产| 亚洲国产国产亚洲一二三| 亚洲欧洲在线免费| 亚洲一级二级| 在线中文字幕一区| 午夜精品在线视频| 米奇777在线欧美播放| 免费中文字幕日韩欧美| 欧美日韩亚洲免费| 国产日韩一区二区三区| 曰韩精品一区二区| 一区二区三区中文在线观看| 国产欧美日韩视频| 亚洲国产成人午夜在线一区 | 香蕉久久精品日日躁夜夜躁| 久久gogo国模裸体人体| 欧美成人国产| 一本久久知道综合久久| 日韩亚洲欧美一区二区三区| 亚洲韩国精品一区| 在线亚洲成人| 久久精品中文字幕一区| 欧美精品自拍| 欧美色图一区二区三区| 国产在线精品二区| 一区二区三区视频在线| 久久久精品国产免大香伊 | 日韩亚洲在线观看| 久久aⅴ乱码一区二区三区| 欧美精品不卡| 狠狠久久亚洲欧美| 亚洲大胆视频| 欧美一区二区观看视频| 亚洲国产精品一区在线观看不卡| 亚洲一区中文| 欧美日韩国产一区| 1769国内精品视频在线播放| 午夜精品福利电影| 亚洲人人精品| 久久人人精品| 国产欧美亚洲日本| 亚洲色诱最新| 欧美激情第4页| 99精品福利视频| 亚洲欧美日韩直播| 欧美日韩国内自拍| 91久久夜色精品国产网站| 久久久久www| 午夜欧美大片免费观看| 欧美日韩在线观看视频| 亚洲精品中文字幕在线观看| 久久综合久久综合久久| 小辣椒精品导航| 国产精品男gay被猛男狂揉视频| 亚洲美女在线国产| 亚洲国产乱码最新视频| 久久视频一区二区| 韩国av一区二区| 久久国产福利| 翔田千里一区二区| 国产精品日韩在线播放| 亚洲国产精品第一区二区三区 | 久久久无码精品亚洲日韩按摩| 国产精品视频九色porn| 亚洲一区免费网站| 亚洲视频一起| 国产精品久久久久av| 亚洲自拍偷拍麻豆| 亚洲视频电影图片偷拍一区| 欧美三区在线观看| 亚洲永久字幕| 亚洲欧美日本国产有色| 免费亚洲电影在线观看| 亚洲国产综合91精品麻豆| 欧美黄色影院| 欧美国产日韩一区二区| 黄色国产精品一区二区三区| 久久久久国产免费免费| 欧美一区二区三区视频| 国产一区欧美日韩| 久久久久久久久综合| 久久国产精彩视频| 影音先锋成人资源站| 欧美激情成人在线| 欧美激情五月| 亚洲一区三区视频在线观看| 亚洲视频一二三| 国产亚洲视频在线| 欧美成人日本| 欧美国产在线视频| 亚洲一二三四久久| 性刺激综合网| 亚洲高清视频中文字幕| 亚洲精品日产精品乱码不卡| 国产精品av一区二区| 一区二区三区.www| 亚洲午夜精品久久| 国产在线精品一区二区中文| 欧美高清一区二区| 欧美四级在线观看| 久久激情视频久久| 免费欧美网站| 性娇小13――14欧美| 久久偷看各类wc女厕嘘嘘偷窃| 亚洲美女在线看| 小处雏高清一区二区三区|