Chemical Data Processing Library C++ API - Version 1.2.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 
208  operator const void*() const;
209  bool operator!() const;
210 
211  private:
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
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 the class CDPL::Base::DataWriter.
struct tagInchiAtom inchi_Atom
Definition: INCHIMolecularGraphWriter.hpp:41
struct tagINCHIStereo0D inchi_Stereo0D
Definition: INCHIMolecularGraphWriter.hpp:42
An interface for writing data objects of a given type to an arbitrary data sink.
Definition: DataWriter.hpp:63
Atom.
Definition: Atom.hpp:52
A writer for molecular graph data in the IUPAC International Chemical Identifier (InChI) [INCHI] form...
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 the writer is in a bad state.
const std::string & getMessage() const
Returns the error message associated with the last write operation.
MolecularGraph.
Definition: MolecularGraph.hpp:52
CDPL_CHEM_API void setRadicalType(Atom &atom, unsigned int type)
CDPL_CHEM_API void setIsotope(Atom &atom, std::size_t isotope)
CDPL_CHEM_API void setFormalCharge(Atom &atom, long charge)
The namespace of the Chemical Data Processing Library.