FeatureParser.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2004-2006 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 __FEATUREPARSER_H_02122004_1810__
00011 #define __FEATUREPARSER_H_02122004_1810__
00012 
00013 #include <iostream>
00014 #include <string>
00015 #include <map>
00016 #include "MolChemicalFeatureDef.h"
00017 
00018 namespace RDKit{
00019   //! \brief class used to indicate errors in parsing feature definition
00020   //!   files.
00021   class FeatureFileParseException : public std::exception {
00022   public:
00023     FeatureFileParseException(unsigned int lineNo,std::string line,std::string msg) :
00024       d_lineNo(lineNo), d_line(line), d_msg(msg) {};
00025     unsigned int lineNo () const { return d_lineNo; };
00026     std::string line () const { return d_line; };
00027     std::string message () const { return d_msg; };
00028     ~FeatureFileParseException () throw () {};
00029   private:
00030     unsigned int d_lineNo;
00031     std::string d_line,d_msg;
00032   };
00033   
00034   int parseFeatureData(const std::string &defnText,
00035                        MolChemicalFeatureDef::CollectionType &featDefs);
00036   int parseFeatureData(std::istream &istream,
00037                        MolChemicalFeatureDef::CollectionType &featDefs);
00038   int parseFeatureFile(const std::string &fileName,
00039                        MolChemicalFeatureDef::CollectionType &featDefs);
00040 
00041 
00042   namespace Local {
00043     // these functions are exposed only so they can be tested
00044     void parseAtomType(const std::string &inLine,
00045                        std::map<std::string,std::string> &atomTypeDefs,
00046                        const unsigned int &lineNo);
00047     MolChemicalFeatureDef *parseFeatureDef(std::istream &inStream,
00048                                         const std::string &inLine,
00049                                         unsigned int &lineNo,
00050                                         const std::map<std::string,std::string> &atomTypeDefs);
00051   }
00052 } // end of namespace RDKit
00053 #endif