NO FRAMES

Class IloXmlContext

Definition file: ilconcert/iloxmlcontext.h

An instance of IloXmlContext allows you to serialize an IloModel or an IloSolution in XML.

You can write an IloModel using IloXmlContext::writeModel, write an IloSolution using IloXmlContext::writeSolution, or write both using IloXmlContext::writeModelAndSolution.

You can read an IloModel in XML using IloXmlContext::readModel, read an IloSolution in XML using IloXmlContext::readSolution, or read both using IloXmlContext::readModelAndSolution.

Other products should add their own serialization class and add them to the plug-in using the member functions IloXmlContext::registerXML and IloXmlContext::registerXMLArray.

Examples

For example, you can write:

  IloModel model(env);
	IloSolution solution(env);
   ...;
  IloXmlcontext context(env);
  context.writeModel(model, "model.xml");
  context.writeSolution(solution, "solution.xml");
 

or you can write

  IloModel model(env);
	IloSolution solution(env);
	IloXmlcontext context(env);
	context.readModel(model, "model.xml");
	context.readSolution(solution, "solution.xml");
 

See Also:

Constructor Summary
public IloXmlContext(IloEnv)
public IloXmlContext(IloXmlContextI *)
Method Summary
public voidend()
public IloIntgetChildIdReadError()
public const char *getChildTagReadError()
public IloIntArraygetIdListReadError()
public const IloXmlContextI *getImpl()
public IloIntgetParentIdReadError()
public const char *getParentTagReadError()
public IloAnyArraygetTagListReadError()
public const char *getWriteError()
public intgetWritePrecision()
public IloBoolreadExtractable(IloXmlReader, IloXmlElement *)
public IloBoolreadModel(IloModel, istream &)
public IloBoolreadModel(IloModel, const char *)
public IloBoolreadModelAndSolution(IloModel, const char *, IloSolution, const char *)
public IloBoolreadSolution(IloSolution, istream &)
public IloBoolreadSolution(IloSolution, const char *)
public IloBoolreadSolutionValue(IloSolution, IloXmlElement *, IloXmlReader)
public voidregisterXML(IloTypeIndex, IloXmlInfo *)
public voidregisterXMLArray(IloXmlInfo *)
public IloBoolsetWriteMode(IloInt)
public voidsetWritePrecision(int)
public IloBoolwriteExtractable(const IloExtractableI *, IloXmlWriter, IloXmlElement *)
public IloBoolwriteModel(const IloModel, const char *)
public IloBoolwriteModelAndSolution(const IloModel, const char *, const IloSolution, const char *)
public IloBoolwriteSolution(const IloSolution, const char *)
public voidwriteSolutionValue(const IloExtractable, const IloSolution, IloXmlWriter)
Constructor Detail

IloXmlContext

public IloXmlContext(IloEnv env)

This constructor creates an XML context and makes it part of the environment env.


IloXmlContext

public IloXmlContext(IloXmlContextI * impl)

This constructor creates a XML context from its implementation object.


Method Detail

end

public void end()

This member function deletes the invoking XML context.


getChildIdReadError

public IloInt getChildIdReadError()

This member function returns the XML ID of the child unparsed XML element in cases where a problem occurs when reading an IloModel.


getChildTagReadError

public const char * getChildTagReadError()

This member function returns the XML tag of the child unparsed XML element in cases where a problem occurs when reading an IloModel


getIdListReadError

public IloIntArray getIdListReadError()

This member function returns the XML ID list of the unparsed XML elements in cases where a problem occurs when reading an IloModel. The list is composed of the tags from the parent to the child elements.


getImpl

public const IloXmlContextI * getImpl()

This member function returns the IloXmlContextI implementation.


getParentIdReadError

public IloInt getParentIdReadError()

This member function returns the XML ID of the parent unparsed XML element in cases where a problem occurs when reading an IloModel.


getParentTagReadError

public const char * getParentTagReadError()

