Does this library support C++ attributes?
Closed this issue · 5 comments
From what I see, cppparser doesn't recognize the [[ns::attribute]] syntax at all.
Am I unfortunately right, or is there any way to somehow enable attribute declaration parsing?
If I'm right, are there any plans to implement attribute parsing in the near future?
As of now cppparser doesn't recognize the [[ns::attribute]] syntax. But it is easy to add. I can do that but if you post a "test file" with the required attributes then it will be great. You can hand craft such test file or put a link to a publicly available file from some open source and I will make the changes to improve the parser.
Sorry for the delay - I didn't see your reply till now. Yeah, I can do that. Where do you want me to post it? Right here?
namespace plakmp
{
struct [[xnet::ValidateData]] SignUpRequest
{
[[xnet::StringNotEmpty]]
[[xnet::StringMinLength(2)]]
std::string name;
};
class [[xnet::HttpController]] [[xnet::Route("/plakmp")]] PlakMpApiController
{
public:
[[xnet::HttpGet]]
[[xnet::Route("/players")]]
std::string GetPlakMpPlayers(std::string first_name);
[[xnet::HttpGet]]
std::string GetHelloWorld();
[[xnet::HttpPost]]
[[xnet::Route("/register")]]
std::string CreateAccount([[xnet::FromBody]] [[xnet::EnsureValid]] SignUpRequest request);
};
}
These are custom attributes I'm writing a parser/metadata generator for. You can see how it looks a lot like ASP.NET or funny Java web stuff - that's what I'm aiming for.
In general, all I need is a list of attributes for a particular code "entity" along with their namespace, name and (optional) arguments. I'll be extremely glad if you provided that!
I realized I had missed working on it. I had a plan to work on it and then I got busy somewhere else. I am working on it now and soon it will be available. Sorry for forgetting about it. I would not mind if I was poked to get reminded about it. :)