XMLConversion Class Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
XMLConversion Class Reference

`#include <openbabel/xml.h>`

Inheritance diagram for XMLConversion:
[legend]

List of all members.

## Public Types
typedef std::map< std::string, XMLBaseFormat * > | NsMapType
## Public Member Functions
| XMLConversion (OBConversion *pConv)
| ~XMLConversion ()
bool | SetupReader ()
bool | SetupWriter ()
bool | ReadXML (XMLBaseFormat *pFormat, OBBase *pOb)
int | SkipXML (const char *ctag)
bool | IsLast ()
int | GetOutputIndex ()
xmlTextReaderPtr | GetReader () const
xmlTextWriterPtr | GetWriter () const
void | OutputToStream ()
void | LookForNamespace ()
std::string | GetAttribute (const char *attrname)
std::string | GetContent ()
bool | GetContentInt (int &value)
bool | GetContentDouble (double &value)
void | CopyOptions (OBConversion *pSourceConv, Option_type typ=ALL)
Parameter get and set
std::istream * | GetInStream () const
std::ostream * | GetOutStream () const
void | SetInStream (std::istream *pIn)
void | SetOutStream (std::ostream *pOut)
bool | SetInAndOutFormats (const char *inID, const char *outID)
bool | SetInAndOutFormats (OBFormat *pIn, OBFormat *pOut)
bool | SetInFormat (const char *inID)
bool | SetInFormat (OBFormat *pIn)
bool | SetOutFormat (const char *outID)
bool | SetOutFormat (OBFormat *pOut)
OBFormat * | GetInFormat () const
OBFormat * | GetOutFormat () const
std::string | GetInFilename () const
std::streampos | GetInPos () const
size_t | GetInLen () const
const char * | GetTitle () const
OBConversion * | GetAuxConv () const
void | SetAuxConv (OBConversion *pConv)
Supported file format
std::vector< std::string > | GetSupportedInputFormat ()
std::vector< std::string > | GetSupportedOutputFormat ()
Conversion
int | Convert (std::istream *is, std::ostream *os)
int | Convert ()
int | FullConvert (std::vector< std::string > &FileList, std::string &OutputFileName, std::vector< std::string > &OutputFileList)
Conversion loop control
int | AddChemObject (OBBase *pOb)
OBBase * | GetChemObject ()
bool | IsFirstInput ()
void | SetFirstInput (bool b=true)
int | GetOutputIndex () const
void | SetOutputIndex (int indx)
void | SetMoreFilesToCome ()
void | SetOneObjectOnly (bool b=true)
void | SetLast (bool b)
bool | IsLastFile ()
int | GetCount () const
## Static Public Member Functions
static NsMapType & | Namespaces ()
static void | RegisterXMLFormat (XMLBaseFormat *pFormat, bool IsDefault=false, const char *uri=NULL)
static XMLConversion * | GetDerived (OBConversion *pConv, bool ForReading=true)
static XMLBaseFormat * | GetDefaultXMLClass ()
static int | ReadStream (void *context, char *buffer, int len)
static int | WriteStream (void *context, const char *buffer, int len)
Collection of formats
static int | RegisterFormat (const char *ID, OBFormat *pFormat, const char *MIME=NULL)
static OBFormat * | FindFormat (const char *ID)
static OBFormat * | FindFormat (const std::string ID)
static OBFormat * | FormatFromExt (const char *filename)
static OBFormat * | FormatFromExt (const std::string filename)
static OBFormat * | FormatFromMIME (const char *MIME)
static bool | GetNextFormat (Formatpos &itr, const char *&str, OBFormat *&pFormat)
Information
static const char * | Description ()
## Public Attributes
bool | _SkipNextRead
## Protected Types
typedef std::map< std::string, int > | OPAMapType
typedef FilteringInputStreambuf < LineEndingExtractor > | LErdbuf
## Protected Member Functions
bool | SetStartAndEnd ()
bool | OpenAndSetFormat (bool SetFormat, std::ifstream *is, std::stringstream *ss=NULL)
## Static Protected Member Functions
static OPAMapType & | OptionParamArray (Option_type typ)
static int | LoadFormatFiles ()
## Protected Attributes
std::string | InFilename
std::istream * | pInStream
std::ostream * | pOutStream
OBFormat * | pInFormat
OBFormat * | pOutFormat
std::map< std::string, std::string > | OptionsArray [3]
int | Index
unsigned int | StartNumber
unsigned int | EndNumber
int | Count
bool | m_IsFirstInput
bool | m_IsLast
bool | MoreFilesToCome
bool | OneObjectOnly
bool | ReadyToInput
bool | CheckedForGzip
bool | NeedToFreeInStream
bool | NeedToFreeOutStream
LErdbuf * | pLineEndBuf
OBBase * | pOb1
std::streampos | wInpos
std::streampos | rInpos
size_t | wInlen
size_t | rInlen
OBConversion * | pAuxConv
std::vector< std::string > | SupportedInputFormat
std::vector< std::string > | SupportedOutputFormat
## Static Protected Attributes
static OBFormat * | pDefaultFormat
static int | FormatFilesLoaded = 0
## Option handling
Three types of Option provide information and control instructions to the conversion process, INOPTIONS, OUTOPTIONS, GENOPTIONS, and are stored in each OBConversion object in separate maps. Each option has an id and an optional text string. They are set individually by AddOption() or (rarely) collectively in SetOptions(). Options cannot be altered but can be replaced with AddOption() and deleted with RemoveOption(), which, however, should be used in an op derived from OBOp (because of iterator invalidation). If the "Convert" interface is used, the GENOPTIONS are acted upon in the OBBase::DoTransformations() functions (currently only OBMol has one). This happens after the object has been input but before it has been output. All the options are available to input and output formats, etc. via the IsOption() function, and the interpretation of any text string needs to be done subsequently. In the commandline interface, options with single character ids are are indicated like -s, and those with multiple character ids like --gen3D. An option may have one or more parameters which appear, space separated, in the option's text string. With babel, unless the option is at the end of the command, it is necessary for the number of its parameters to be exactly that specified in RegisterOptionParam(). The default is 0, but if it is more, and babel is likely to be used, this function should be called in the constructor of a format or op. With obabel (or the GUI), it is not necessary to call RegisterOptionParam(). New GENOPTIONS can be defined (as plugins) using the class OBOp. It is customary for a format or op to document any INOPTIONS or OUTPTIONS it uses in its Description() function. As well as providing documentation during use, this is also parsed by the GUI to construct its checkboxes,etc., so it is advisable to give new Descriptions the same form as existing ones. Some conversion options, such as -f, -l, -m, are unlikely to be used in programming, but are listed in OBConversion::Description(). The built-in GENOPTIONS for OBMol objects are listed in OBMol::ClassDescription() which is in transform.cpp and also in this documentation under AddOption().
enum | Option_type { INOPTIONS, OUTOPTIONS, GENOPTIONS, ALL }
const char * | IsOption (const char *opt, Option_type opttyp=OUTOPTIONS)
const std::map< std::string, std::string > * | GetOptions (Option_type opttyp)
void | AddOption (const char *opt, Option_type opttyp=OUTOPTIONS, const char *txt=NULL)
bool | RemoveOption (const char *opt, Option_type optype)
void | SetOptions (const char *options, Option_type opttyp)
static void | RegisterOptionParam (std::string name, OBFormat *pFormat, int numberParams=0, Option_type typ=OUTOPTIONS)
static int | GetOptionParams (std::string name, Option_type typ)
## Convenience functions
bool | Write (OBBase *pOb, std::ostream *pout=NULL)
std::string | WriteString (OBBase *pOb, bool trimWhitespace=false)
bool | WriteFile (OBBase *pOb, std::string filePath)
void | CloseOutFile ()
bool | Read (OBBase *pOb, std::istream *pin=NULL)
bool | ReadString (OBBase *pOb, std::string input)
bool | ReadFile (OBBase *pOb, std::string filePath)
bool | OpenInAndOutFiles (std::string infilepath, std::string outfilepath)
void | ReportNumberConverted (int count, OBFormat *pFormat=NULL)
int | NumInputObjects ()
static OBFormat * | GetDefaultFormat ()
static std::string | BatchFileName (std::string &BaseName, std::string &InFile)
static std::string | IncrementedFileName (std::string &BaseName, const int Count)
static bool | CheckForUnintendedBatch (const std::string &infile, const std::string &outfile)
void | InstallStreamFilter ()

