cocos2d-x开发: 一切应该从配置文件读取开始(4)
来源:未知 责任编辑:责任编辑 发表时间:2015-03-01 01:33 点击:次
p> 75 }
p> 76 }
p> 77 fout.close();
p> 78 }
p> 79 bool INICache::isSectionExist(const std::string& section) const
p> 80 { return (this->propsMap_.find(section) != this->propsMap_.end()); }
p> 81 bool INICache::deleteSection(const std::string& section)
p> 82 {
p> 83 if(!section.empty()) { return false; }
p> 84 SKVtype::iterator skv_iter = this->propsMap_.find(section);
p> 85 if(skv_iter != this->propsMap_.end())
p> 86 {
p> 87 this->propsMap_.erase(skv_iter);
p> 88 return true;
p> 89 }
p> 90 return false;
p> 91 }
p> 92 void INICache::getSectionNames(std::vector<std::string>& sectionVector)
p> 93 {
p> 94 if(!sectionVector.empty()) { sectionVector.clear(); }
p> 95 SKVtype::iterator skv_iter = this->propsMap_.begin();
p> 96 for(; skv_iter != this->propsMap_.end(); ++skv_iter)
p> 97 { sectionVector.push_back(skv_iter->first); }
p> 98 }
p> 99 void INICache::setString(const std::string& section, const std::string& key, const std::string& value)
p>100 {
p>101 if(!section.empty() && !key.empty())
p>102 { this->propsMap_[section][key] = value; }
p>103 }
p>104 std::string INICache::getString(const std::string& section, const std::string& key, const std::string& defaultValue)
p>105 {
p>106 if(!section.empty() && !key.empty())
p>107 {
p>108 SKVtype::iterator skv_iter = this->propsMap_.find(section);
p>109 if(skv_iter != this->propsMap_.end())
p>110 {
p>111 KVtype::iterator kv_iter = skv_iter->second.find(key);
p>112 if(kv_iter != skv_iter->second.end())
p>113 { return kv_iter->second; }
p>114 }
p>115 }
p>116 return defaultValue;
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>