示例#1
0
void Config::set(PMap &a, const PMap &b, bool merge) {
	if(!merge) {
		a.clear();
		a = b;
		return;
	}
	for(PMap::const_iterator i = b.begin(); i != b.end(); ++i) {
		a.insert(*i);
	}
}
示例#2
0
 Tag(const std::string& tag, const PMap& props, std::ostream& os)
     : name_(tag), os_(os)
 {
     indent(os);
     os << "<" << tag;
     for (PMap::const_iterator it = props.begin(); it != props.end(); ++it) {
         os << " " << it->first << "=\"" << it->second << "\"";
     }
     os << ">\n";
     ++indent_;
 }
示例#3
0
bool Config::loadSetting(const std::string &line, const std::string &name, PMap &var) const {
	size_t i = isSetting(line, name, "=");
	if(i != std::string::npos) {
		size_t j = line.find(':', i);
		if(j == std::string::npos) { return false; }
		var.clear();
		var.insert(PMap::value_type(
			trim(line.substr(i, j - i)),
			trim(line.substr(j + 1))
		));
		return true;
	}
	i = isSetting(line, name, "+=");
	if(i != std::string::npos) {
		size_t j = line.find(':', i);
		if(j == std::string::npos) { return false; }
		var.insert(PMap::value_type(
			trim(line.substr(i, j - i)),
			trim(line.substr(j + 1))
		));
		return true;
	}
	i = isSetting(line, name, "-=");
	if(i != std::string::npos) {
		size_t j = line.find(':', i);
		if(j == std::string::npos) { return false; }
		PMap::iterator a = var.find(PMap::value_type(
			trim(line.substr(i, j - i)),
			trim(line.substr(j + 1))
		));
		if(a != var.end()) {
			var.erase(a);
		}
		return true;
	}
	return false;
}