00001
00002
00003
00004
00005
00006
00007
00008 #ifndef DATABASE_H
00009 #define DATABASE_H
00010
00011 #include "externs.h"
00012 #include <list>
00013
00014 #ifdef DB_NDBM
00015 extern "C" {
00016 # include <ndbm.h>
00017 }
00018 #elif defined(DB_DBH)
00019 extern "C" {
00020 # define DB_DBM_HSEARCH 1
00021 # include <db.h>
00022 }
00023 #elif defined(USE_SQLITE_DBM)
00024 # include "sqldbm.h"
00025 #else
00026 # error DBM interfaces unavailable!
00027 #endif
00028
00029 #define DPTR_COERCE char *
00030
00031 void databaseSystemInit();
00032 void databaseSystemShutdown();
00033 datum database_fetch(DBM *database, const std::string &key);
00034
00035 typedef bool (*db_find_filter)(std::string key, std::string body);
00036
00037 std::vector<std::string> database_find_keys(DBM *database,
00038 const std::string ®ex,
00039 bool ignore_case = false,
00040 db_find_filter filter = NULL);
00041 std::vector<std::string> database_find_bodies(DBM *database,
00042 const std::string ®ex,
00043 bool ignore_case = false,
00044 db_find_filter filter = NULL);
00045
00046
00047 std::string getWeightedSpeechString(const std::string &key,
00048 const std::string &suffix,
00049 const int weight = -1);
00050
00051 std::string getQuoteString(const std::string &key);
00052 std::string getLongDescription(const std::string &key);
00053 std::string getWeightedRandomisedDescription(const std::string &key);
00054
00055 std::vector<std::string> getLongDescKeysByRegex(const std::string ®ex,
00056 db_find_filter filter = NULL);
00057 std::vector<std::string> getLongDescBodiesByRegex(const std::string ®ex,
00058 db_find_filter filter = NULL);
00059
00060 std::string getGameStartDescription(const std::string &key);
00061
00062 std::string getShoutString(const std::string &monst,
00063 const std::string &suffix = "");
00064 std::string getSpeakString(const std::string &key);
00065 std::string getRandNameString(const std::string &itemtype,
00066 const std::string &suffix = "");
00067 std::string getHelpString(const std::string &topic);
00068 std::string getMiscString(const std::string &misc,
00069 const std::string &suffix = "");
00070
00071 std::vector<std::string> getAllFAQKeys(void);
00072 std::string getFAQ_Question(const std::string &key);
00073 std::string getFAQ_Answer(const std::string &question);
00074 #endif