Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OB_DESCRIPTOR_H
00020 #define OB_DESCRIPTOR_H
00021
00022 #include <string>
00023 #include <sstream>
00024 #include <limits>
00025
00026 #include <openbabel/babelconfig.h>
00027 #include <openbabel/plugin.h>
00028
00029 namespace OpenBabel
00030 {
00031 class OBBase;
00032
00033
00034 class OBAPI OBDescriptor : public OBPlugin
00035 {
00036 MAKE_PLUGIN(OBDescriptor)
00037
00038 public:
00039 const char* TypeID(){return "descriptors";};
00040
00042 virtual double Predict(OBBase* , std::string* =NULL)
00043 {return std::numeric_limits<double>::quiet_NaN();}
00044
00046 double PredictAndSave(OBBase* pOb, std::string* param=NULL);
00047
00049 virtual double GetStringValue(OBBase* pOb, std::string& svalue, std::string* param=NULL);
00050
00052 virtual bool Compare(OBBase* pOb, std::istream& ss, bool noEval, std::string* param=NULL);
00053
00057 virtual bool Display(std::string& txt, const char* param, const char* ID=NULL);
00058
00061 virtual bool Order(double p1, double p2){ return p1<p2; }
00062 virtual bool Order(std::string s1, std::string s2){ return s1<s2; }
00063
00065 static bool FilterCompare(OBBase* pOb, std::istream& ss, bool noEval);
00066
00068 static void AddProperties(OBBase* pOb, const std::string& DescrList);
00069
00071 static void DeleteProperties(OBBase* pOb, const std::string& DescrList);
00072
00075 static std::string GetValues(OBBase* pOb, const std::string& DescrList);
00076
00078 static std::pair<std::string, std::string> GetIdentifier(std::istream& optionText);
00079
00080 protected:
00081
00082 static double ParsePredicate(std::istream& optionText, char& ch1, char& ch2, std::string& svalue);
00083
00086 static bool ReadStringFromFilter(std::istream& ss, std::string& result);
00087
00090 static bool CompareStringWithFilter(std::istream& optionText, std::string& s, bool noEval, bool NoCompOK=false);
00091
00092
00093 static bool ispunctU(char ch)
00094 {
00095 return ispunct(ch) && ch!='_';
00096 }
00097
00099 static bool MatchPairData(OBBase* pOb, std::string& s);
00100 };
00101
00102 template <class T>
00103 static bool DoComparison(char ch1, char ch2, T& val, T& filterval)
00104 {
00105 switch(ch1)
00106 {
00107 case (0):
00108 case('='):
00109 return val==filterval;
00110 case('!'):
00111 return val!=filterval;
00112 case('>'):
00113 if(ch2=='=')
00114 return val>=filterval;
00115 else
00116 return val>filterval;
00117 case('<'):
00118 if(ch2=='=')
00119 return val<=filterval;
00120 else
00121 return val<filterval;
00122 }
00123 return false;
00124 }
00125
00126 }
00127 #endif
00128