cocos2d-x开发: 一切应该从配置文件读取开始(5)
来源:未知 责任编辑:责任编辑 发表时间:2015-03-01 01:33 点击:次
p>117 }
p>118 void INICache::setInteger(const std::string& section, const std::string& key, int value)
p>119 {
p>120 std::stringstream sstream;
p>121 sstream << value;
p>122 this->setString(section, key, sstream.str());
p>123 }
p>124 int INICache::getInteger(const std::string& section, const std::string& key, int defaultValue)
p>125 {
p>126 std::string tmp = this->getString(section, key, std::string(""));
p>127 std::stringstream sstream;
p>128 sstream << tmp;
p>129 sstream >> defaultValue;
p>130 return defaultValue;
p>131 }
p>132 void INICache::setDouble(const std::string& section, const std::string& key, double value, int pre)
p>133 {
p>134 std::stringstream sstream;
p>135 if(pre) { sstream.precision(pre); }
p>136 sstream << value;
p>137 this->setString(section, key, sstream.str());
p>138 }
p>139 double INICache::getDouble(const std::string& section, const std::string& key, double defaultValue)
p>140 {
p>141 std::string tmp = this->getString(section, key, std::string(""));
p>142 std::stringstream sstream;
p>143 if(!tmp.empty())
p>144 {
p>145 sstream << tmp;
p>146 sstream >> defaultValue;
p>147 }
p>148 return defaultValue;
p>149 }
p>150 void INICache::setBoolean(const std::string& section, const std::string& key, bool value)
p>151 { this->setInteger(section, key, value ? 1:0); }
p>152 bool INICache::getBoolean(const std::string& section, const std::string& key, bool defaultValue)
p>153 {
p>154 std::string tmp = this->getString(section, key, std::string(""));
p>155 if(!tmp.empty()) { return this->stringToBoolean(tmp, defaultValue); }
p>156 return defaultValue;
p>157 }
p>158 void INICache::trimString(std::string& buffer, const std::string& trim, bool isAll)
p>159 {
p>160 if(buffer.empty()) { return; }
p>161 while(buffer.find(trim) == 0)
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>