Commit 8890bae1 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Allow a vcard parse with extension properties

parent ed1e592f
......@@ -10,6 +10,7 @@ shared_ptr<BelCard> BelCard::create() {
void BelCard::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("vcard", make_fn(&BelCard::create))
->setCollector("OTHER", make_sfn(&BelCard::addProperty))
->setCollector("SOURCE", make_sfn(&BelCard::addSource))
->setCollector("KIND", make_sfn(&BelCard::setKind))
->setCollector("XML", make_sfn(&BelCard::addXML))
......
......@@ -52,11 +52,18 @@ shared_ptr<BelCardProperty> BelCardProperty::create() {
}
shared_ptr<BelCardProperty> BelCardProperty::parse(const string& input) {
return NULL;
ABNFGrammarBuilder grammar_builder;
shared_ptr<Grammar> grammar = grammar_builder.createFromAbnf((const char*)vcard_grammar, make_shared<CoreRules>());
Parser<shared_ptr<BelCardGeneric>> parser(grammar);
setHandlerAndCollectors(&parser);
shared_ptr<BelCardGeneric> ret = parser.parseInput("OTHER", input, NULL);
return dynamic_pointer_cast<BelCardProperty>(ret);
}
void BelCardProperty::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("OTHER", make_fn(&BelCardProperty::create))
->setCollector("OTHER-name", make_sfn(&BelCardProperty::setName))
->setCollector("OTHER-value", make_sfn(&BelCardProperty::setValue));
}
BelCardProperty::BelCardProperty() : BelCardGeneric() {
......
......@@ -20,6 +20,7 @@ shared_ptr<BelCard> BelCardParser::parse(const string &input) {
BelCard::setHandlerAndCollectors(&parser);
BelCardParam::setHandlerAndCollectors(&parser);
BelCardProperty::setHandlerAndCollectors(&parser);
BelCardSource::setHandlerAndCollectors(&parser);
BelCardKind::setHandlerAndCollectors(&parser);
......
......@@ -14,6 +14,23 @@ property = SOURCE / KIND / XML
/ CATEGORIES / NOTE / PRODID / REV / SOUND / UID / CLIENTPIDMAP / URL
/ KEY
/ FBURL / CALADRURI / CALURI
/ OTHER
OTHER = [group "."] OTHER-name *(";" any-param) ":" OTHER-value CRLF
OTHER-name = x-name
OTHER-value = text
/ text-list
/ date-list
/ time-list
/ date-time-list
/ date-and-or-time-list
/ timestamp-list
/ boolean
/ integer-list
/ float-list
/ URI
/ utc-offset
/ Language-Tag
KIND = [group "."] "KIND" *(";" any-param) ":" KIND-value CRLF
KIND-value = "individual" / "group" / "org" / "location" / iana-token / x-name
......
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment