Loading...
Searching...
No Matches
obconversion_readstring.cpp

Reading a smiles string.

#include <openbabel/obconversion.h>
#include <openbabel/mol.h>
using namespace OpenBabel;
int main()
{
// Create an OBConversion object.
OBConversion conv;
// Set the input format.
if (!conv.SetInFormat("smi")) {
// Handle error.
return 1;
}
// Create the OBMol object.
OBMol mol;
// Read the smiles string.
if (conv.ReadString(&mol, "CCCC")) {
// Handle error.
return 1;
}
// ...Use OBMol object...
}
OpenBabel::OBConversion
Class to convert from one format to another.
Definition obconversion.h:60
OpenBabel::OBConversion::ReadString
bool ReadString(OBBase *pOb, std::string input)
Reads an object of a class derived from OBBase into pOb from the supplied string.
Definition obconversion.cpp:1074
OpenBabel::OBConversion::SetInFormat
bool SetInFormat(const char *inID, bool isgzip=false)
Sets the input format from an id e.g. CML.
Definition obconversion.cpp:440
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
mol.h
Handle molecules. Declarations of OBMol, OBAtom, OBBond, OBResidue. (the main header for Open Babel).
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23
obconversion.h
Handle file conversions. Declaration of OBFormat, OBConversion.