最近在解析IOS版微信数据中的 mmsetting.archive 文件时,第一次接触到PList文件。

注:mmsetting.archive  不是一个标准的PList文件,其中含有汉字,并且很多value没有对应的key值

在GITHUB上找到了开源的PListCpp库,可以解析PList文件。经过我的修改完善,可以读取汉字(见上一篇博客)

但读取出的数据在一个列表中,用到boost::any,

我对boost并不熟悉,经大牛帮忙,读取的数据方式如下:

      std::map<std::string, boost::any> dict;
Plist::readPlist(“mmsetting.archive”, dict); for (auto it = dict.begin(); it != dict.end(); ++it)
{
// if (it->first == "$version")
// {
// const int& ver = boost::any_cast<const int&>(it->second);
//
// cout << "$version: " << ver << endl;
// }
std::string strStringType = "class std::basic_string";
std::string strMapType = "class std::map"; if (it->first == "$objects")
{
const std::vector<boost::any>& plistArray = boost::any_cast<const std::vector<boost::any>&>(it->second);
for (int i = ; i < plistArray.size(); i++)
{
// plistArray[i].type()
std::string typeName = plistArray[i].type().name();
std::string key_context_type = typeName.substr(, strStringType.length()); if (strStringType == key_context_type)
{
const std::string & key_context = boost::any_cast<const std::string &> (plistArray[i]);
//cout << key_context_type.c_str() << ": " << key_context.c_str() << endl;
vec.emplace_back(key_context);
}
else
{
key_context_type = typeName.substr(, strMapType.length());
if (strMapType == key_context_type)
{
//cout << key_context_type.c_str() << endl;
//const map<string, boost::any>& subdict = boost::any_cast<const map<string, boost::any> &> (plistArray[i]);
}
} }
}
} // 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;

[IOS微信] PList文件解析,boost数据读取的更多相关文章

  1. iOS中plist的创建,数据写入与读取

    iOS中plist的创建,数据写入与读取 Documents:应用将数据存储在Documents中,但基于NSuserDefaults的首选项设置除外Library:基于NSUserDefaults的 ...

  2. 蜗牛爱课- iOS中plist的创建,数据写入与读取

    iOS中plist的创建,数据写入与读取功能创建一个test.plist文件-(void)triggerStorage{    NSArray *paths=NSSearchPathForDirect ...

  3. IOS 获取.plist文件的数据

      @property (nonatomic,strong) NSArray *apps; //获取.plist数据 /**获取plist文件的数组数据*/ -(NSArray *)apps{ if( ...

  4. IOS开发-OC学习-Info.plist文件解析

    Info.plist文件是新建ios项目完成后自动生成的一个配置文件,在Xcode中如下图: 通过解析可以获得配置的具体细节,解析过程如下: // 定义一个nsstring用来获取Info.plist ...

  5. IOS的XML文件解析,利用了NSData和NSFileHandle

    如果需要了解关于文档对象模型和XML的介绍,参看 http://www.cnblogs.com/xinchrome/p/4890723.html 读取XML 上代码: NSFileHandle *fi ...

  6. iOS开发-plist文件增删改查

    plist第一次看到这个后缀名文件的时候感觉怪怪的,不过接触久了也就习以为常了,plist是Property List的简称可以理解成属性列表文件,主要用来存储串行化后的对象的文件.扩展名为.plis ...

  7. iOS 中plist文件中配置key值冲突的现象

    iOS开发一些特殊的软件需要在项目中配置对应的key值,然而近期在项目中发现一个有意思的现象,苹果官方文档中提供的key值很多,但其实有一些彼此可能有冲突,当你同时配置了彼此冲突的key值,可能会出现 ...

  8. Python: 文件操作与数据读取

    文件及目录操作 python中对文件.文件夹(文件操作函数)的操作需要涉及到os模块,主要用到的几个函数是, import os 返回指定目录下的所有文件和目录名: os.listdir() 重命名: ...

  9. iOS instruments trace文件解析方案

    前言 已很少写文章,不过这次感觉有必要写一下.因为: 1. 这个方案通过debug逆向得来,很有参考意义. 2. iOS这方面资料非常少,做这块时,无论国内外,翻遍了google,baidu都没太多合 ...

随机推荐

  1. CentOS6.X、7.X下Jenkins的安装及使用

    一.相关概念 1.1 Jenkins概念: Jenkins是一个功能强大的应用程序,允许持续集成和持续交付项目,无论用的是什么平台.这是一个免费的源代码,可以处理任何类型的构建或持续集成.集成Jenk ...

  2. centos7安装tomcat8 新手入门 图文教程

    系统环境 操作系统:64位CentOS Linux release 7.2.1511 (Core) JDK版本:1.8.0_121 下载tomcat8压缩包 访问官网:http://tomcat.ap ...

  3. Hibernate的查询功能

    1.Query对象 1.使用Query对象,不需要写sql语句,但是写hql语句 (1)hql:hibernate query language,提供查询语言,这个hql语言和普通sql语句相似 (2 ...

  4. async await 多线程

    async await 并没有开启多线程  出现await的地方 只是开启了一个子线程继续往后执行  主线程返回 防止阻塞 相当于  await customerRepository.getall() ...

  5. 贪心 —— 今年暑假不AC

    贪心基本题, 有助于理解贪心算法的思想 #include <cstdio> #include <algorithm> using namespace std; struct P ...

  6. sort-插入排序

    void sort_insertion(vector<int> &v) { for(int i=1;i<v.size();i++) { for(int j=i;j>0; ...

  7. echarts画多条一元回归线

    理论上两点一线,只要两个点即可 option = { title: { text: '', left: 'center' }, tooltip: { // trigger: 'item', // fo ...

  8. Enable SMB2 on the Client

    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanWorkstation edit DependOnService and add ...

  9. English trip V1 - B 1. How much is it? 它是多少钱? Teacher:Corrine Key: is/are

    In this lesson you will learn to ask about prices. 本节课你将学习询问关于价格 课上内容(Lesson) one piece of     two p ...

  10. 京东某商品页面的简单爬取 --Pyhon网络爬虫与信息获取

    1.京东商品页面链接地址(本次要爬取的页面url) https://item.jd.hk/1953999200.html 2.代码部分 import requestsurl = "https ...