## Detailed Description

A subclass for conversion of XML formats.

An extended OBConversion class which includes a libxml2 reader for use with XML formats. Copies an OBConversion and then extends it with a XML parser. Instances made on the heap are deleted when the original OBConversion object is.

This class is not intended to be used externally -- instead use OBConversion which will find both XML and non-XML OBFormats.

Instead, this subclass also has support for handling specific needs in XML formats. For example, an XML file may include multiple namespaces, and the conversion should call appropriate XMLBaseFormat formats as needed.

## Member Typedef Documentation

typedef std::map<std::string, XMLBaseFormat*> NsMapType

typedef std::map<std::string,int> OPAMapType`[protected, inherited]`

typedef FilteringInputStreambuf< LineEndingExtractor > LErdbuf`[protected, inherited]`

## Member Enumeration Documentation

enum Option_type`[inherited]`

Three types of options set on the the command line by -a? , -x? , or -?

Enumerator:

  INOPTIONS |
  OUTOPTIONS |
  GENOPTIONS |
  ALL |

## Constructor & Destructor Documentation

XMLConversion | ( | OBConversion * | pConv | ) |

Existing OBConversion instance copied.

~XMLConversion | ( |  | ) |

Frees reader and writer if necessary.

## Member Function Documentation

bool SetupReader | ( |  | ) |

opens libxml2 reader

bool SetupWriter | ( |  | ) |

opens libxml2 writer

bool ReadXML | ( | XMLBaseFormat * | pFormat,
|  | OBBase * | pOb
| ) |  |

Parses the input xml stream and sends each element to the format's callback routines.

Referenced by XMLMoleculeFormat::ReadMolecule().

int SkipXML | ( | const char * | ctag | ) |

Read and discard XML text up to the next occurrence of the tag e.g."/molecule>" This is left as the current node. Returns 1 on success, 0 if not found, -1 if failed.

Referenced by XMLBaseFormat::SkipObjects().

static NsMapType& Namespaces | ( |  | ) | `[inline, static]`

This static function returns a reference to the map Avoids "static initialization order fiasco"

static void RegisterXMLFormat | ( | XMLBaseFormat * | pFormat,
|  | bool | IsDefault = `false`,
|  | const char * | uri = `NULL`
| ) |  | `[static]`

static XMLConversion* GetDerived | ( | OBConversion * | pConv,
|  | bool | ForReading = `true`
| ) |  | `[static]`

Returns the extended OBConversion class, making it if necessary.

Referenced by XMLMoleculeFormat::ReadMolecule(), and XMLBaseFormat::SkipObjects().

bool IsLast | ( |  | ) | `[inline]`

Because OBConversion::Convert is still using the unextended OBConversion object we need to obtain the conversion paramters from it when requested

Reimplemented from OBConversion.

int GetOutputIndex | ( |  | ) | `[inline]`

xmlTextReaderPtr GetReader | ( |  | ) | const`[inline]`

Referenced by XMLBaseFormat::reader().

xmlTextWriterPtr GetWriter | ( |  | ) | const`[inline]`

Referenced by XMLBaseFormat::writer().

void OutputToStream | ( |  | ) | `[inline]`

Referenced by XMLBaseFormat::OutputToStream().

static XMLBaseFormat* GetDefaultXMLClass | ( |  | ) | `[inline, static]`

void LookForNamespace | ( |  | ) | `[inline]`

static int ReadStream | ( | void * | context,
|  | char * | buffer,
|  | int | len
| ) |  | `[static]`

Static callback functions for xmlReaderForIO()

static int WriteStream | ( | void * | context,
|  | const char * | buffer,
|  | int | len
| ) |  | `[static]`

std::string GetAttribute | ( | const char * | attrname | ) |

std::string GetContent | ( |  | ) |

Sets value to element content. Returns false if there is no content.

bool GetContentInt | ( | int & | value | ) |

Sets value to element content as an integer. Returns false if there is no content.

bool GetContentDouble | ( | double & | value | ) |

Sets value to element content as an double. Returns false if there is no content.

int RegisterFormat | ( | const char * | ID,
|  | OBFormat * | pFormat,
|  | const char * | MIME = `NULL`
| ) |  | `[static, inherited]`

Called once by each format class.

Class information on formats is collected by making an instance of the class derived from OBFormat(only one is usually required). RegisterFormat() is called from its constructor.

If the compiled format is stored separately, like in a DLL or shared library, the initialization code makes an instance of the imported OBFormat class.

OBFormat * FindFormat | ( | const char * | ID | ) | `[static, inherited]`

Searches registered formats.

Referenced by OBConversion::FormatFromExt(), OBConversion::SetInFormat(), and OBConversion::SetOutFormat().

OBFormat * FindFormat | ( | const std::string | ID | ) | `[static, inherited]`

Searches registered formats.

Since:
  version 2.3

OBFormat * FormatFromExt | ( | const char * | filename | ) | `[static, inherited]`

Searches registered formats for an ID the same as the file extension.

Examples:
  obconformersearch_default.cpp, and obforcefield_energy.cpp.

Referenced by OBConversion::FormatFromExt(), and OBConversion::OpenAndSetFormat().

OBFormat * FormatFromExt | ( | const std::string | filename | ) | `[static, inherited]`

Searches registered formats for an ID the same as the file extension.

Since:
  version 2.3

OBFormat * FormatFromMIME | ( | const char * | MIME | ) | `[static, inherited]`

Searches registered formats for a MIME the same as the chemical MIME type passed.

bool GetNextFormat | ( | Formatpos & | itr,
|  | const char *& | str,
|  | OBFormat *& | pFormat
| ) |  | `[static, inherited]`

Deprecated!.Repeatedly called to recover available Formats.

const char * Description | ( |  | ) | `[static, inherited]`

std::istream* GetInStream | ( |  | ) | const`[inline, inherited]`

Referenced by OBMoleculeFormat::DeferMolOutput(), OBConversion::NumInputObjects(), and OBMoleculeFormat::ReadChemObjectImpl().

std::ostream* GetOutStream | ( |  | ) | const`[inline, inherited]`

void SetInStream | ( | std::istream * | pIn | ) | `[inline, inherited]`

Referenced by OBConversion::FullConvert().

void SetOutStream | ( | std::ostream * | pOut | ) | `[inline, inherited]`

Referenced by OBConversion::FullConvert().

bool SetInAndOutFormats | ( | const char * | inID,
|  | const char * | outID
| ) |  | `[inherited]`

Sets the formats from their ids, e g CML.

Sets the formats from their ids, e g CML. If inID is NULL, the input format is left unchanged. Similarly for outID Returns true if both formats have been successfully set at sometime

bool SetInAndOutFormats | ( | OBFormat * | pIn,
|  | OBFormat * | pOut
| ) |  | `[inherited]`

bool SetInFormat | ( | const char * | inID | ) | `[inherited]`

Sets the input format from an id e.g. CML.

Examples:
  obconformersearch_default.cpp, obconversion_readstring.cpp, and obforcefield_energy.cpp.

Referenced by OpenBabel::CompileSmilesQuery(), OBConversion::OpenAndSetFormat(), OBMoleculeFormat::ReadNameIndex(), and OBConversion::SetInAndOutFormats().

bool SetInFormat | ( | OBFormat * | pIn | ) | `[inherited]`

bool SetOutFormat | ( | const char * | outID | ) | `[inherited]`

Sets the output format from an id e.g. CML.

Examples:
  obconformersearch_default.cpp.

Referenced by OBConversion::SetInAndOutFormats().

bool SetOutFormat | ( | OBFormat * | pOut | ) | `[inherited]`

OBFormat* GetInFormat | ( |  | ) | const`[inline, inherited]`

Referenced by OBConversion::NumInputObjects().

OBFormat* GetOutFormat | ( |  | ) | const`[inline, inherited]`

Referenced by OBMoleculeFormat::DoOutputOptions(), and OBMoleculeFormat::OutputDeferredMols().

std::string GetInFilename | ( |  | ) | const`[inline, inherited]`

std::streampos GetInPos | ( |  | ) | const`[inline, inherited]`

Get the position in the input stream of the object being read.

size_t GetInLen | ( |  | ) | const`[inline, inherited]`

Get the length in the input stream of the object being read.

const char * GetTitle | ( |  | ) | const`[inherited]`

Returns:
  a default title which is the filename

OBConversion* GetAuxConv | ( |  | ) | const`[inline, inherited]`

Extension method: deleted in ~OBConversion()

void SetAuxConv | ( | OBConversion * | pConv | ) | `[inline, inherited]`

const char * IsOption | ( | const char * | opt,
|  | Option_type | opttyp = `OUTOPTIONS`
| ) |  | `[inherited]`

Determine whether an option is set.

Returns:
  NULL if option not and a pointer to the associated text if it is

Referenced by OBConversion::Convert(), OBMoleculeFormat::DoOutputOptions(), OBConversion::FullConvert(), OBConversion::NumInputObjects(), OBMoleculeFormat::ReadChemObjectImpl(), OBConversion::SetStartAndEnd(), OBConversion::Write(), and OBMoleculeFormat::WriteChemObjectImpl().

const std::map<std::string,std::string>* GetOptions | ( | Option_type | opttyp | ) | `[inline, inherited]`

Access the map with option name as key and any associated text as value.

Referenced by OBMoleculeFormat::OutputDeferredMols(), and OBMoleculeFormat::ReadChemObjectImpl().

void AddOption | ( | const char * | opt,
|  | Option_type | opttyp = `OUTOPTIONS`,
|  | const char * | txt = `NULL`
| ) |  | `[inherited]`

Set an option of specified type, with optional text.

Referenced by OBMoleculeFormat::DeferMolOutput().

bool RemoveOption | ( | const char * | opt,
|  | Option_type | optype
| ) |  | `[inherited]`

void SetOptions | ( | const char * | options,
|  | Option_type | opttyp
| ) |  | `[inherited]`

Set several single character options of specified type from string like ab"btext"c"ctext".

void RegisterOptionParam | ( | std::string | name,
|  | OBFormat * | pFormat,
|  | int | numberParams = `0`,
|  | Option_type | typ = `OUTOPTIONS`
| ) |  | `[static, inherited]`

For example -h takes 0 parameters; -f takes 1. Call in a format constructor.

Referenced by OBConversion::OBConversion(), and OBMoleculeFormat::OBMoleculeFormat().

int GetOptionParams | ( | std::string | name,
|  | Option_type | typ
| ) |  | `[static, inherited]`

Returns:
  the number of parameters registered for the option, or 0 if not found

void CopyOptions | ( | OBConversion * | pSourceConv,
|  | Option_type | typ = `ALL`
| ) |  | `[inherited]`

Copies the options (by default of all types) from one OBConversion Object to another.

std::vector< std::string > GetSupportedInputFormat | ( |  | ) | `[inherited]`

Returns the list of supported input format

std::vector< std::string > GetSupportedOutputFormat | ( |  | ) | `[inherited]`

Returns the list of supported output format

int Convert | ( | std::istream * | is,
|  | std::ostream * | os
| ) |  | `[inherited]`

Conversion for single input and output stream.

int Convert | ( |  | ) | `[inherited]`

Conversion with existing streams.

Actions the "convert" interface. Calls the OBFormat class's ReadMolecule() which

- makes a new chemical object of its chosen type (e.g. OBMol)
- reads an object from the input file
- subjects the chemical object to 'transformations' as specified by the Options
- calls AddChemObject to add it to a buffer. The previous object is first output via the output Format's WriteMolecule(). During the output process calling IsFirst() and GetIndex() (the number of objects including the current one already output. allows more control, for instance writing <cml> and </cml> tags for multiple molecule outputs only.

AddChemObject does not save the object passed to it if it is NULL (as a result of a DoTransformation()) or if the number of the object is outside the range defined by StartNumber and EndNumber.This means the start and end counts apply to all chemical objects found whether or not they are output.

If ReadMolecule returns false the input conversion loop is exited.

Referenced by OBConversion::Convert(), and OBConversion::FullConvert().

int FullConvert | ( | std::vector< std::string > & | FileList,
|  | std::string & | OutputFileName,
|  | std::vector< std::string > & | OutputFileList
| ) |  | `[inherited]`

Conversion with multiple input/output files: makes input and output streams, and carries out normal, batch, aggregation, and splitting conversion.

Makes input and output streams, and carries out normal, batch, aggregation, and splitting conversion.

Normal Done if FileList contains a single file name and OutputFileName does not contain a *.

Aggregation Done if FileList has more than one file name and OutputFileName does not contain * . All the chemical objects are converted and sent to the single output file.

Splitting Done if FileList contains a single file name and OutputFileName contains a * . Each chemical object in the input file is converted and sent to a separate file whose name is OutputFileName with the replaced by 1, 2, 3, etc. OutputFileName must have at least one character other than the * before the extension. For example, if OutputFileName is NEW*.smi then the output files are NEW1.smi, NEW2.smi, etc.

Batch Conversion Done if FileList has more than one file name and contains a * . Each input file is converted to an output file whose name is OutputFileName with the * replaced by the inputfile name without its path and extension. So if the input files were inpath/First.cml, inpath/Second.cml and OutputFileName was NEW*.mol, the output files would be NEWFirst.mol, NEWSecond.mol.

If FileList is empty, the input stream that has already been set (usually in the constructor) is used. If OutputFileName is empty, the output stream already set is used.

On exit, OutputFileList contains the names of the output files.

Returns the number of Chemical objects converted.

int AddChemObject | ( | OBBase * | pOb | ) | `[inherited]`

Adds to internal array during input.

Called by ReadMolecule() to deliver an object it has read from an input stream. Used in two modes:

