-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created project layout and csv, conf readers #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this pull request is a good proof of concept for casbin, may work but it differs so much from the official go version.
Before contributing I think we should have a code of conduct, like which build tool we use, which coding style to use, which cpp standard to use, which file extension to use etc.
include/CSVManager.h
Outdated
#include<vector> | ||
#include<string> | ||
|
||
class CSVManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
casbin doesn't read csv file directly, it uses an adapter to read policy, csv file is a kind of adapter.
public: | ||
std::vector<std::string> readLine(std::string); | ||
void readFile(std::string); | ||
void writeFile(std::string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the writeFile
api here has no use because we usually don't edit a csv file.
include/ConfReader.cc
Outdated
std::ifstream file(fileName, std::ios::out); | ||
if (!file.is_open()) | ||
{ | ||
std::cerr << "Error: Unable to open CSV file " << fileName << " for reading!" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conf file is actually an ini
file, not a csv file. The purpose of a conf reader is to construct a model
include/ExpressionParser.cc
Outdated
#include <iostream> | ||
#include "utils.h" | ||
|
||
class ExpressionParser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class is to parse the matcher expression passed in the model conf file
makefile
Outdated
@@ -0,0 +1,4 @@ | |||
CC = g++ | |||
CFLAGS = -std=c++11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about choosing a cross-platform build tool like cmake so we can build in windows.
@xcaptain thank you for your support, I will refactor the whole code according to your suggestions and code of conduct. |
Added CMake and Visual Studio Support. |
See: #7 and my latest commits. |
@hsluoyz I will add support for makefile and Visual Studio project files support. |
I think contributors should add code based on my latest commits. Like start from: https://github.com/casbin/casbin-cpp/blob/master/casbin/enforcer.cpp |
No description provided.