ROSE  0.9.10.168
FunctionIdDatabaseInterface.h
1 #ifndef FUNCTION_ID_DATABASE_INTERFACE_H
2 #define FUNCTION_ID_DATABASE_INTERFACE_H
3 
4 #include "sqlite3x.h"
5 #include "LibraryInfo.h"
6 #include "FunctionInfo.h"
7 #include <vector>
8 #include <ctype.h>
9 
17 {
29  {
30  UNKNOWN,
31  COMBINE,
32  REPLACE,
33  NO_ADD
34  };
35 
36  enum DUPLICATE_OPTION duplicateOptionFromString(std::string option);
37 
38 
45  {
46  public:
57  FunctionIdDatabaseInterface(std::string dbName);
58 
59 
71  void createTables();
72 
73 
74  // @brief Add an entry for a function to the database
75  void addFunctionToDB(const FunctionInfo& fInfo, enum DUPLICATE_OPTION dupOption = COMBINE);
76 
83  bool matchOneFunction(FunctionInfo& fInfo);
84 
90  std::vector<FunctionInfo> matchFunction(const FunctionInfo& fInfo);
91 
92 
100  bool exactMatchFunction(const FunctionInfo& fInfo);
101 
102 
107  void removeFunctions(const std::string& funcHash);
108 
109 
110  // @brief Add an entry for a library to the database
111  void addLibraryToDB(const LibraryInfo& lInfo, bool replace = false);
112 
117  bool matchLibrary(LibraryInfo& fInfo);
118 
119 
120  private:
121  // @brief The name of the database
122  std::string database_name;
123 
124  // @brief SQLite database handle
125  sqlite3x::sqlite3_connection sqConnection;
126  };
127 }
128 
129 
130 #endif
131 
class FunctionInfo Combines all the information to uniquely identify a single function in one object...
Definition: FunctionInfo.h:22
FunctionIdDatabaseInterface(std::string dbName)
FunctionIdentification.
bool matchOneFunction(FunctionInfo &fInfo)
Lookup a single function in the database.
void createTables()
createTables Make sure that all the tables are defined in the function identification database...
void removeFunctions(const std::string &funcHash)
Removes any functions that match the hash from the database.
Creates and holds the handle for the sqlite database used for storing and matching libraries and func...
DUPLICATE_OPTION
Option for what to do if a function with the same hash is found when adding a function.
std::vector< FunctionInfo > matchFunction(const FunctionInfo &fInfo)
Lookup all functions with the hash in the database.
bool matchLibrary(LibraryInfo &fInfo)
Lookup a library in the database.
bool exactMatchFunction(const FunctionInfo &fInfo)
Exactly lookup a function in the database.