RDKit
Open-source cheminformatics and machine learning.
ReactionPickler.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2009 Greg Landrum
3 // Copyright (c) 2014, Novartis Institutes for BioMedical Research Inc.
4 //
5 // @@ All Rights Reserved @@
6 // This file is part of the RDKit.
7 // The contents are covered by the terms of the BSD license
8 // which is included in the file license.txt, found at the root
9 // of the RDKit source tree.
10 //
11 #ifndef _RD_RXNPICKLE_H_2JUNE2009_
12 #define _RD_RXNPICKLE_H_2JUNE2009_
13 
14 // Std stuff
15 #include <iostream>
16 #include <string>
17 #include <exception>
18 #ifdef WIN32
19 #include <ios>
20 #endif
21 
22 namespace RDKit{
23  class ChemicalReaction;
24 
25  //! used to indicate exceptions whilst pickling (serializing) reactions
26  class ReactionPicklerException : public std::exception {
27  public :
28  ReactionPicklerException(const char *msg) : _msg(msg) {};
29  ReactionPicklerException(const std::string msg) : _msg(msg) {};
30  const char *message () const { return _msg.c_str(); };
31  ~ReactionPicklerException () throw () {};
32 
33  private :
34  std::string _msg;
35  };
36 
37  //! handles pickling (serializing) reactions
39  public:
40  static const boost::int32_t versionMajor,versionMinor,versionPatch; //!< mark the pickle version
41  static const boost::int32_t endianId; //! mark the endian-ness of the pickle
42 
43  //! the pickle format is tagged using these tags:
44  //! NOTE: if you add to this list, be sure to put new entries AT THE BOTTOM, otherwise
45  //! you will break old pickles.
46  typedef enum {
47  VERSION=10000,
55  } Tags;
56 
57  //! pickles a reaction and sends the results to stream \c ss
58  static void pickleReaction(const ChemicalReaction *rxn,std::ostream &ss);
59  static void pickleReaction(const ChemicalReaction &rxn,std::ostream &ss) {
61  };
62  //! pickles a reaction and adds the results to string \c res
63  static void pickleReaction(const ChemicalReaction *rxn,std::string &res);
64  static void pickleReaction(const ChemicalReaction &rxn,std::string &res) {
66  };
67 
68  //! constructs a reaction from a pickle stored in a string
69  static void reactionFromPickle(const std::string &pickle,ChemicalReaction *rxn);
70  static void reactionFromPickle(const std::string &pickle,ChemicalReaction &rxn) {
72  };
73 
74  //! constructs a reaction from a pickle stored in a stream
75  static void reactionFromPickle(std::istream &ss,ChemicalReaction *rxn);
76  static void reactionFromPickle(std::istream &ss,ChemicalReaction &rxn) {
78  };
79  private:
80  //! do the actual work of pickling a reaction
81  static void _pickle(const ChemicalReaction *rxn,std::ostream &ss);
82 
83  //! do the actual work of de-pickling a reaction
84  static void _depickle(std::istream &ss,ChemicalReaction *rxn, int version);
85 
86  };
87 
88 };
89 
90 
91 #endif
const int versionMinor
Definition: Catalog.h:31
const char * message() const
static const boost::int32_t versionPatch
mark the pickle version
static void pickleReaction(const ChemicalReaction &rxn, std::ostream &ss)
This is a class for storing and applying general chemical reactions.
Definition: Reaction.h:113
ReactionPicklerException(const std::string msg)
used to indicate exceptions whilst pickling (serializing) reactions
static void reactionFromPickle(const std::string &pickle, ChemicalReaction *rxn)
constructs a reaction from a pickle stored in a string
static void reactionFromPickle(const std::string &pickle, ChemicalReaction &rxn)
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
Tags
mark the endian-ness of the pickle
static void pickleReaction(const ChemicalReaction &rxn, std::string &res)
static const boost::int32_t endianId
static void reactionFromPickle(std::istream &ss, ChemicalReaction &rxn)
const int versionMajor
Definition: Catalog.h:30
handles pickling (serializing) reactions
ReactionPicklerException(const char *msg)
static void pickleReaction(const ChemicalReaction *rxn, std::ostream &ss)
pickles a reaction and sends the results to stream ss