Commit 78e59f0e authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added missing parameters + grammar

parent b09eb288
......@@ -11,6 +11,15 @@ using namespace::std;
using namespace::belr;
namespace belcard {
class BelCardLanguageParam : public BelCardParam {
public:
static shared_ptr<BelCardLanguageParam> create();
static shared_ptr<BelCardLanguageParam> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardLanguageParam();
};
class BelCardValueParam : public BelCardParam {
public:
static shared_ptr<BelCardValueParam> create();
......@@ -19,6 +28,87 @@ namespace belcard {
BelCardValueParam();
};
class BelCardPrefParam : public BelCardParam {
public:
static shared_ptr<BelCardPrefParam> create();
static shared_ptr<BelCardPrefParam> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardPrefParam();
};
class BelCardAlternativeIdParam : public BelCardParam {
public:
static shared_ptr<BelCardAlternativeIdParam> create();
static shared_ptr<BelCardAlternativeIdParam> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardAlternativeIdParam();
};
class BelCardParamIdParam : public BelCardParam {
public:
static shared_ptr<BelCardParamIdParam> create();
static shared_ptr<BelCardParamIdParam> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardParamIdParam();
};
class BelCardTypeParam : public BelCardParam {
public:
static shared_ptr<BelCardTypeParam> create();
static shared_ptr<BelCardTypeParam> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardTypeParam();
};
class BelCardMediaTypeParam : public BelCardParam {
public:
static shared_ptr<BelCardMediaTypeParam> create();
static shared_ptr<BelCardMediaTypeParam> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardMediaTypeParam();
};
class BelCardCALSCALEParam : public BelCardParam {
public:
static shared_ptr<BelCardCALSCALEParam> create();
static shared_ptr<BelCardCALSCALEParam> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardCALSCALEParam();
};
class BelCardSortAsParam : public BelCardParam {
public:
static shared_ptr<BelCardSortAsParam> create();
static shared_ptr<BelCardSortAsParam> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardSortAsParam();
};
class BelCardGeoParam : public BelCardParam {
public:
static shared_ptr<BelCardGeoParam> create();
static shared_ptr<BelCardGeoParam> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardGeoParam();
};
class BelCardTimezoneParam : public BelCardParam {
public:
static shared_ptr<BelCardTimezoneParam> create();
static shared_ptr<BelCardTimezoneParam> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardTimezoneParam();
};
}
#endif
\ No newline at end of file
......@@ -4,6 +4,28 @@ using namespace::std;
using namespace::belr;
using namespace::belcard;
shared_ptr<BelCardLanguageParam> BelCardLanguageParam::create() {
return BelCardGeneric::create<BelCardLanguageParam>();
}
shared_ptr<BelCardLanguageParam> BelCardLanguageParam::parse(const string& input) {
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("LANGUAGE-param", input, NULL);
return dynamic_pointer_cast<BelCardLanguageParam>(ret);
}
void BelCardLanguageParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("LANGUAGE-param", make_fn(&BelCardLanguageParam::create))
->setCollector("LANGUAGE-param", make_sfn(&BelCardLanguageParam::setValue));
}
BelCardLanguageParam::BelCardLanguageParam() : BelCardParam() {
setName("LANGUAGE");
}
shared_ptr<BelCardValueParam> BelCardValueParam::create() {
return BelCardGeneric::create<BelCardValueParam>();
}
......@@ -24,4 +46,202 @@ void BelCardValueParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric
BelCardValueParam::BelCardValueParam() : BelCardParam() {
setName("VALUE");
}
shared_ptr<BelCardPrefParam> BelCardPrefParam::create() {
return BelCardGeneric::create<BelCardPrefParam>();
}
shared_ptr<BelCardPrefParam> BelCardPrefParam::parse(const string& input) {
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("PREF-param", input, NULL);
return dynamic_pointer_cast<BelCardPrefParam>(ret);
}
void BelCardPrefParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("PREF-param", make_fn(&BelCardPrefParam::create))
->setCollector("PREF-param", make_sfn(&BelCardPrefParam::setValue));
}
BelCardPrefParam::BelCardPrefParam() : BelCardParam() {
setName("PREF");
}
shared_ptr<BelCardAlternativeIdParam> BelCardAlternativeIdParam::create() {
return BelCardGeneric::create<BelCardAlternativeIdParam>();
}
shared_ptr<BelCardAlternativeIdParam> BelCardAlternativeIdParam::parse(const string& input) {
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("ALTID-param", input, NULL);
return dynamic_pointer_cast<BelCardAlternativeIdParam>(ret);
}
void BelCardAlternativeIdParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("ALTID-param", make_fn(&BelCardAlternativeIdParam::create))
->setCollector("ALTID-param", make_sfn(&BelCardAlternativeIdParam::setValue));
}
BelCardAlternativeIdParam::BelCardAlternativeIdParam() : BelCardParam() {
setName("ALTID");
}
shared_ptr<BelCardParamIdParam> BelCardParamIdParam::create() {
return BelCardGeneric::create<BelCardParamIdParam>();
}
shared_ptr<BelCardParamIdParam> BelCardParamIdParam::parse(const string& input) {
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("PID-param", input, NULL);
return dynamic_pointer_cast<BelCardParamIdParam>(ret);
}
void BelCardParamIdParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("PID-param", make_fn(&BelCardParamIdParam::create))
->setCollector("PID-param", make_sfn(&BelCardParamIdParam::setValue));
}
BelCardParamIdParam::BelCardParamIdParam() : BelCardParam() {
setName("PID");
}
shared_ptr<BelCardTypeParam> BelCardTypeParam::create() {
return BelCardGeneric::create<BelCardTypeParam>();
}
shared_ptr<BelCardTypeParam> BelCardTypeParam::parse(const string& input) {
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("TYPE-param", input, NULL);
return dynamic_pointer_cast<BelCardTypeParam>(ret);
}
void BelCardTypeParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("TYPE-param", make_fn(&BelCardTypeParam::create))
->setCollector("TYPE-param", make_sfn(&BelCardTypeParam::setValue));
}
BelCardTypeParam::BelCardTypeParam() : BelCardParam() {
setName("TYPE");
}
shared_ptr<BelCardMediaTypeParam> BelCardMediaTypeParam::create() {
return BelCardGeneric::create<BelCardMediaTypeParam>();
}
shared_ptr<BelCardMediaTypeParam> BelCardMediaTypeParam::parse(const string& input) {
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("MEDIATYPE-param", input, NULL);
return dynamic_pointer_cast<BelCardMediaTypeParam>(ret);
}
void BelCardMediaTypeParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("MEDIATYPE-param", make_fn(&BelCardMediaTypeParam::create))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardMediaTypeParam::setValue));
}
BelCardMediaTypeParam::BelCardMediaTypeParam() : BelCardParam() {
setName("MEDIATYPE");
}
shared_ptr<BelCardCALSCALEParam> BelCardCALSCALEParam::create() {
return BelCardGeneric::create<BelCardCALSCALEParam>();
}
shared_ptr<BelCardCALSCALEParam> BelCardCALSCALEParam::parse(const string& input) {
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("CALSCALE-param", input, NULL);
return dynamic_pointer_cast<BelCardCALSCALEParam>(ret);
}
void BelCardCALSCALEParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("CALSCALE-param", make_fn(&BelCardCALSCALEParam::create))
->setCollector("CALSCALE-param", make_sfn(&BelCardCALSCALEParam::setValue));
}
BelCardCALSCALEParam::BelCardCALSCALEParam() : BelCardParam() {
setName("CALSCALE");
}
shared_ptr<BelCardSortAsParam> BelCardSortAsParam::create() {
return BelCardGeneric::create<BelCardSortAsParam>();
}
shared_ptr<BelCardSortAsParam> BelCardSortAsParam::parse(const string& input) {
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("SORT-AS-param", input, NULL);
return dynamic_pointer_cast<BelCardSortAsParam>(ret);
}
void BelCardSortAsParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("SORT-AS-param", make_fn(&BelCardSortAsParam::create))
->setCollector("SORT-AS-param", make_sfn(&BelCardSortAsParam::setValue));
}
BelCardSortAsParam::BelCardSortAsParam() : BelCardParam() {
setName("SORT-AS");
}
shared_ptr<BelCardGeoParam> BelCardGeoParam::create() {
return BelCardGeneric::create<BelCardGeoParam>();
}
shared_ptr<BelCardGeoParam> BelCardGeoParam::parse(const string& input) {
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("GEO-param", input, NULL);
return dynamic_pointer_cast<BelCardGeoParam>(ret);
}
void BelCardGeoParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("GEO-param", make_fn(&BelCardGeoParam::create))
->setCollector("GEO-param", make_sfn(&BelCardGeoParam::setValue));
}
BelCardGeoParam::BelCardGeoParam() : BelCardParam() {
setName("GEO");
}
shared_ptr<BelCardTimezoneParam> BelCardTimezoneParam::create() {
return BelCardGeneric::create<BelCardTimezoneParam>();
}
shared_ptr<BelCardTimezoneParam> BelCardTimezoneParam::parse(const string& input) {
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("TZ-param", input, NULL);
return dynamic_pointer_cast<BelCardTimezoneParam>(ret);
}
void BelCardTimezoneParam::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("TZ-param", make_fn(&BelCardTimezoneParam::create))
->setCollector("TZ-param", make_sfn(&BelCardTimezoneParam::setValue));
}
BelCardTimezoneParam::BelCardTimezoneParam() : BelCardParam() {
setName("TZ");
}
\ No newline at end of file
......@@ -22,7 +22,17 @@ shared_ptr<BelCard> BelCardParser::parse(const string &input) {
BelCardParam::setHandlerAndCollectors(&parser);
BelCardProperty::setHandlerAndCollectors(&parser);
BelCardLanguageParam::setHandlerAndCollectors(&parser);
BelCardValueParam::setHandlerAndCollectors(&parser);
BelCardPrefParam::setHandlerAndCollectors(&parser);
BelCardAlternativeIdParam::setHandlerAndCollectors(&parser);
BelCardParamIdParam::setHandlerAndCollectors(&parser);
BelCardTypeParam::setHandlerAndCollectors(&parser);
BelCardMediaTypeParam::setHandlerAndCollectors(&parser);
BelCardCALSCALEParam::setHandlerAndCollectors(&parser);
BelCardSortAsParam::setHandlerAndCollectors(&parser);
BelCardGeoParam::setHandlerAndCollectors(&parser);
BelCardTimezoneParam::setHandlerAndCollectors(&parser);
BelCardSource::setHandlerAndCollectors(&parser);
BelCardKind::setHandlerAndCollectors(&parser);
......
......@@ -191,6 +191,8 @@ CALURI-value = URI
group = 1*(ALPHA / DIGIT / "-")
LANGUAGE-param = "LANGUAGE=" Language-Tag
VALUE-param = "VALUE=" VALUE-param-value
VALUE-param-value = "text"
/ "uri"
......@@ -205,6 +207,29 @@ VALUE-param-value = "text"
/ "utc-offset"
/ "language-tag"
/ x-name
PREF-param = "PREF=" (1*2DIGIT / "100")
ALTID-param = "ALTID=" param-value
PID-param = "PID=" PID-param-value *("," PID-param-value)
PID-param-value = 1*DIGIT ["." 1*DIGIT]
TYPE-param = "TYPE=" TYPE-param-value *("," TYPE-param-value)
TYPE-param-value = "work" / "home" / type-param-tel / type-param-related / iana-token / x-name
MEDIATYPE-param = "MEDIATYPE=" MEDIATYPE-param-value
MEDIATYPE-param-value = type-name "/" subtype-name *( ";" any-param )
CALSCALE-param = "CALSCALE=" CALSCALE-param-value
CALSCALE-param-value = "gregorian" / iana-token / x-name
SORT-AS-param = "SORT-AS=" SORT-AS-param-value
SORT-AS-param-value = param-value *("," param-value)
GEO-param = "GEO=" DQUOTE URI DQUOTE
TZ-param = "TZ=" (param-value / DQUOTE URI DQUOTE)
any-param = param-name "=" param-value
param-name = (iana-token / x-name)
......@@ -276,6 +301,19 @@ date-and-or-time = date-time / date / time-designator time
utc-offset = sign hour [minute]
type-param-related = related-type-value *("," related-type-value)
related-type-value = "contact" / "acquaintance" / "friend" / "met"
/ "co-worker" / "colleague" / "co-resident"
/ "neighbor" / "child" / "parent"
/ "sibling" / "spouse" / "kin" / "muse"
/ "crush" / "date" / "sweetheart" / "me"
/ "agent" / "emergency"
type-param-tel = "text" / "voice" / "fax" / "cell" / "video"
/ "pager" / "textphone" / iana-token / x-name
type-name = reg-name
subtype-name = reg-name
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
hier-part = "//" authority path-abempty
......
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