This member function returns the XML tag of the parent unparsed XML element in cases where a problem occurs when reading an IloModel.


getTagListReadError

public IloAnyArray getTagListReadError()

This member function returns the XML tag list of the unparsed XML elements in cases where a problem occurs when reading an IloModel. The list is composed of the tags from the parent to the child elements.


getWriteError

public const char * getWriteError()

This member function returns the name of the extractable called in cases where a problem occurs when reading an IloModel.


getWritePrecision

public int getWritePrecision()

This member function returns the write precision for floats


readExtractable

public IloBool readExtractable(IloXmlReader reader, IloXmlElement * element)

This member function tries to read all extractables from the XML element.


readModel

public IloBool readModel(IloModel model, istream & file)

This member function reads model from an XML stream.


readModel

public IloBool readModel(IloModel model, const char * fileName)

This member function reads model from the XML file fileName.


readModelAndSolution

public IloBool readModelAndSolution(IloModel model, const char * modelFileName, IloSolution solution, const char * solutionFileName)

This member function reads model and solution from their respective XML files, modelFileName and solutionFileName.


readSolution

public IloBool readSolution(IloSolution solution, istream & file)

This member function reads solution from an XML stream.

Note
This member function only works if a model has already been serialized.

readSolution

public IloBool readSolution(IloSolution solution, const char * fileName)

This member function reads solution from the XML file fileName.

Note
This member function only works if a model has already been serialized.

readSolutionValue

public IloBool readSolutionValue(IloSolution solution, IloXmlElement * root, IloXmlReader reader)

This member function reads an IloSolution object from an XML element.


registerXML

public void registerXML(IloTypeIndex index, IloXmlInfo * xmlinfo)

This member function registers the serialization class of an extractable with a linked ID, usually its RTTI index. In write mode, the RTTI index is used to catch the correct serialization class.

In read mode, IloXmlInfo::getTagName is used to link the correct serialization class to the correct tag.

   IloXmlcontext context(env);
	  context.registerXML(IloAllDiffI::GetTypeIndex(), new (env) IloXmlInfo_AllDiff(context));
 

registerXMLArray

public void registerXMLArray(IloXmlInfo * xmlinfo)

This member function registers the serialization class of an array of extractables with a linked ID.

   context.registerXMLArray(new (env) IloXmlInfo_SOS2Array(context));
 

setWriteMode

public IloBool setWriteMode(IloInt mode)

This member function sets the write mode. The write mode can be set to NoUnknown or EvenUnknown. NoUnknown throws an exception if an attempt is made to serialize an unknown extractable. EvenUnknown writes a Unknown tag with the name of the extractable in a type attribute.


setWritePrecision

public void setWritePrecision(int writePrecision)

This member function sets the write precision for floats. By default, there is no rounding mode on an IloNum or an IloNumArray. You can also choose the no rounding mode with the IloNoRoundingMode constant.


writeExtractable

public IloBool writeExtractable(const IloExtractableI * it, IloXmlWriter writer, IloXmlElement * masterElement)

This member function writes a specified extractable. It is used from the serialization class of an extractable to write a embedded extractable.

The IloOr object calls this method on its constrained vars.

See Also:


writeModel

public IloBool writeModel(const IloModel model, const char * fileName)

This member function writes model to the file fileNamein XML format.


writeModelAndSolution

public IloBool writeModelAndSolution(const IloModel model, const char * modelFileName, const IloSolution solution, const char * solutionFileName)

This member function writes model to the file modelFileName and solution to the file solutionFileName in XML format.


writeSolution

public IloBool writeSolution(const IloSolution solution, const char * fileName)

This member function writes solution to the file fileName in XML format.


writeSolutionValue

public void writeSolutionValue(const IloExtractable it, const IloSolution solution, IloXmlWriter writer)

This member function writes a specified extractable of a solution in XML. It is used from the serialization class of an extractable to write an embedded extractable.

See Also: