Updated the rule system to automatically restore rule notes (rule-based)

This commit is contained in:
Uleat
2019-09-04 22:37:17 -04:00
parent f9536f9621
commit c1b48b9931
5 changed files with 116 additions and 126 deletions
+6 -10
View File
@@ -97,6 +97,9 @@ public:
static const char *GetRuleName(IntType t) { return(s_RuleInfo[t].name); }
static const char *GetRuleName(RealType t) { return(s_RuleInfo[t+_IntRuleCount].name); }
static const char *GetRuleName(BoolType t) { return(s_RuleInfo[t+_IntRuleCount+_RealRuleCount].name); }
static const std::string &GetRuleNotes(IntType t) { return(s_RuleInfo[t].notes); }
static const std::string &GetRuleNotes(RealType t) { return(s_RuleInfo[t+_IntRuleCount].notes); }
static const std::string &GetRuleNotes(BoolType t) { return(s_RuleInfo[t+_IntRuleCount+_RealRuleCount].notes); }
static uint32 CountRules() { return(_RulesCount); }
static CategoryType FindCategory(const char *catname);
bool ListRules(const char *catname, std::vector<const char *> &into);
@@ -113,9 +116,9 @@ public:
void ResetRules(bool reload = false);
bool LoadRules(Database *db, const char *ruleset = nullptr, bool reload = false);
void SaveRules(Database *db, const char *ruleset = nullptr);
bool UpdateChangedRules(Database *db, const char *ruleset_name, bool quiet_update = false);
bool UpdateInjectedRules(Database *db, const char *ruleset_name, bool quiet_update = false);
bool UpdateOrphanedRules(Database *db, bool quiet_update = false);
bool RestoreRuleNotes(Database *db);
private:
RuleManager();
@@ -143,21 +146,14 @@ private:
static const std::string &_GetRuleNotes(RuleType type, uint16 index);
static int _FindOrCreateRuleset(Database *db, const char *ruleset);
void _SaveRule(Database *db, RuleType type, uint16 index);
bool _UpdateRules(
Database *db,
const char *ruleset_name,
const int ruleset_id,
const std::vector<std::tuple<int, std::string, std::string, std::string>> &injected,
const std::vector<std::string> &orphaned
);
static const char *s_categoryNames[];
typedef struct {
const char *name;
CategoryType category;
RuleType type;
uint16 rule_index; //index into its 'type' array
std::string notes;
const std::string notes;
} RuleInfo;
static const RuleInfo s_RuleInfo[];