-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruleset.cpp
More file actions
83 lines (69 loc) · 2.06 KB
/
ruleset.cpp
File metadata and controls
83 lines (69 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <stdlib.h>
#include <string>
#include <iostream>
#include <regex>
#include <pqxx/pqxx>
#include "../structuredLogger/structuredLogger.h"
#include "ruleset.h"
/// \version $Revision: $
/// \date $Date: $
/// \file ruleset.cpp
/// \class rulset
///\fn ruleset::ruleset
///\arg none
///<< constructor no args
///<< connect to rule table to fill in the fields
///
ruleset::ruleset()
{
//ctor
}
///\fn ruleset::ruleset
///\arg pqxx::connection *
/// <<< used or creating an already connected db
ruleset::ruleset(pqxx::connection *dbc)
{
mp_dbc = dbc;
m_doNotDisconnect = true;
std::string table("ruleset");
retriveTableMetadata(table);
}
///\fn ruleset::ruleset
///\arg std::string connection
///<< dbname=[databaseName] user=[database user] password=[md5 encypted password] hostadd=[ip or localhost] port=[5432]
///<< constructor string for database connection
///<< connect to rule table to fill in the fields
///
ruleset::ruleset(std::string &dbconnection) : genericTable(dbconnection)
{
// file in field and type string vectors
std::string table("ruleset");
retriveTableMetadata(table);
}
pqxx::result ruleset::getRuleset(std::string &ruleset, std::vector<std::string> &rv)
{
std::string query( "SELECT rule.id, rule.regex FROM rule INNER JOIN rule_set ON rule.rule_set=rule_set.id and rule_set.name ~* '.*");
query.append (ruleset) ;
query.append (".*'");
pqxx::result r = execQuery(nullptr,query);
// go through the results
// vector<string> of rules (regex)
//
for (pqxx::result::const_iterator row = r.begin();
row != r.end(); row++)
{
//bool fname = true; // toggle whether it is the field or the field=-type
for (pqxx::result::tuple::const_iterator fields = row->begin();
fields != row->end();
++fields)
{
rv.push_back(fields->c_str());
elog()->debugL(debug,fields.c_str(),__FUNCTION__ );
}
}
return r;
}
ruleset::~ruleset()
{
//dtor
}