- When Count is negative it is left negative and the routine is just a store for an OBBase object. The negative value returned tells the calling routine that no more objects are required.
- When count is >=0, probably set by Convert(), it acts as a queue of 2: writing the currently stored value before accepting the supplied one. This delay allows output routines to respond differently when the written object is the last. Count is incremented with each call, even if pOb=NULL. Objects are not added to the queue if the count is outside the range StartNumber to EndNumber. There is no upper limit if EndNumber is zero. The return value is Count ((>0) or 0 if WriteChemObject returned false.

Referenced by OBMoleculeFormat::ReadChemObjectImpl().

OBBase * GetChemObject | ( |  | ) | `[inherited]`

Retrieve from internal array during output.

Retrieves an object stored by AddChemObject() during output

Referenced by OBMoleculeFormat::WriteChemObjectImpl().

bool IsFirstInput | ( |  | ) | `[inherited]`

True if the first input object is being processed.

Referenced by OBMoleculeFormat::DeferMolOutput(), and OBMoleculeFormat::ReadChemObjectImpl().

void SetFirstInput | ( | bool | b = `true` | ) | `[inherited]`

Setwhether or not is the first input.

Referenced by OBConversion::Convert(), and OBConversion::FullConvert().

int GetOutputIndex | ( |  | ) | const`[inherited]`

Retrieves number of ChemObjects that have been actually output.

Returns the number of objects which have been output or are currently being output. The outputindex is incremented when an object for output is fetched by GetChemObject(). So the function will return 1 if called from WriteMolecule() during output of the first object.

Referenced by OBMoleculeFormat::DoOutputOptions(), and XMLConversion::GetOutputIndex().

void SetOutputIndex | ( | int | indx | ) | `[inherited]`

Sets ouput index (maybe to control whether seen as first object)

Referenced by OBConversion::FullConvert(), OBMoleculeFormat::OutputDeferredMols(), and OBMoleculeFormat::WriteChemObjectImpl().

void SetMoreFilesToCome | ( |  | ) | `[inherited]`

Used with multiple input files. Off by default.

Referenced by OBConversion::FullConvert().

void SetOneObjectOnly | ( | bool | b = `true` | ) | `[inherited]`

Used with multiple input files. Off by default.

Referenced by OBConversion::FullConvert(), OBMoleculeFormat::OutputDeferredMols(), and OBConversion::Write().

void SetLast | ( | bool | b | ) | `[inline, inherited]`

Synonym for SetOneObjectOnly()

bool IsLastFile | ( |  | ) | `[inline, inherited]`

True if no more files to be read.

int GetCount | ( |  | ) | const`[inline, inherited]`

Number of objects read and processed Incremented after options are processed, so 0 for first object. Returns -1 if Convert interface not used.

static OBFormat* GetDefaultFormat | ( |  | ) | `[inline, static, inherited]`

The default format is set in a single OBFormat class (generally it is OBMol)

bool Write | ( | OBBase * | pOb,
|  | std::ostream * | pout = `NULL`
| ) |  | `[inherited]`

Outputs an object of a class derived from OBBase.

Part of "API" interface. The output stream can be specified and the change is retained in the OBConversion instance

Writes the object pOb but does not delete it afterwards. The output stream is lastingly changed if pos is not NULL Returns true if successful.

Examples:
  obconformersearch_default.cpp.

Referenced by OBConversion::WriteFile(), and OBConversion::WriteString().

std::string WriteString | ( | OBBase * | pOb,
|  | bool | trimWhitespace = `false`
| ) |  | `[inherited]`

Outputs an object of a class derived from OBBase as a string.

Part of "API" interface. The output stream is temporarily changed to the string and then restored This method is primarily intended for scripting languages without "stream" classes The optional "trimWhitespace" parameter allows trailing whitespace to be removed (e.g., in a SMILES string or InChI, etc.)

Writes the object pOb but does not delete it afterwards. The output stream not changed (since we cannot write to this string later) Returns true if successful.

bool WriteFile | ( | OBBase * | pOb,
|  | std::string | filePath
| ) |  | `[inherited]`

Outputs an object of a class derived from OBBase as a file (with the supplied path)

Part of "API" interface. The output stream is changed to the supplied file and the change is retained in the OBConversion instance. This method is primarily intended for scripting languages without "stream" classes

Writes the object pOb but does not delete it afterwards. The output stream is lastingly changed to point to the file Returns true if successful.

void CloseOutFile | ( |  | ) | `[inherited]`

Manually closes and deletes the output stream The file is closed anyway when in the OBConversion destructor or when WriteFile is called again.

Since:
  version 2.1

bool Read | ( | OBBase * | pOb,
|  | std::istream * | pin = `NULL`
| ) |  | `[inherited]`

Reads an object of a class derived from OBBase into pOb.

Part of "API" interface. The input stream can be specified and the change is retained in the OBConversion instance

Returns:
  false and pOb=NULL on error

Examples:
  obconformersearch_default.cpp, and obforcefield_energy.cpp.

Referenced by OBConversion::ReadFile(), OBMoleculeFormat::ReadNameIndex(), and OBConversion::ReadString().

bool ReadString | ( | OBBase * | pOb,
|  | std::string | input
| ) |  | `[inherited]`

Reads an object of a class derived from OBBase into pOb from the supplied string.

Part of "API" interface. The input stream can be specified and the change is retained in the OBConversion instance

Returns:
  NULL on error Part of "API" interface.
  false and pOb=NULL on error This method is primarily intended for scripting languages without "stream" classes

Examples:
  obconversion_readstring.cpp.

Referenced by OpenBabel::CompileSmilesQuery().

bool ReadFile | ( | OBBase * | pOb,
|  | std::string | filePath
| ) |  | `[inherited]`

Reads an object of a class derived from OBBase into pOb from the file specified.

Part of "API" interface. The output stream is changed to the supplied file and the change is retained in the OBConversion instance. For multi-molecule files, the remaining molecules can be read by repeatedly calling the Read() method.

Returns:
  false and pOb=NULL on error This method is primarily intended for scripting languages without "stream" classes

bool OpenInAndOutFiles | ( | std::string | infilepath,
|  | std::string | outfilepath
| ) |  | `[inherited]`

Part of the "Convert" interface. Open the files and update the streams in the OBConversion object. This method is primarily intended for scripting languages without "stream" classes and will usually followed by a call to Convert().

Returns:
  false if unsucessful.

void ReportNumberConverted | ( | int | count,
|  | OBFormat * | pFormat = `NULL`
| ) |  | `[inherited]`

Sends a message like "2 molecules converted" to clog The type of object is taken from the TargetClassDescription of the specified class (or the output format if not specified)and is appropriately singular or plural.

int NumInputObjects | ( |  | ) | `[inherited]`

Returns:
  the number of objects in the inputstream, or -1 if error or if SkipObjects for the input format is not implemented Adjusts for the value of -f and -l options (first and last objects).

string BatchFileName | ( | std::string & | BaseName,
|  | std::string & | InFile
| ) |  | `[static, protected, inherited]`

Replaces * in BaseName by InFile without extension and path.

Referenced by OBConversion::FullConvert().

string IncrementedFileName | ( | std::string & | BaseName,
|  | const int | Count
| ) |  | `[static, protected, inherited]`

Replaces * in BaseName by Count.

Referenced by OBConversion::FullConvert().

bool CheckForUnintendedBatch | ( | const std::string & | infile,
|  | const std::string & | outfile
| ) |  | `[static, protected, inherited]`

Checks for misunderstandings when using the -m option.

Referenced by OBConversion::FullConvert().

void InstallStreamFilter | ( |  | ) | `[protected, inherited]`

Adds a filtering rdbuffer to handle line endings if not already installed and not a binary or xml format.

Referenced by OBConversion::Convert(), and OBConversion::Read().

bool SetStartAndEnd | ( |  | ) | `[protected, inherited]`

Referenced by OBConversion::Convert().

OBConversion::OPAMapType & OptionParamArray | ( | Option_type | typ | ) | `[static, protected, inherited]`

Referenced by OBConversion::GetOptionParams(), and OBConversion::RegisterOptionParam().

int LoadFormatFiles | ( |  | ) | `[static, protected, inherited]`

Referenced by OBConversion::OBConversion().

bool OpenAndSetFormat | ( | bool | SetFormat,
|  | std::ifstream * | is,
|  | std::stringstream * | ss = `NULL`
| ) |  | `[protected, inherited]`

Referenced by OBConversion::FullConvert().

## Member Data Documentation

bool _SkipNextRead

std::string InFilename`[protected, inherited]`

Referenced by OBConversion::FullConvert(), OBConversion::GetTitle(), OBConversion::OBConversion(), OBConversion::OpenAndSetFormat(), OBConversion::OpenInAndOutFiles(), and OBConversion::ReadFile().

std::istream* pInStream`[protected, inherited]`

Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), OBConversion::InstallStreamFilter(), OBConversion::OBConversion(), OBConversion::OpenInAndOutFiles(), OBConversion::Read(), OBConversion::ReadFile(), OBConversion::ReadString(), and OBConversion::~OBConversion().

