cocos2d-x开发: 一切应该从配置文件读取开始(3)
来源:未知 责任编辑:责任编辑 发表时间:2015-03-01 01:33 点击:次
p> 33 this->parseLine(lineBuffer);
p> 34 }
p> 35 fin.close();
p> 36 this->M_filePath_ = filePath;
p> 37 return true;
p> 38 }
p> 39 INICache* INICache::createFromStream(const std::stringstream& sstream)
p> 40 {
p> 41 INICache* pINICache = new INICache;
p> 42 if(!pINICache->loadFromStream(sstream))
p> 43 {
p> 44 delete pINICache;
p> 45 return NULL;
p> 46 }
p> 47 return pINICache;
p> 48 }
p> 49 bool INICache::loadFromStream(const std::stringstream& sstream)
p> 50 {
p> 51 std::string lineBuffer;
p> 52 std::istringstream isstream(sstream.str());
p> 53 while(!isstream.eof())
p> 54 {
p> 55 std::getline(isstream, lineBuffer);
p> 56 this->trimString(lineBuffer, std::string(" "), true);
p> 57 this->parseLine(lineBuffer);
p> 58 }
p> 59 return true;
p> 60 }
p> 61 void INICache::flush(const std::string& filePath)
p> 62 {
p> 63 std::ofstream fout(filePath.c_str());
p> 64 if(!fout.is_open()) { return; }
p> 65 std::string buffer;
p> 66 SKVtype::iterator skv_iter;
p> 67 KVtype::iterator kv_iter;
p> 68 for(skv_iter = this->propsMap_.begin(); skv_iter != this->propsMap_.end(); ++skv_iter)
p> 69 {
p> 70 fout << std::endl;
p> 71 fout << std::string("[") << skv_iter->first << std::string("]") << std::endl;
p> 72 for(kv_iter = skv_iter->second.begin(); kv_iter != skv_iter->second.end(); ++kv_iter)
p> 73 {
p> 74 fout << kv_iter->first << std::string("=") << kv_iter->second << std::endl;
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>