Chemical Data Processing Library C++ API - Version 1.1.1
INCHIMolecularGraphWriter.hpp
Go to the documentation of this file.
1 /*
2  * INCHIMolecularGraphWriter.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_CHEM_INCHIMOLECULARGRAPHWRITER_HPP
30 #define CDPL_CHEM_INCHIMOLECULARGRAPHWRITER_HPP
31 
32 #include <vector>
33 #include <string>
34 #include <cstddef>
35 #include <iosfwd>
36 
37 #include "CDPL/Chem/APIPrefix.hpp"
38 #include "CDPL/Base/DataWriter.hpp"
39 
40 
41 typedef struct tagInchiAtom inchi_Atom;
42 typedef struct tagINCHIStereo0D inchi_Stereo0D;
43 
44 
45 namespace CDPL
46 {
47 
48  namespace Chem
49  {
50 
51  class MolecularGraph;
52  class Atom;
53 
161  {
162 
163  public:
169  INCHIMolecularGraphWriter(std::ostream& os);
170 
175 
182 
190  int getReturnCode() const;
191 
196  const std::string& getMessage() const;
197 
202  const std::string& getLogOutput() const;
203 
204  operator const void*() const;
205  bool operator!() const;
206 
207  private:
209 
211 
212  void writeMolGraph(const MolecularGraph&);
213 
214  void setupAtomTable(const MolecularGraph&, std::size_t);
215 
216  std::size_t getCoordsDimension(const MolecularGraph&) const;
217 
218  void setBondingInfo(const MolecularGraph&, const Atom&, inchi_Atom&, std::size_t) const;
219  void setElementSymbol(const Atom&, inchi_Atom&) const;
220  void setIsotope(const Atom&, inchi_Atom&) const;
221  void setFormalCharge(const Atom&, inchi_Atom&) const;
222  void setCoordinates(const Atom&, inchi_Atom&, std::size_t) const;
223  void setRadicalType(const Atom&, inchi_Atom&) const;
224  void setImplicitHCounts(inchi_Atom&) const;
225 
226  void setup0DStereoInfo(const MolecularGraph&);
227 
228  void setup0DAtomStereoInfo(const MolecularGraph&);
229  void setup0DBondStereoInfo(const MolecularGraph&);
230 
231  typedef std::vector<inchi_Atom> InChIAtomTable;
232  typedef std::vector<inchi_Stereo0D> InChIStereoInfoList;
233  typedef std::vector<char> StringData;
234 
235  std::ostream& output;
236  InChIAtomTable inchiAtomTable;
237  InChIStereoInfoList inchiStereoInfo;
238  StringData inchiOptions;
239  bool strictErrorChecking;
240  int returnCode;
241  std::string message;
242  std::string logOutput;
243  bool state;
244  };
245  } // namespace Chem
246 } // namespace CDPL
247 
248 #endif // CDPL_CHEM_INCHIMOLECULARGRAPHWRITER_HPP
CDPL::Chem::INCHIMolecularGraphWriter::getReturnCode
int getReturnCode() const
Returns the error code of the last write operation.
CDPL::Chem::setFormalCharge
CDPL_CHEM_API void setFormalCharge(Atom &atom, long charge)
CDPL::Chem::INCHIMolecularGraphWriter
A writer for molecular graph data in the IUPAC International Chemical Identifier (InChI) [INCHI] form...
Definition: INCHIMolecularGraphWriter.hpp:161
DataWriter.hpp
Definition of the class CDPL::Base::DataWriter.
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CHEM_API.
CDPL::Chem::INCHIMolecularGraphWriter::getLogOutput
const std::string & getLogOutput() const
Returns the log output that was generated for the last write operation.
CDPL_CHEM_API
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
inchi_Stereo0D
struct tagINCHIStereo0D inchi_Stereo0D
Definition: INCHIMolecularGraphWriter.hpp:42
CDPL::Chem::INCHIMolecularGraphWriter::write
Base::DataWriter< MolecularGraph > & write(const MolecularGraph &molgraph)
Writes data of the molecular graph molgraph to the output stream specified in the constructor.
CDPL::Chem::setRadicalType
CDPL_CHEM_API void setRadicalType(Atom &atom, unsigned int type)
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
inchi_Atom
struct tagInchiAtom inchi_Atom
Definition: INCHIMolecularGraphWriter.hpp:41
CDPL::Chem::INCHIMolecularGraphWriter::~INCHIMolecularGraphWriter
~INCHIMolecularGraphWriter()
Destructor.
CDPL::Chem::INCHIMolecularGraphWriter::INCHIMolecularGraphWriter
INCHIMolecularGraphWriter(std::ostream &os)
Constructs a INCHIMolecularGraphWriter instance that will write data of molecular graphs to the outpu...
CDPL::Chem::INCHIMolecularGraphWriter::getMessage
const std::string & getMessage() const
Returns the error message associated with the last write operation.
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
CDPL::Chem::setIsotope
CDPL_CHEM_API void setIsotope(Atom &atom, std::size_t isotope)
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Base::DataWriter
An interface for writing data objects of a given type to an arbitrary data sink.
Definition: DataWriter.hpp:63
CDPL::Chem::INCHIMolecularGraphWriter::operator!
bool operator!() const