void ConfigManager::writeDomain(FILE *file, const String &name, const Domain &domain) {
	if (domain.empty())
		return;		// Don't bother writing empty domains.

	String comment;

	// Write domain comment (if any)
	comment = domain.getDomainComment();
	if (!comment.empty())
		fprintf(file, "%s", comment.c_str());

	// Write domain start
	fprintf(file, "[%s]\n", name.c_str());

	// Write all key/value pairs in this domain, including comments
	Domain::const_iterator x;
	for (x = domain.begin(); x != domain.end(); ++x) {
		const String &value = x->_value;
		if (!value.empty()) {
			// Write comment (if any)
			if (domain.hasKVComment(x->_key)) {
				comment = domain.getKVComment(x->_key);
				fprintf(file, "%s", comment.c_str());
			}
			// Write the key/value pair
			fprintf(file, "%s=%s\n", x->_key.c_str(), value.c_str());
		}
	}
	fprintf(file, "\n");
}
Beispiel #2
0
void ConfigManager::writeDomain(WriteStream &stream, const String &name, const Domain &domain) {
	if (domain.empty())
		return;     // Don't bother writing empty domains.

	// WORKAROUND: Fix for bug #1972625 "ALL: On-the-fly targets are
	// written to the config file": Do not save domains that came from
	// the command line
	if (domain.contains("id_came_from_command_line"))
		return;

	String comment;

	// Write domain comment (if any)
	comment = domain.getDomainComment();
	if (!comment.empty())
		stream.writeString(comment);

	// Write domain start
	stream.writeByte('[');
	stream.writeString(name);
	stream.writeByte(']');
#ifdef _WIN32
	stream.writeByte('\r');
	stream.writeByte('\n');
#else
	stream.writeByte('\n');
#endif

	// Write all key/value pairs in this domain, including comments
	Domain::const_iterator x;
	for (x = domain.begin(); x != domain.end(); ++x) {
		if (!x->_value.empty()) {
			// Write comment (if any)
			if (domain.hasKVComment(x->_key)) {
				comment = domain.getKVComment(x->_key);
				stream.writeString(comment);
			}
			// Write the key/value pair
			stream.writeString(x->_key);
			stream.writeByte('=');
			stream.writeString(x->_value);
#ifdef _WIN32
			stream.writeByte('\r');
			stream.writeByte('\n');
#else
			stream.writeByte('\n');
#endif
		}
	}
#ifdef _WIN32
	stream.writeByte('\r');
	stream.writeByte('\n');
#else
	stream.writeByte('\n');
#endif
}
 // variable varIndex has been assigned
 void whenValue(const IlcInt varIndex)
 {
     checkFailure();
     if (ToulBar2::verbose >= 2)
         cout << "ILOG: " << vars[varIndex].getName() << " = " << vars[varIndex].getValue() << endl;
     wcsp->assign(varIndex, vars[varIndex].getValue());
     if (unassignedVars->canbe(varIndex)) {
         unassignedVars->erase(varIndex);
         if (unassignedVars->empty()) {
             assert(wcsp->verify());
             obj.setValue(wcsp->getLb());
         }
     }
     push(); // global propagation done after local propagation
 }