std::ostream* pOutStream`[protected, inherited]`

Referenced by OBConversion::CloseOutFile(), OBConversion::Convert(), OBConversion::OBConversion(), OBConversion::OpenInAndOutFiles(), OBConversion::Write(), OBConversion::WriteFile(), OBConversion::WriteString(), and OBConversion::~OBConversion().

OBFormat* pDefaultFormat`[static, protected, inherited]`

OBFormat* pInFormat`[protected, inherited]`

Referenced by OBConversion::Convert(), OBConversion::FullConvert(), OBConversion::InstallStreamFilter(), OBConversion::OBConversion(), OBConversion::OpenAndSetFormat(), OBConversion::Read(), OBConversion::ReadFile(), OBConversion::SetInFormat(), and OBConversion::SetStartAndEnd().

OBFormat* pOutFormat`[protected, inherited]`

Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), OBConversion::FullConvert(), OBConversion::OBConversion(), OBConversion::ReportNumberConverted(), OBConversion::SetOutFormat(), OBConversion::Write(), OBConversion::WriteFile(), and OBConversion::WriteString().

std::map<std::string,std::string> OptionsArray[3]`[protected, inherited]`

Referenced by OBConversion::AddOption(), OBConversion::CopyOptions(), OBConversion::IsOption(), OBConversion::OBConversion(), OBConversion::RemoveOption(), and OBConversion::SetOptions().

