zoukankan      html  css  js  c++  java
  • [IOS微信] PList文件解析,boost数据读取

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

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

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

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

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

     1      std::map<std::string, boost::any> dict;
     2         Plist::readPlist(“mmsetting.archive”, dict); 
     3 
     4         for (auto it = dict.begin(); it != dict.end(); ++it)
     5         {
     6 //             if (it->first == "$version")
     7 //             {
     8 //                 const int& ver = boost::any_cast<const int&>(it->second);
     9 // 
    10 //                 cout << "$version: " << ver << endl;
    11 //             }
    12             std::string strStringType = "class std::basic_string";
    13             std::string strMapType = "class std::map";
    14 
    15             if (it->first == "$objects")
    16             {
    17                 const std::vector<boost::any>& plistArray = boost::any_cast<const std::vector<boost::any>&>(it->second);
    18                 for (int i = 0; i < plistArray.size(); i++)
    19                 {
    20                     // plistArray[i].type()
    21                     std::string typeName = plistArray[i].type().name();
    22                     std::string key_context_type = typeName.substr(0, strStringType.length());
    23 
    24                     if (strStringType == key_context_type)
    25                     {
    26                         const std::string & key_context = boost::any_cast<const std::string &> (plistArray[i]);
    27                         //cout << key_context_type.c_str() << ": " << key_context.c_str() << endl;
    28                         vec.emplace_back(key_context);
    29                     }
    30                     else
    31                     {
    32                         key_context_type = typeName.substr(0, strMapType.length());
    33                         if (strMapType == key_context_type)
    34                         {
    35                             //cout << key_context_type.c_str() << endl;
    36                             //const map<string, boost::any>& subdict = boost::any_cast<const map<string, boost::any> &> (plistArray[i]);
    37                         }
    38                     }
    39 
    40                 }
    41             }
    42         }
    43 
    44 
    45         //         const vector<boost::any>& plistArray = boost::any_cast<const vector<boost::any>&>(dict.find("testArray")->second);
    46         //         cout << boost::any_cast<const int64_t&>(plistArray[0]) << endl;
    47         //         cout << boost::any_cast<const string&>(plistArray[1]).c_str() << endl;
  • 相关阅读:
    MySQL优化查询语句Explain
    Spring Kafka(二)操作Topic以及Kafka Tool 2的使用
    集群作业管理OpenPBS与OpenPBS Interface Library
    OpenPBS 脚本样本 非常值得参考
    mpirun 与 PBS 问题
    MPIRUN 与 PBS 脚本
    什么是IA架构服务器
    集群的管理pbs
    软件包 javax.servlet 不存在
    An introduction to PORTABLE BATCH SYSTEM
  • 原文地址:https://www.cnblogs.com/pjl1119/p/8610968.html
Copyright © 2011-2022 走看看