-
Notifications
You must be signed in to change notification settings - Fork 2
/
sqlpp11_adapter.h
44 lines (33 loc) · 959 Bytes
/
sqlpp11_adapter.h
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
//
// Created by lenovo on 2024/5/12.
//
#ifndef CASBIN_CPP_SQLPP11_ADAPTER_H
#define CASBIN_CPP_SQLPP11_ADAPTER_H
#include <memory>
#include <string>
#include <vector>
#include "casbin/persist/adapter.h"
#include "casbin/util/util.h"
#include "sqlpp11/mysql/mysql.h"
#include "sqlpp11/sqlpp11.h"
namespace casbin {
struct CasbinRule;
struct Adapter;
class Model;
class Sqlpp11Adapter : public Adapter {
public:
Sqlpp11Adapter();
void LoadPolicy(const std::shared_ptr<Model>& model)
;
void SavePolicy(Model& model);
std::string GetFullTableName() const;
void createTable();
void dropTable();
private:
sqlpp::mysql::connection_config config;
sqlpp::mysql::connection db;
CasbinRule savePolicyLine(const std::string& ptype, const std::vector<std::string>& rule);
void LoadPolicyLine(CasbinRule line, const std::shared_ptr<Model>& model);
};
} // namespace casbin
#endif // CASBIN_CPP_SQLPP11_ADAPTER_H