int Index`[protected, inherited]`

Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), OBConversion::GetChemObject(), OBConversion::GetOutputIndex(), OBConversion::OBConversion(), and OBConversion::SetOutputIndex().

unsigned int StartNumber`[protected, inherited]`

Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), OBConversion::OBConversion(), and OBConversion::SetStartAndEnd().

unsigned int EndNumber`[protected, inherited]`

Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), OBConversion::OBConversion(), and OBConversion::SetStartAndEnd().

int Count`[protected, inherited]`

Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), OBConversion::FullConvert(), OBConversion::OBConversion(), and OBConversion::SetStartAndEnd().

bool m_IsFirstInput`[protected, inherited]`

Referenced by OBConversion::IsFirstInput(), OBConversion::OBConversion(), and OBConversion::SetFirstInput().

bool m_IsLast`[protected, inherited]`

Referenced by OBConversion::Convert(), OBConversion::IsLast(), OBConversion::OBConversion(), and OBConversion::SetOneObjectOnly().

bool MoreFilesToCome`[protected, inherited]`

Referenced by OBConversion::Convert(), OBConversion::OBConversion(), and OBConversion::SetMoreFilesToCome().

bool OneObjectOnly`[protected, inherited]`

Referenced by OBConversion::Convert(), OBConversion::OBConversion(), and OBConversion::SetOneObjectOnly().

bool ReadyToInput`[protected, inherited]`

Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), and OBConversion::OBConversion().

bool CheckedForGzip`[protected, inherited]`

input stream is gzip-encoded

Referenced by OBConversion::Convert(), OBConversion::FullConvert(), OBConversion::OBConversion(), and OBConversion::Read().

bool NeedToFreeInStream`[protected, inherited]`

Referenced by OBConversion::OBConversion(), OBConversion::OpenInAndOutFiles(), OBConversion::Read(), OBConversion::ReadFile(), OBConversion::ReadString(), and OBConversion::~OBConversion().

bool NeedToFreeOutStream`[protected, inherited]`

Referenced by OBConversion::CloseOutFile(), OBConversion::OBConversion(), OBConversion::OpenInAndOutFiles(), OBConversion::WriteFile(), and OBConversion::~OBConversion().

LErdbuf* pLineEndBuf`[protected, inherited]`

Referenced by OBConversion::InstallStreamFilter(), and OBConversion::OBConversion().

int FormatFilesLoaded = 0`[static, protected, inherited]`

Referenced by OBConversion::OBConversion().

OBBase* pOb1`[protected, inherited]`

Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), OBConversion::GetChemObject(), and OBConversion::OBConversion().

std::streampos wInpos`[protected, inherited]`

position in the input stream of the object being written

Referenced by OBConversion::AddChemObject(), and OBConversion::OBConversion().

std::streampos rInpos`[protected, inherited]`

position in the input stream of the object being read

Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), and OBConversion::OBConversion().

size_t wInlen`[protected, inherited]`

length in the input stream of the object being written

Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), and OBConversion::OBConversion().

size_t rInlen`[protected, inherited]`

length in the input stream of the object being read

Referenced by OBConversion::AddChemObject(), and OBConversion::OBConversion().

OBConversion* pAuxConv`[protected, inherited]`

Way to extend OBConversion.

Referenced by OBConversion::OBConversion(), and OBConversion::~OBConversion().

std::vector<std::string> SupportedInputFormat`[protected, inherited]`

list of supported input format

std::vector<std::string> SupportedOutputFormat`[protected, inherited]`

list of supported output format

The documentation for this class was generated from the following file:

- xml.h

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines