FileParserUtils.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2010 Greg Landrum and Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved @@
00005 //  This file is part of the RDKit.
00006 //  The contents are covered by the terms of the BSD license
00007 //  which is included in the file license.txt, found at the root
00008 //  of the RDKit source tree.
00009 //
00010 #ifndef _RD_FILEPARSERUTILS_H
00011 #define _RD_FILEPARSERUTILS_H
00012 
00013 #include <string>
00014 #include <iostream>
00015 #include <boost/lexical_cast.hpp>
00016 #include <boost/algorithm/string.hpp>
00017 
00018 namespace RDKit{
00019   class RWMol;
00020   class Conformer;
00021 
00022   namespace FileParserUtils {
00023     template <typename T>
00024     T stripSpacesAndCast(const std::string &input,bool acceptSpaces=false){
00025       std::string trimmed=boost::trim_copy(input);
00026       if(acceptSpaces && trimmed==""){
00027         return 0;
00028       } else {
00029         return boost::lexical_cast<T>(trimmed);
00030       }
00031     }
00032     int toInt(const std::string &input,bool acceptSpaces=false);
00033     double toDouble(const std::string &input,bool acceptSpaces=true);
00034 
00035 
00036     // reads a line from an MDL v3K CTAB
00037     std::string getV3000Line(std::istream *inStream,unsigned int &line);
00038 
00039     // nAtoms and nBonds are ignored on input, set on output
00040     bool ParseV3000CTAB(std::istream *inStream,unsigned int &line,
00041                         RWMol *mol, Conformer *&conf,
00042                         bool &chiralityPossible,
00043                         unsigned int &nAtoms,unsigned int &nBonds);
00044 
00045     // nAtoms and nBonds are used
00046     bool ParseV2000CTAB(std::istream *inStream,unsigned int &line,
00047                         RWMol *mol, Conformer *&conf,
00048                         bool &chiralityPossible,
00049                         unsigned int &nAtoms,unsigned int &nBonds);
00050 
00051     Atom *replaceAtomWithQueryAtom(RWMol *mol,Atom *atom);
00052 
00053   }
00054 }
00055 
00056 #endif