25 #include <libxml/xmlreader.h> 26 #include <libxml/xmlwriter.h> 72 typedef std::map<std::string, XMLBaseFormat*>
NsMapType;
88 bool IsDefault=
false,
const char* uri=NULL);
96 {
return _pConv->
IsLast(); }
109 xmlOutputBufferFlush(_buf);
113 {
return _pDefault;};
116 { _LookingForNamespace =
true; };
119 static int ReadStream(
void * context,
char * buffer,
int len);
120 static int WriteStream(
void * context,
const char * buffer,
int len);
137 std::streampos _requestedpos, _lastpos;
138 xmlTextReaderPtr _reader;
139 xmlTextWriterPtr _writer;
140 xmlOutputBufferPtr _buf;
142 bool _LookingForNamespace;
163 virtual const char* NamespaceURI()
const=0;
164 virtual bool DoElement(
const std::string& ElName){
return false;};
165 virtual bool EndElement(
const std::string& ElName){
return false;};
167 virtual const char*
EndTag(){
return ">";};
204 if(_pxmlConv->
SkipXML(EndTag())!=1)
234 _pmol =
dynamic_cast<OBMol*
>(pOb);
241 return _pxmlConv->ReadXML(
this,pOb);
246 return typeid(
OBMol*);
void OutputToStream()
Definition: xml.h:107
bool ReadXML(XMLBaseFormat *pFormat, OBBase *pOb)
Parses the input xml stream and sends each element to the format's callback routines.
Class to convert from one format to another.
Definition: obconversion.h:59
int SkipXML(const char *ctag)
static XMLConversion * GetDerived(OBConversion *pConv, bool ForReading=true)
Returns the extended OBConversion class, making it if necessary.
bool IsLast()
Definition: xml.h:95
bool _SkipNextRead
Definition: xml.h:144
static int ReadStream(void *context, char *buffer, int len)
Static callback functions for xmlReaderForIO()
void LookForNamespace()
Definition: xml.h:115
bool SetupWriter()
opens libxml2 writer
static int WriteStream(void *context, const char *buffer, int len)
Molecule Class.
Definition: mol.h:118
Handle molecules. Declarations of OBMol, OBAtom, OBBond, OBResidue. (the main header for Open Babel) ...
A subclass for conversion of XML formats.
Definition: xml.h:53
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. ...
static NsMapType & Namespaces()
Definition: xml.h:76
int GetOutputIndex()
Definition: xml.h:97
Handle file conversions. Declaration of OBFormat, OBConversion.
std::map< std::string, XMLBaseFormat * > NsMapType
Definition: xml.h:72
bool SetupReader()
opens libxml2 reader
XMLConversion(OBConversion *pConv)
Existing OBConversion instance copied.
xmlTextReaderPtr GetReader() const
Definition: xml.h:101
int GetOutputIndex() const
Retrieves number of ChemObjects that have been actually output.
Definition: obconversion.cpp:738
xmlTextWriterPtr GetWriter() const
Definition: xml.h:104
~XMLConversion()
Frees reader and writer if necessary.
bool IsLast()
True if no more objects to be output.
Definition: obconversion.cpp:1143
std::string GetContent()
Sets value to element content. Returns false if there is no content.
static XMLBaseFormat * GetDefaultXMLClass()
Definition: xml.h:112
Base Class.
Definition: base.h:239
std::string GetAttribute(const char *attrname)
static void RegisterXMLFormat(XMLBaseFormat *pFormat, bool IsDefault=false, const char *uri=NULL)
Global namespace for all Open Babel code.
Definition: alias.h:22