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 env, const char * name=0)
public IloXmlContext(IloXmlContextI * impl=0)
Method Summary
public voidend()
public IloIntgetChildIdReadError() const
public const char *getChildTagReadError() const
public IloIntArraygetIdListReadError() const
public IloXmlContextI *getImpl() const
public IloIntgetParentIdReadError() const
public const char *getParentTagReadError() const
public IloAnyArraygetTagListReadError() const
public const char *getWriteError() const
public intgetWritePrecision() const
public IloBoolreadModel(IloModel model, istream & file) const
public IloBoolreadModel(IloModel model, const char * fileName) const
public IloBoolreadModelAndSolution(IloModel model, const char * modelFileName, IloSolution solution, const char * solutionFileName) const
public IloBoolreadRtti(IloXmlReader reader, IloXmlElement * element) const
public IloBoolreadSolution(IloSolution solution, istream & file) const
public IloBoolreadSolution(IloSolution solution, const char * fileName) const
public IloBoolreadSolutionValue(IloSolution solution, IloXmlElement * root, IloXmlReader reader) const
public voidregisterXML(IloTypeIndex index, IloXmlInfo * xmlinfo) const
public voidregisterXMLArray(IloXmlInfo * xmlinfo) const
public IloBoolsetWriteMode(IloInt mode) const
public voidsetWritePrecision(int writePrecision) const
public IloBoolwriteModel(const IloModel model, const char * fileName) const
public IloBoolwriteModelAndSolution(const IloModel model, const char * modelFileName, const IloSolution solution, const char * solutionFileName) const
public IloBoolwriteRtti(const IloRtti * it, IloXmlWriter writer, IloXmlElement * masterElement) const
public IloBoolwriteSolution(const IloSolution solution, const char * fileName) const
public voidwriteSolutionValue(const IloExtractable it, const IloSolution solution, IloXmlWriter writer) const
Constructor Detail

IloXmlContext

public IloXmlContext(IloEnv env, const char * name=0)

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


IloXmlContext

public IloXmlContext(IloXmlContextI * impl=0)

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() const

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() const

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() const

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 IloXmlContextI * getImpl() const

This member function returns the IloXmlContextI implementation.


getParentIdReadError

public IloInt getParentIdReadError() const

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() const

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() const

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() const

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


getWritePrecision

public int getWritePrecision() const

This member function returns the write precision for floats


readModel

public IloBool readModel(IloModel model, istream & file) const

This member function reads model from an XML stream.


readModel

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

This member function reads model from the XML file fileName.


readModelAndSolution

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

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


readRtti

public IloBool readRtti(IloXmlReader reader, IloXmlElement * element) const

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


readSolution

public IloBool readSolution(IloSolution solution, istream & file) const

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) const

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) const

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


registerXML

public void registerXML(IloTypeIndex index, IloXmlInfo * xmlinfo) const

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.

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

registerXMLArray

public void registerXMLArray(IloXmlInfo * xmlinfo) const

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) const

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) const

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.


writeModel

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

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) const

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


writeRtti

public IloBool writeRtti(const IloRtti * it, IloXmlWriter writer, IloXmlElement * masterElement) const

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:


writeSolution

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

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


writeSolutionValue

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

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: