Chemical Data Processing Library C++ API - Version 1.4.0
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 
172 
177 
179 
186 
194  int getReturnCode() const;
195 
200  const std::string& getMessage() const;
201 
206  const std::string& getLogOutput() const;
207 
212  operator const void*() const;
213 
218  bool operator!() const;
219 
220  private:
221  void writeMolGraph(const MolecularGraph&);
222 
223  void setupAtomTable(const MolecularGraph&, std::size_t);
224 
225  std::size_t getCoordsDimension(const MolecularGraph&) const;
226 
227  void setBondingInfo(const MolecularGraph&, const Atom&, inchi_Atom&, std::size_t) const;
228  void setElementSymbol(const Atom&, inchi_Atom&) const;
229  void setIsotope(const Atom&, inchi_Atom&) const;
230  void setFormalCharge(const Atom&, inchi_Atom&) const;
231  void setCoordinates(const Atom&, inchi_Atom&, std::size_t) const;
232  void setRadicalType(const Atom&, inchi_Atom&) const;
233  void setImplicitHCounts(inchi_Atom&) const;
234 
235  void setup0DStereoInfo(const MolecularGraph&);
236 
237  void setup0DAtomStereoInfo(const MolecularGraph&);
238  void setup0DBondStereoInfo(const MolecularGraph&);
239 
240  typedef std::vector<inchi_Atom> InChIAtomTable;
241  typedef std::vector<inchi_Stereo0D> InChIStereoInfoList;
242  typedef std::vector<char> StringData;
243 
244  std::ostream& output;
245  InChIAtomTable inchiAtomTable;
246  InChIStereoInfoList inchiStereoInfo;
247  StringData inchiOptions;
248  bool strictErrorChecking;
249  int returnCode;
250  std::string message;
251  std::string logOutput;
252  bool state;
253  };
254  } // namespace Chem
255 } // namespace CDPL
256 
257 #endif // CDPL_CHEM_INCHIMOLECULARGRAPHWRITER_HPP
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of class CDPL::Base::DataWriter.
struct tagInchiAtom inchi_Atom
Definition: INCHIMolecularGraphWriter.hpp:41
struct tagINCHIStereo0D inchi_Stereo0D
Definition: INCHIMolecularGraphWriter.hpp:42
Interface for writing data objects of a given type to an arbitrary data sink.
Definition: DataWriter.hpp:63
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:57
Writer for molecular graph data in the IUPAC International Chemical Identifier (InChI) [INCHI] format...
Definition: INCHIMolecularGraphWriter.hpp:161
Base::DataWriter< MolecularGraph > & write(const MolecularGraph &molgraph)
Writes data of the molecular graph molgraph to the output stream specified in the constructor.
const std::string & getLogOutput() const
Returns the log output that was generated for the last write operation.
INCHIMolecularGraphWriter(std::ostream &os)
Constructs a INCHIMolecularGraphWriter instance that will write data of molecular graphs to the outpu...
INCHIMolecularGraphWriter & operator=(const INCHIMolecularGraphWriter &)=delete
int getReturnCode() const
Returns the error code of the last write operation.
INCHIMolecularGraphWriter(const INCHIMolecularGraphWriter &)=delete
bool operator!() const
Tells whether a previous write operation has failed.
const std::string & getMessage() const
Returns the error message associated with the last write operation.
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
CDPL_CHEM_API void setRadicalType(Atom &atom, unsigned int type)
Sets the Chem::AtomProperty::RADICAL_TYPE property of atom to type (see namespace Chem::RadicalType).
CDPL_CHEM_API void setIsotope(Atom &atom, std::size_t isotope)
Sets the Chem::AtomProperty::ISOTOPE property of atom to isotope.
CDPL_CHEM_API void setFormalCharge(Atom &atom, long charge)
Sets the Chem::AtomProperty::FORMAL_CHARGE property of atom to charge.
The namespace of the Chemical Data Processing Library.