OpenStructure
chemdict_parser.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_CONOP_CHEMDICT_PARSER_HH
20 #define OST_CONOP_CHEMDICT_PARSER_HH
21 
22 /*
23  Author: Marco Biasini
24  */
25 
26 
27 #include <ost/mol/mol.hh>
30 
31 namespace ost { namespace io {
32 
33 typedef enum {
37 } LoopType;
38 
40 public:
41  ChemdictParser(std::istream& stream, conop::Compound::Dialect dialect):
42  StarParser(stream), compound_(new conop::Compound("UNK")),
43  last_(0), loop_type_(DONT_KNOW), dialect_(dialect)
44  {
45  this->InitTypeMap();
46  }
47 
48  virtual bool OnBeginData(const StringRef& data_name);
49 
50  virtual bool OnBeginLoop(const StarLoopDesc& header);
51 
52  virtual void OnDataRow(const StarLoopDesc& header,
53  const std::vector<StringRef>& columns);
54 
55  virtual void OnDataItem(const StarDataItem& item);
56 
57  virtual void OnEndData();
58 
59  void SetCompoundLib(const conop::CompoundLibPtr& lib)
60  {
61  lib_=lib;
62  }
63 private:
64  void InitTypeMap();
66  conop::CompoundPtr compound_;
67  typedef enum {
68  ATOM_NAME=0,
69  ALT_ATOM_NAME=1,
70  IS_AROMATIC=2,
71  ORDINAL=3,
72  IS_LEAVING=4,
73  ELE=5,
74  STEREO_CONF=6,
75  ATOM_ID1=0,
76  ATOM_ID2=1,
77  BOND_ORDER=2
78  } PropIndex;
79  char last_;
80  int indices_[10];
81  bool insert_;
82  static std::map<String, mol::ChemClass> tm_;
83  std::map<String, int> atom_map_;
84  LoopType loop_type_;
85  conop::AtomSpec atom_;
86  conop::Compound::Dialect dialect_;
87 };
88 
89 
90 }}
91 
92 
93 #endif