XMLBaseFormat Class Reference

Abstract class containing common functionality for XML formats. More...

#include <openbabel/xml.h>

Inheritance diagram for XMLBaseFormat:

List of all members.

Public Types

typedef std::map< const char
*, OBPlugin *, CharPtrLess

Public Member Functions

 ~XMLBaseFormat ()
virtual const char * NamespaceURI () const =0
virtual bool DoElement (const std::string &ElName)
virtual bool EndElement (const std::string &ElName)
virtual const char * EndTag ()
const char * TypeID ()
virtual bool ReadMolecule (OBBase *, OBConversion *)
virtual bool ReadChemObject (OBConversion *)
virtual bool WriteMolecule (OBBase *, OBConversion *)
virtual bool WriteChemObject (OBConversion *)
virtual const char * Description ()=0
virtual const char * TargetClassDescription ()
virtual const std::type_info & GetType ()
virtual const char * SpecificationURL ()
const char * GetMIMEType ()
virtual unsigned int Flags ()
virtual OBFormatMakeNewInstance ()
int RegisterFormat (const char *ID, const char *MIME=NULL)
virtual bool Display (std::string &txt, const char *param, const char *ID=NULL)
virtual OBPluginMakeInstance (const std::vector< std::string > &)
const char * GetID () const
virtual PluginMapTypeGetMap () const =0

Static Public Member Functions

static OBFormatFormatFromMIME (const char *MIME)
static OBPluginGetPlugin (const char *Type, const char *ID)
static bool ListAsVector (const char *PluginID, const char *param, std::vector< std::string > &vlist)
static void List (const char *PluginID, const char *param=NULL, std::ostream *os=&std::cout)
static std::string ListAsString (const char *PluginID, const char *param=NULL)
static std::string FirstLine (const char *txt)
static PluginIterator Begin (const char *PluginID)
static PluginIterator End (const char *PluginID)

Protected Member Functions

xmlTextReaderPtr reader () const
xmlTextWriterPtr writer () const
void OutputToStream ()
virtual int SkipObjects (int n, OBConversion *pConv)

Static Protected Member Functions

static PluginMapTypePluginMap ()
static PluginMapTypeGetTypeMap (const char *PluginID)
static OBPluginBaseFindType (PluginMapType &Map, const char *ID)

Protected Attributes

std::string _prefix
int baseindent
int ind
std::string nsdecl
int _embedlevel
const char * _id

Detailed Description

Abstract class containing common functionality for XML formats.

Member Typedef Documentation

typedef std::map<const char*, OBPlugin*, CharPtrLess> PluginMapType [inherited]

typedef PluginMapType::const_iterator PluginIterator [inherited]

Constructor & Destructor Documentation

~XMLBaseFormat (  )  [inline]

Member Function Documentation

virtual const char* NamespaceURI (  )  const [pure virtual]

virtual bool DoElement ( const std::string &  ElName  )  [inline, virtual]

virtual bool EndElement ( const std::string &  ElName  )  [inline, virtual]

virtual const char* EndTag (  )  [inline, virtual]

The tag at the end of the chemical object e.g. "/molecule>".

Referenced by XMLBaseFormat::SkipObjects().

xmlTextReaderPtr reader (  )  const [inline, protected]

xmlTextWriterPtr writer (  )  const [inline, protected]

void OutputToStream (  )  [inline, protected]

virtual int SkipObjects ( int  n,
OBConversion pConv 
) [inline, protected, virtual]

Skip past first n objects in input stream (or current one with n=0) Returns 1 on success, -1 on error and 0 if not implemented

Reimplemented from OBFormat.

const char* TypeID (  )  [inline, inherited]

virtual bool ReadMolecule ( OBBase ,
) [inline, virtual, inherited]

The "API" interface Read function.

Reads a single object. Does not make a new object on the heap; can be used with a pointer to an chem object on the heap or the stack.

Reimplemented in XMLMoleculeFormat.

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

virtual bool ReadChemObject ( OBConversion  )  [inline, virtual, inherited]

The "Convert" interface Read function.

Possibly reads multiple new objects on the heap and subjects them to its DoTransformations() function, which may delete them again. Sends result to pConv->AddChemObject()

Reimplemented in OBMoleculeFormat, and XMLMoleculeFormat.

Referenced by OBConversion::Convert().

virtual bool WriteMolecule ( OBBase ,
) [inline, virtual, inherited]

The "API" interface Write function.

Writes a single object Does not delete the object; can be used with a pointer to an chem object on the heap or the stack.

false on error.

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

virtual bool WriteChemObject ( OBConversion  )  [inline, virtual, inherited]

The "Convert" interface Write function.

Writes a single object Deletes the object after writing

false on error

Reimplemented in OBMoleculeFormat, and XMLMoleculeFormat.

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

virtual const char* Description (  )  [pure virtual, inherited]

Information on this format. Printed out in response to -Hxxx option where xxx id the id of the format.

Must be provided by each format class. Can include a list of command line Options. These may be used to construction check boxes, radio buttons etc for GUI interface.

Reimplemented from OBPlugin.

Referenced by OBFormat::Display(), OBConversion::GetNextFormat(), OBMoleculeFormat::OutputDeferredMols(), OBMoleculeFormat::ReadChemObjectImpl(), OBConversion::RegisterOptionParam(), and OBMoleculeFormat::WriteChemObjectImpl().

const char * TargetClassDescription (  )  [virtual, inherited]

A decription of the chemical object converted by this format.

If not provided, the object type used by the default format is used (usually OBMol).

Referenced by OBConversion::ReportNumberConverted().

const type_info & GetType (  )  [virtual, inherited]

the type of chemical object used by the format. Defaults to that used by the default format. Useful for checking that a format can handle a particular object.

Reimplemented in OBMoleculeFormat, and XMLMoleculeFormat.

virtual const char* SpecificationURL (  )  [inline, virtual, inherited]

Web address where the format is defined.

Referenced by OBFormat::Display().

const char* GetMIMEType (  )  [inline, inherited]

Chemical MIME type associated with this file type (if any).

virtual unsigned int Flags (  )  [inline, virtual, inherited]

Decribes the capabilities of the format (Read only etc.).


Referenced by OBConversion::AddChemObject(), OBConversion::Convert(), OBFormat::Display(), OBConversion::FullConvert(), OBConversion::GetNextFormat(), OBConversion::InstallStreamFilter(), OBConversion::OpenAndSetFormat(), OBMoleculeFormat::ReadChemObjectImpl(), OBConversion::ReadFile(), OBFormat::RegisterFormat(), OBConversion::SetInFormat(), OBConversion::SetOutFormat(), and OBConversion::WriteFile().

virtual OBFormat* MakeNewInstance (  )  [inline, virtual, inherited]

a pointer to a new instance of the format, or NULL if fails. Normally a single global instance is used but this may cause problems if there are member variables and the format is used in more than one place in the program.

int RegisterFormat ( const char *  ID,
const char *  MIME = NULL 
) [inherited]

bool Display ( std::string &  txt,
const char *  param,
const char *  ID = NULL 
) [virtual, inherited]

Provides a description in txt of the format specified by itr. If param starts with "in", read", "out" or "write" only the appropriate formats are output. The others return false. If param contains "verbose", the whole description is output.

Reimplemented from OBPlugin.

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

virtual OBPlugin* MakeInstance ( const std::vector< std::string > &   )  [inline, virtual, inherited]

Make a new instance of the class. See OpTransform, OBGroupContrib, SmartsDescriptor classes for derived versions. Usually, the first parameter is the classname, the next three are parameters(ID, filename, description) for a constructor, and the rest data.

Reimplemented in OBGroupContrib, and OpTransform.

Referenced by OBConversion::LoadFormatFiles().

static OBPlugin* GetPlugin ( const char *  Type,
const char *  ID 
) [inline, static, inherited]

Get a pointer to a plugin from its type and ID. Return NULL if not found. Not cast to Type*.

Referenced by OBConversion::LoadFormatFiles().

const char* GetID (  )  const [inline, inherited]

Return the ID of the sub-type instance.

Referenced by OBPlugin::Display(), OBFormat::Display(), and OBDescriptor::PredictAndSave().

bool ListAsVector ( const char *  PluginID,
const char *  param,
std::vector< std::string > &  vlist 
) [static, inherited]

Output a list of sub-type classes of the the type PluginID, or, if PluginID is "plugins" or empty, a list of the base types. If PluginID is not recognized or is NULL, the base types are output and the return is false.

Referenced by OBConversion::GetSupportedInputFormat(), OBConversion::GetSupportedOutputFormat(), and OBPlugin::List().

void List ( const char *  PluginID,
const char *  param = NULL,
std::ostream *  os = &std::cout 
) [static, inherited]

As ListAsVector but sent to an ostream with a default of cout if not specified.

Referenced by OBPlugin::ListAsString().

string ListAsString ( const char *  PluginID,
const char *  param = NULL 
) [static, inherited]

As ListAsVector but returns a string containing the list.

string FirstLine ( const char *  txt  )  [static, inherited]

Utility function to return only the first line of a string.

Referenced by OBPlugin::Display(), OBFormat::Display(), and OBOp::OpOptions().

static PluginIterator Begin ( const char *  PluginID  )  [inline, static, inherited]

Return an iterator at the start of the map of the plugin types PluginID or, if there is no such map, the end of the top level plugin map.

Referenced by OBConversion::GetNextFormat(), and OBOp::OpOptions().

static PluginIterator End ( const char *  PluginID  )  [inline, static, inherited]

virtual PluginMapType& GetMap (  )  const [pure virtual, inherited]

Returns the map of the subtypes.

Referenced by OBFormat::RegisterFormat().

static PluginMapType& PluginMap (  )  [inline, static, protected, inherited]

Returns a reference to the map of the plugin types. Is a function rather than a static member variable to avoid initialization problems.

Referenced by OBPlugin::GetTypeMap(), OBPlugin::ListAsVector(), and OBFormat::RegisterFormat().

OBPlugin::PluginMapType & GetTypeMap ( const char *  PluginID  )  [static, protected, inherited]

Returns the map of a particular plugin type, e.g. GetMapType("fingerprints").

static OBPlugin* BaseFindType ( PluginMapType Map,
const char *  ID 
) [inline, static, protected, inherited]

Returns the type with the specified ID, or NULL if not found. Will be cast to the appropriate class in the calling routine.

Member Data Documentation

std::string _prefix [protected]

int baseindent [protected]

int ind [protected]

std::string nsdecl [protected]

int _embedlevel [protected]

const char* _id [protected, inherited]

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