Commit 135458c7 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Added collectors for properties according to RFC and grammar

parent 112fd342
......@@ -21,6 +21,7 @@ namespace belcard {
string _region;
string _postal_code;
string _country;
shared_ptr<BelCardLabelParam> _label_param;
public:
static shared_ptr<BelCardAddress> create();
......@@ -50,6 +51,9 @@ namespace belcard {
void setCountry(const string &value);
const string &getCountry() const;
void setLabelParam(const shared_ptr<BelCardLabelParam> &param);
const shared_ptr<BelCardLabelParam> &getLabelParam() const;
string serialize() const;
};
}
......
......@@ -20,7 +20,17 @@ namespace belcard {
string _group;
string _name;
string _value;
shared_ptr<BelCardLanguageParam> _lang_param;
shared_ptr<BelCardValueParam> _value_param;
shared_ptr<BelCardPrefParam> _pref_param;
shared_ptr<BelCardAlternativeIdParam> _altid_param;
shared_ptr<BelCardParamIdParam> _pid_param;
shared_ptr<BelCardTypeParam> _type_param;
shared_ptr<BelCardMediaTypeParam> _mediatype_param;
shared_ptr<BelCardCALSCALEParam> _calscale_param;
shared_ptr<BelCardSortAsParam> _sort_as_param;
shared_ptr<BelCardGeoParam> _geo_param;
shared_ptr<BelCardTimezoneParam> _tz_param;
list<shared_ptr<BelCardParam>> _params;
public:
......@@ -44,7 +54,38 @@ namespace belcard {
virtual void setValue(const string &value);
virtual const string &getValue() const;
virtual void addValueParam(const shared_ptr<BelCardValueParam> &param);
virtual void setLanguageParam(const shared_ptr<BelCardLanguageParam> &param);
virtual const shared_ptr<BelCardLanguageParam> &getLanguageParam() const;
virtual void setValueParam(const shared_ptr<BelCardValueParam> &param);
virtual const shared_ptr<BelCardValueParam> &getValueParam() const;
virtual void setPrefParam(const shared_ptr<BelCardPrefParam> &param);
virtual const shared_ptr<BelCardPrefParam> &getPrefParam() const;
virtual void setAlternativeIdParam(const shared_ptr<BelCardAlternativeIdParam> &param);
virtual const shared_ptr<BelCardAlternativeIdParam> &getAlternativeIdParam() const;
virtual void setParamIdParam(const shared_ptr<BelCardParamIdParam> &param);
virtual const shared_ptr<BelCardParamIdParam> &getParamIdParam() const;
virtual void setTypeParam(const shared_ptr<BelCardTypeParam> &param);
virtual const shared_ptr<BelCardTypeParam> &getTypeParam() const;
virtual void setMediaTypeParam(const shared_ptr<BelCardMediaTypeParam> &param);
virtual const shared_ptr<BelCardMediaTypeParam> &getMediaTypeParam() const;
virtual void setCALSCALEParam(const shared_ptr<BelCardCALSCALEParam> &param);
virtual const shared_ptr<BelCardCALSCALEParam> &getCALSCALEParam() const;
virtual void setSortAsParam(const shared_ptr<BelCardSortAsParam> &param);
virtual const shared_ptr<BelCardSortAsParam> &getSortAsParam() const;
virtual void setGeoParam(const shared_ptr<BelCardGeoParam> &param);
virtual const shared_ptr<BelCardGeoParam> &getGeoParam() const;
virtual void setTimezoneParam(const shared_ptr<BelCardTimezoneParam> &param);
virtual const shared_ptr<BelCardTimezoneParam> &getTimezoneParam() const;
virtual void addParam(const shared_ptr<BelCardParam> &param);
virtual const list<shared_ptr<BelCardParam>> &getParams() const;
......
......@@ -20,8 +20,17 @@ shared_ptr<BelCardAddress> BelCardAddress::parse(const string& input) {
void BelCardAddress::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("ADR", make_fn(&BelCardAddress::create))
->setCollector("group", make_sfn(&BelCardAddress::setGroup))
->setCollector("any-param", make_sfn(&BelCardAddress::addParam))
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("LABEL-param", make_sfn(&BelCardAddress::setLabelParam))
->setCollector("LANGUAGE-param", make_sfn(&BelCardProperty::setLanguageParam))
->setCollector("GEO-PARAM-param", make_sfn(&BelCardProperty::setGeoParam))
->setCollector("TZ-PARAM-param", make_sfn(&BelCardProperty::setTimezoneParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("ADR-pobox", make_sfn(&BelCardAddress::setPostOfficeBox))
->setCollector("ADR-ext", make_sfn(&BelCardAddress::setExtendedAddress))
->setCollector("ADR-street", make_sfn(&BelCardAddress::setStreet))
......@@ -83,6 +92,14 @@ void BelCardAddress::setCountry(const string &value) {
const string &BelCardAddress::getCountry() const {
return _country;
}
void BelCardAddress::setLabelParam(const shared_ptr<BelCardLabelParam> &param) {
_label_param = param;
_params.push_back(_label_param);
}
const shared_ptr<BelCardLabelParam> &BelCardAddress::getLabelParam() const {
return _label_param;
}
string BelCardAddress::serialize() const {
stringstream output;
......
......@@ -20,9 +20,15 @@ shared_ptr<BelCardFBURL> BelCardFBURL::parse(const string& input) {
void BelCardFBURL::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("FBURL", make_fn(&BelCardFBURL::create))
->setCollector("group", make_sfn(&BelCardFBURL::setGroup))
->setCollector("any-param", make_sfn(&BelCardFBURL::addParam))
->setCollector("FBURL-value", make_sfn(&BelCardFBURL::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("FBURL-value", make_sfn(&BelCardProperty::setValue));
}
BelCardFBURL::BelCardFBURL() : BelCardProperty() {
......@@ -45,9 +51,15 @@ shared_ptr<BelCardCALADRURI> BelCardCALADRURI::parse(const string& input) {
void BelCardCALADRURI::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("CALADRURI", make_fn(&BelCardCALADRURI::create))
->setCollector("group", make_sfn(&BelCardCALADRURI::setGroup))
->setCollector("any-param", make_sfn(&BelCardCALADRURI::addParam))
->setCollector("CALADRURI-value", make_sfn(&BelCardCALADRURI::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("CALADRURI-value", make_sfn(&BelCardProperty::setValue));
}
BelCardCALADRURI::BelCardCALADRURI() : BelCardProperty() {
......@@ -70,9 +82,15 @@ shared_ptr<BelCardCALURI> BelCardCALURI::parse(const string& input) {
void BelCardCALURI::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("CALURI", make_fn(&BelCardCALURI::create))
->setCollector("group", make_sfn(&BelCardCALURI::setGroup))
->setCollector("any-param", make_sfn(&BelCardCALURI::addParam))
->setCollector("CALURI-value", make_sfn(&BelCardCALURI::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("CALURI-value", make_sfn(&BelCardProperty::setValue));
}
BelCardCALURI::BelCardCALURI() : BelCardProperty() {
......
......@@ -20,9 +20,14 @@ shared_ptr<BelCardPhoneNumber> BelCardPhoneNumber::parse(const string& input) {
void BelCardPhoneNumber::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("TEL", make_fn(&BelCardPhoneNumber::create))
->setCollector("group", make_sfn(&BelCardPhoneNumber::setGroup))
->setCollector("any-param", make_sfn(&BelCardPhoneNumber::addParam))
->setCollector("TEL-value", make_sfn(&BelCardPhoneNumber::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("TEL-value", make_sfn(&BelCardProperty::setValue));
}
BelCardPhoneNumber::BelCardPhoneNumber() : BelCardProperty() {
......@@ -45,9 +50,14 @@ shared_ptr<BelCardEmail> BelCardEmail::parse(const string& input) {
void BelCardEmail::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("EMAIL", make_fn(&BelCardEmail::create))
->setCollector("group", make_sfn(&BelCardEmail::setGroup))
->setCollector("any-param", make_sfn(&BelCardEmail::addParam))
->setCollector("EMAIL-value", make_sfn(&BelCardEmail::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("EMAIL-value", make_sfn(&BelCardProperty::setValue));
}
BelCardEmail::BelCardEmail() : BelCardProperty() {
......@@ -70,9 +80,15 @@ shared_ptr<BelCardImpp> BelCardImpp::parse(const string& input) {
void BelCardImpp::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("IMPP", make_fn(&BelCardImpp::create))
->setCollector("group", make_sfn(&BelCardImpp::setGroup))
->setCollector("any-param", make_sfn(&BelCardImpp::addParam))
->setCollector("IMPP-value", make_sfn(&BelCardImpp::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("IMPP-value", make_sfn(&BelCardProperty::setValue));
}
BelCardImpp::BelCardImpp() : BelCardProperty() {
......@@ -95,9 +111,14 @@ shared_ptr<BelCardLang> BelCardLang::parse(const string& input) {
void BelCardLang::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("LANG", make_fn(&BelCardLang::create))
->setCollector("group", make_sfn(&BelCardLang::setGroup))
->setCollector("any-param", make_sfn(&BelCardLang::addParam))
->setCollector("LANG-value", make_sfn(&BelCardLang::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("LANG-value", make_sfn(&BelCardProperty::setValue));
}
BelCardLang::BelCardLang() : BelCardProperty() {
......
......@@ -20,9 +20,14 @@ shared_ptr<BelCardCategories> BelCardCategories::parse(const string& input) {
void BelCardCategories::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("CATEGORIES", make_fn(&BelCardCategories::create))
->setCollector("group", make_sfn(&BelCardCategories::setGroup))
->setCollector("any-param", make_sfn(&BelCardCategories::addParam))
->setCollector("CATEGORIES-value", make_sfn(&BelCardCategories::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("CATEGORIES-value", make_sfn(&BelCardProperty::setValue));
}
BelCardCategories::BelCardCategories() : BelCardProperty() {
......@@ -45,9 +50,15 @@ shared_ptr<BelCardNote> BelCardNote::parse(const string& input) {
void BelCardNote::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("NOTE", make_fn(&BelCardNote::create))
->setCollector("group", make_sfn(&BelCardNote::setGroup))
->setCollector("any-param", make_sfn(&BelCardNote::addParam))
->setCollector("NOTE-value", make_sfn(&BelCardNote::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("LANGUAGE-param", make_sfn(&BelCardProperty::setLanguageParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("NOTE-value", make_sfn(&BelCardProperty::setValue));
}
BelCardNote::BelCardNote() : BelCardProperty() {
......@@ -70,9 +81,10 @@ shared_ptr<BelCardProductId> BelCardProductId::parse(const string& input) {
void BelCardProductId::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("PRODID", make_fn(&BelCardProductId::create))
->setCollector("group", make_sfn(&BelCardProductId::setGroup))
->setCollector("any-param", make_sfn(&BelCardProductId::addParam))
->setCollector("PRODID-value", make_sfn(&BelCardProductId::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PRODID-value", make_sfn(&BelCardProperty::setValue));
}
BelCardProductId::BelCardProductId() : BelCardProperty() {
......@@ -95,9 +107,10 @@ shared_ptr<BelCardRevision> BelCardRevision::parse(const string& input) {
void BelCardRevision::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("REV", make_fn(&BelCardRevision::create))
->setCollector("group", make_sfn(&BelCardRevision::setGroup))
->setCollector("any-param", make_sfn(&BelCardRevision::addParam))
->setCollector("REV-value", make_sfn(&BelCardRevision::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("REV-value", make_sfn(&BelCardProperty::setValue));
}
BelCardRevision::BelCardRevision() : BelCardProperty() {
......@@ -120,9 +133,16 @@ shared_ptr<BelCardSound> BelCardSound::parse(const string& input) {
void BelCardSound::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("SOUND", make_fn(&BelCardSound::create))
->setCollector("group", make_sfn(&BelCardSound::setGroup))
->setCollector("any-param", make_sfn(&BelCardSound::addParam))
->setCollector("SOUND-value", make_sfn(&BelCardSound::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("LANGUAGE-param", make_sfn(&BelCardProperty::setLanguageParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("SOUND-value", make_sfn(&BelCardProperty::setValue));
}
BelCardSound::BelCardSound() : BelCardProperty() {
......@@ -145,9 +165,10 @@ shared_ptr<BelCardUniqueId> BelCardUniqueId::parse(const string& input) {
void BelCardUniqueId::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("UID", make_fn(&BelCardUniqueId::create))
->setCollector("group", make_sfn(&BelCardUniqueId::setGroup))
->setCollector("any-param", make_sfn(&BelCardUniqueId::addParam))
->setCollector("UID-value", make_sfn(&BelCardUniqueId::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("UID-value", make_sfn(&BelCardProperty::setValue));
}
BelCardUniqueId::BelCardUniqueId() : BelCardProperty() {
......@@ -170,9 +191,9 @@ shared_ptr<BelCardClientProductIdMap> BelCardClientProductIdMap::parse(const str
void BelCardClientProductIdMap::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("CLIENTPIDMAP", make_fn(&BelCardClientProductIdMap::create))
->setCollector("group", make_sfn(&BelCardClientProductIdMap::setGroup))
->setCollector("any-param", make_sfn(&BelCardClientProductIdMap::addParam))
->setCollector("CLIENTPIDMAP-value", make_sfn(&BelCardClientProductIdMap::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("CLIENTPIDMAP-value", make_sfn(&BelCardProperty::setValue));
}
BelCardClientProductIdMap::BelCardClientProductIdMap() : BelCardProperty() {
......@@ -195,9 +216,15 @@ shared_ptr<BelCardURL> BelCardURL::parse(const string& input) {
void BelCardURL::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("URL", make_fn(&BelCardURL::create))
->setCollector("group", make_sfn(&BelCardURL::setGroup))
->setCollector("any-param", make_sfn(&BelCardURL::addParam))
->setCollector("URL-value", make_sfn(&BelCardURL::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("URL-value", make_sfn(&BelCardProperty::setValue));
}
BelCardURL::BelCardURL() : BelCardProperty() {
......
......@@ -4,54 +4,60 @@ using namespace::std;
using namespace::belr;
using namespace::belcard;
shared_ptr<BelCardKind> BelCardKind::create() {
return BelCardGeneric::create<BelCardKind>();
shared_ptr<BelCardSource> BelCardSource::create() {
return BelCardGeneric::create<BelCardSource>();
}
shared_ptr<BelCardKind> BelCardKind::parse(const string& input) {
shared_ptr<BelCardSource> BelCardSource::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);
BelCardParam::setHandlerAndCollectors(&parser);
shared_ptr<BelCardGeneric> ret = parser.parseInput("KIND", input, NULL);
return dynamic_pointer_cast<BelCardKind>(ret);
shared_ptr<BelCardGeneric> ret = parser.parseInput("SOURCE", input, NULL);
return dynamic_pointer_cast<BelCardSource>(ret);
}
void BelCardKind::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("KIND", make_fn(&BelCardKind::create))
->setCollector("group", make_sfn(&BelCardKind::setGroup))
->setCollector("any-param", make_sfn(&BelCardKind::addParam))
->setCollector("KIND-value", make_sfn(&BelCardKind::setValue));
void BelCardSource::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("SOURCE", make_fn(&BelCardSource::create))
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("SOURCE-value", make_sfn(&BelCardProperty::setValue));
}
BelCardKind::BelCardKind() : BelCardProperty() {
setName("KIND");
BelCardSource::BelCardSource() : BelCardProperty() {
setName("SOURCE");
}
shared_ptr<BelCardSource> BelCardSource::create() {
return BelCardGeneric::create<BelCardSource>();
shared_ptr<BelCardKind> BelCardKind::create() {
return BelCardGeneric::create<BelCardKind>();
}
shared_ptr<BelCardSource> BelCardSource::parse(const string& input) {
shared_ptr<BelCardKind> BelCardKind::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);
BelCardParam::setHandlerAndCollectors(&parser);
shared_ptr<BelCardGeneric> ret = parser.parseInput("SOURCE", input, NULL);
return dynamic_pointer_cast<BelCardSource>(ret);
shared_ptr<BelCardGeneric> ret = parser.parseInput("KIND", input, NULL);
return dynamic_pointer_cast<BelCardKind>(ret);
}
void BelCardSource::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("SOURCE", make_fn(&BelCardSource::create))
->setCollector("group", make_sfn(&BelCardSource::setGroup))
->setCollector("any-param", make_sfn(&BelCardSource::addParam))
->setCollector("SOURCE-value", make_sfn(&BelCardSource::setValue));
void BelCardKind::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("KIND", make_fn(&BelCardKind::create))
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("KIND-value", make_sfn(&BelCardProperty::setValue));
}
BelCardSource::BelCardSource() : BelCardProperty() {
setName("SOURCE");
BelCardKind::BelCardKind() : BelCardProperty() {
setName("KIND");
}
shared_ptr<BelCardXML> BelCardXML::create() {
......@@ -70,9 +76,10 @@ shared_ptr<BelCardXML> BelCardXML::parse(const string& input) {
void BelCardXML::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("XML", make_fn(&BelCardXML::create))
->setCollector("group", make_sfn(&BelCardXML::setGroup))
->setCollector("any-param", make_sfn(&BelCardXML::addParam))
->setCollector("XML-value", make_sfn(&BelCardXML::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("XML-value", make_sfn(&BelCardProperty::setValue));
}
BelCardXML::BelCardXML() : BelCardProperty() {
......
......@@ -20,9 +20,15 @@ shared_ptr<BelCardTimezone> BelCardTimezone::parse(const string& input) {
void BelCardTimezone::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("TZ", make_fn(&BelCardTimezone::create))
->setCollector("group", make_sfn(&BelCardTimezone::setGroup))
->setCollector("any-param", make_sfn(&BelCardTimezone::addParam))
->setCollector("TZ-value", make_sfn(&BelCardTimezone::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
->setCollector("TZ-value", make_sfn(&BelCardProperty::setValue));
}
BelCardTimezone::BelCardTimezone() : BelCardProperty() {
......@@ -45,9 +51,15 @@ shared_ptr<BelCardGeo> BelCardGeo::parse(const string& input) {
void BelCardGeo::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("GEO", make_fn(&BelCardGeo::create))
->setCollector("group", make_sfn(&BelCardGeo::setGroup))
->setCollector("any-param", make_sfn(&BelCardGeo::addParam))
->setCollector("GEO-value", make_sfn(&BelCardGeo::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
->setCollector("GEO-value", make_sfn(&BelCardProperty::setValue));
}
BelCardGeo::BelCardGeo() : BelCardProperty() {
......
......@@ -20,9 +20,15 @@ shared_ptr<BelCardFullName> BelCardFullName::parse(const string& input) {
void BelCardFullName::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("FN", make_fn(&BelCardFullName::create))
->setCollector("group", make_sfn(&BelCardFullName::setGroup))
->setCollector("any-param", make_sfn(&BelCardFullName::addParam))
->setCollector("FN-value", make_sfn(&BelCardFullName::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("LANGUAGE-param", make_sfn(&BelCardProperty::setLanguageParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("FN-value", make_sfn(&BelCardProperty::setValue));
}
BelCardFullName::BelCardFullName() : BelCardProperty() {
......@@ -45,8 +51,12 @@ shared_ptr<BelCardName> BelCardName::parse(const string& input) {
void BelCardName::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("N", make_fn(&BelCardName::create))
->setCollector("group", make_sfn(&BelCardName::setGroup))
->setCollector("any-param", make_sfn(&BelCardName::addParam))
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("SORT-AS-param", make_sfn(&BelCardProperty::setSortAsParam))
->setCollector("LANGUAGE-param", make_sfn(&BelCardProperty::setLanguageParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("N-fn", make_sfn(&BelCardName::setFamilyName))
->setCollector("N-gn", make_sfn(&BelCardName::setGivenName))
->setCollector("N-an", make_sfn(&BelCardName::setAdditionalName))
......@@ -125,9 +135,15 @@ shared_ptr<BelCardNickname> BelCardNickname::parse(const string& input) {
void BelCardNickname::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("NICKNAME", make_fn(&BelCardNickname::create))
->setCollector("group", make_sfn(&BelCardNickname::setGroup))
->setCollector("any-param", make_sfn(&BelCardNickname::addParam))
->setCollector("NICKNAME-value", make_sfn(&BelCardNickname::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("LANGUAGE-param", make_sfn(&BelCardProperty::setLanguageParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("NICKNAME-value", make_sfn(&BelCardProperty::setValue));
}
BelCardNickname::BelCardNickname() : BelCardProperty() {
......@@ -150,9 +166,13 @@ shared_ptr<BelCardBirthday> BelCardBirthday::parse(const string& input) {
void BelCardBirthday::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("BDAY", make_fn(&BelCardBirthday::create))
->setCollector("group", make_sfn(&BelCardBirthday::setGroup))
->setCollector("any-param", make_sfn(&BelCardBirthday::addParam))
->setCollector("BDAY-value", make_sfn(&BelCardBirthday::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("LANGUAGE-param", make_sfn(&BelCardProperty::setLanguageParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("CALSCALE-param", make_sfn(&BelCardProperty::setCALSCALEParam))
->setCollector("BDAY-value", make_sfn(&BelCardProperty::setValue));
}
BelCardBirthday::BelCardBirthday() : BelCardProperty() {
......@@ -175,9 +195,12 @@ shared_ptr<BelCardAnniversary> BelCardAnniversary::parse(const string& input) {
void BelCardAnniversary::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("ANNIVERSARY", make_fn(&BelCardAnniversary::create))
->setCollector("group", make_sfn(&BelCardAnniversary::setGroup))
->setCollector("any-param", make_sfn(&BelCardAnniversary::addParam))
->setCollector("ANNIVERSARY-value", make_sfn(&BelCardAnniversary::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("CALSCALE-param", make_sfn(&BelCardProperty::setCALSCALEParam))
->setCollector("ANNIVERSARY-value", make_sfn(&BelCardProperty::setValue));
}
BelCardAnniversary::BelCardAnniversary() : BelCardProperty() {
......@@ -200,9 +223,10 @@ shared_ptr<BelCardGender> BelCardGender::parse(const string& input) {
void BelCardGender::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("GENDER", make_fn(&BelCardGender::create))
->setCollector("group", make_sfn(&BelCardGender::setGroup))
->setCollector("any-param", make_sfn(&BelCardGender::addParam))
->setCollector("GENDER-value", make_sfn(&BelCardGender::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("GENDER-value", make_sfn(&BelCardProperty::setValue));
}
BelCardGender::BelCardGender() : BelCardProperty() {
......@@ -225,9 +249,15 @@ shared_ptr<BelCardPhoto> BelCardPhoto::parse(const string& input) {
void BelCardPhoto::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("PHOTO", make_fn(&BelCardPhoto::create))
->setCollector("group", make_sfn(&BelCardPhoto::setGroup))
->setCollector("any-param", make_sfn(&BelCardPhoto::addParam))
->setCollector("PHOTO-value", make_sfn(&BelCardPhoto::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PHOTO-value", make_sfn(&BelCardProperty::setValue));
}
BelCardPhoto::BelCardPhoto() : BelCardProperty() {
......
......@@ -20,9 +20,15 @@ shared_ptr<BelCardTitle> BelCardTitle::parse(const string& input) {
void BelCardTitle::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("TITLE", make_fn(&BelCardTitle::create))
->setCollector("group", make_sfn(&BelCardTitle::setGroup))
->setCollector("any-param", make_sfn(&BelCardTitle::addParam))
->setCollector("TITLE-value", make_sfn(&BelCardTitle::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("LANGUAGE-param", make_sfn(&BelCardProperty::setLanguageParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("TITLE-value", make_sfn(&BelCardProperty::setValue));
}
BelCardTitle::BelCardTitle() : BelCardProperty() {
......@@ -45,9 +51,15 @@ shared_ptr<BelCardRole> BelCardRole::parse(const string& input) {
void BelCardRole::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("ROLE", make_fn(&BelCardRole::create))
->setCollector("group", make_sfn(&BelCardRole::setGroup))
->setCollector("any-param", make_sfn(&BelCardRole::addParam))
->setCollector("ROLE-value", make_sfn(&BelCardRole::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("LANGUAGE-param", make_sfn(&BelCardProperty::setLanguageParam))
->setCollector("PID-param", make_sfn(&BelCardProperty::setParamIdParam))
->setCollector("PREF-param", make_sfn(&BelCardProperty::setPrefParam))
->setCollector("TYPE-param", make_sfn(&BelCardProperty::setTypeParam))
->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
->setCollector("ROLE-value", make_sfn(&BelCardProperty::setValue));
}
BelCardRole::BelCardRole() : BelCardProperty() {
......@@ -70,9 +82,16 @@ shared_ptr<BelCardLogo> BelCardLogo::parse(const string& input) {
void BelCardLogo::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("LOGO", make_fn(&BelCardLogo::create))
->setCollector("group", make_sfn(&BelCardLogo::setGroup))
->setCollector("any-param", make_sfn(&BelCardLogo::addParam))
->setCollector("LOGO-value", make_sfn(&BelCardLogo::setValue));
->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
<