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 { ...@@ -21,6 +21,7 @@ namespace belcard {
string _region; string _region;
string _postal_code; string _postal_code;
string _country; string _country;
shared_ptr<BelCardLabelParam> _label_param;
public: public:
static shared_ptr<BelCardAddress> create(); static shared_ptr<BelCardAddress> create();
...@@ -50,6 +51,9 @@ namespace belcard { ...@@ -50,6 +51,9 @@ namespace belcard {
void setCountry(const string &value); void setCountry(const string &value);
const string &getCountry() const; const string &getCountry() const;
void setLabelParam(const shared_ptr<BelCardLabelParam> &param);
const shared_ptr<BelCardLabelParam> &getLabelParam() const;
string serialize() const; string serialize() const;
}; };
} }
......
...@@ -20,7 +20,17 @@ namespace belcard { ...@@ -20,7 +20,17 @@ namespace belcard {
string _group; string _group;
string _name; string _name;
string _value; string _value;
shared_ptr<BelCardLanguageParam> _lang_param;
shared_ptr<BelCardValueParam> _value_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; list<shared_ptr<BelCardParam>> _params;
public: public:
...@@ -44,7 +54,38 @@ namespace belcard { ...@@ -44,7 +54,38 @@ namespace belcard {
virtual void setValue(const string &value); virtual void setValue(const string &value);
virtual const string &getValue() const; 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 void addParam(const shared_ptr<BelCardParam> &param);
virtual const list<shared_ptr<BelCardParam>> &getParams() const; virtual const list<shared_ptr<BelCardParam>> &getParams() const;
......
...@@ -20,8 +20,17 @@ shared_ptr<BelCardAddress> BelCardAddress::parse(const string& input) { ...@@ -20,8 +20,17 @@ shared_ptr<BelCardAddress> BelCardAddress::parse(const string& input) {
void BelCardAddress::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardAddress::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("ADR", make_fn(&BelCardAddress::create)) parser->setHandler("ADR", make_fn(&BelCardAddress::create))
->setCollector("group", make_sfn(&BelCardAddress::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardAddress::addParam)) ->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-pobox", make_sfn(&BelCardAddress::setPostOfficeBox))
->setCollector("ADR-ext", make_sfn(&BelCardAddress::setExtendedAddress)) ->setCollector("ADR-ext", make_sfn(&BelCardAddress::setExtendedAddress))
->setCollector("ADR-street", make_sfn(&BelCardAddress::setStreet)) ->setCollector("ADR-street", make_sfn(&BelCardAddress::setStreet))
...@@ -83,6 +92,14 @@ void BelCardAddress::setCountry(const string &value) { ...@@ -83,6 +92,14 @@ void BelCardAddress::setCountry(const string &value) {
const string &BelCardAddress::getCountry() const { const string &BelCardAddress::getCountry() const {
return _country; 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 { string BelCardAddress::serialize() const {
stringstream output; stringstream output;
......
...@@ -20,9 +20,15 @@ shared_ptr<BelCardFBURL> BelCardFBURL::parse(const string& input) { ...@@ -20,9 +20,15 @@ shared_ptr<BelCardFBURL> BelCardFBURL::parse(const string& input) {
void BelCardFBURL::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardFBURL::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("FBURL", make_fn(&BelCardFBURL::create)) parser->setHandler("FBURL", make_fn(&BelCardFBURL::create))
->setCollector("group", make_sfn(&BelCardFBURL::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardFBURL::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("FBURL-value", make_sfn(&BelCardFBURL::setValue)); ->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() { BelCardFBURL::BelCardFBURL() : BelCardProperty() {
...@@ -45,9 +51,15 @@ shared_ptr<BelCardCALADRURI> BelCardCALADRURI::parse(const string& input) { ...@@ -45,9 +51,15 @@ shared_ptr<BelCardCALADRURI> BelCardCALADRURI::parse(const string& input) {
void BelCardCALADRURI::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardCALADRURI::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("CALADRURI", make_fn(&BelCardCALADRURI::create)) parser->setHandler("CALADRURI", make_fn(&BelCardCALADRURI::create))
->setCollector("group", make_sfn(&BelCardCALADRURI::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardCALADRURI::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("CALADRURI-value", make_sfn(&BelCardCALADRURI::setValue)); ->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() { BelCardCALADRURI::BelCardCALADRURI() : BelCardProperty() {
...@@ -70,9 +82,15 @@ shared_ptr<BelCardCALURI> BelCardCALURI::parse(const string& input) { ...@@ -70,9 +82,15 @@ shared_ptr<BelCardCALURI> BelCardCALURI::parse(const string& input) {
void BelCardCALURI::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardCALURI::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("CALURI", make_fn(&BelCardCALURI::create)) parser->setHandler("CALURI", make_fn(&BelCardCALURI::create))
->setCollector("group", make_sfn(&BelCardCALURI::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardCALURI::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("CALURI-value", make_sfn(&BelCardCALURI::setValue)); ->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() { BelCardCALURI::BelCardCALURI() : BelCardProperty() {
......
...@@ -20,9 +20,14 @@ shared_ptr<BelCardPhoneNumber> BelCardPhoneNumber::parse(const string& input) { ...@@ -20,9 +20,14 @@ shared_ptr<BelCardPhoneNumber> BelCardPhoneNumber::parse(const string& input) {
void BelCardPhoneNumber::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardPhoneNumber::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("TEL", make_fn(&BelCardPhoneNumber::create)) parser->setHandler("TEL", make_fn(&BelCardPhoneNumber::create))
->setCollector("group", make_sfn(&BelCardPhoneNumber::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardPhoneNumber::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("TEL-value", make_sfn(&BelCardPhoneNumber::setValue)); ->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() { BelCardPhoneNumber::BelCardPhoneNumber() : BelCardProperty() {
...@@ -45,9 +50,14 @@ shared_ptr<BelCardEmail> BelCardEmail::parse(const string& input) { ...@@ -45,9 +50,14 @@ shared_ptr<BelCardEmail> BelCardEmail::parse(const string& input) {
void BelCardEmail::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardEmail::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("EMAIL", make_fn(&BelCardEmail::create)) parser->setHandler("EMAIL", make_fn(&BelCardEmail::create))
->setCollector("group", make_sfn(&BelCardEmail::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardEmail::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("EMAIL-value", make_sfn(&BelCardEmail::setValue)); ->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() { BelCardEmail::BelCardEmail() : BelCardProperty() {
...@@ -70,9 +80,15 @@ shared_ptr<BelCardImpp> BelCardImpp::parse(const string& input) { ...@@ -70,9 +80,15 @@ shared_ptr<BelCardImpp> BelCardImpp::parse(const string& input) {
void BelCardImpp::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardImpp::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("IMPP", make_fn(&BelCardImpp::create)) parser->setHandler("IMPP", make_fn(&BelCardImpp::create))
->setCollector("group", make_sfn(&BelCardImpp::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardImpp::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("IMPP-value", make_sfn(&BelCardImpp::setValue)); ->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() { BelCardImpp::BelCardImpp() : BelCardProperty() {
...@@ -95,9 +111,14 @@ shared_ptr<BelCardLang> BelCardLang::parse(const string& input) { ...@@ -95,9 +111,14 @@ shared_ptr<BelCardLang> BelCardLang::parse(const string& input) {
void BelCardLang::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardLang::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("LANG", make_fn(&BelCardLang::create)) parser->setHandler("LANG", make_fn(&BelCardLang::create))
->setCollector("group", make_sfn(&BelCardLang::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardLang::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("LANG-value", make_sfn(&BelCardLang::setValue)); ->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() { BelCardLang::BelCardLang() : BelCardProperty() {
......
...@@ -20,9 +20,14 @@ shared_ptr<BelCardCategories> BelCardCategories::parse(const string& input) { ...@@ -20,9 +20,14 @@ shared_ptr<BelCardCategories> BelCardCategories::parse(const string& input) {
void BelCardCategories::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardCategories::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("CATEGORIES", make_fn(&BelCardCategories::create)) parser->setHandler("CATEGORIES", make_fn(&BelCardCategories::create))
->setCollector("group", make_sfn(&BelCardCategories::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardCategories::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("CATEGORIES-value", make_sfn(&BelCardCategories::setValue)); ->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() { BelCardCategories::BelCardCategories() : BelCardProperty() {
...@@ -45,9 +50,15 @@ shared_ptr<BelCardNote> BelCardNote::parse(const string& input) { ...@@ -45,9 +50,15 @@ shared_ptr<BelCardNote> BelCardNote::parse(const string& input) {
void BelCardNote::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardNote::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("NOTE", make_fn(&BelCardNote::create)) parser->setHandler("NOTE", make_fn(&BelCardNote::create))
->setCollector("group", make_sfn(&BelCardNote::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardNote::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("NOTE-value", make_sfn(&BelCardNote::setValue)); ->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() { BelCardNote::BelCardNote() : BelCardProperty() {
...@@ -70,9 +81,10 @@ shared_ptr<BelCardProductId> BelCardProductId::parse(const string& input) { ...@@ -70,9 +81,10 @@ shared_ptr<BelCardProductId> BelCardProductId::parse(const string& input) {
void BelCardProductId::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardProductId::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("PRODID", make_fn(&BelCardProductId::create)) parser->setHandler("PRODID", make_fn(&BelCardProductId::create))
->setCollector("group", make_sfn(&BelCardProductId::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardProductId::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("PRODID-value", make_sfn(&BelCardProductId::setValue)); ->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("PRODID-value", make_sfn(&BelCardProperty::setValue));
} }
BelCardProductId::BelCardProductId() : BelCardProperty() { BelCardProductId::BelCardProductId() : BelCardProperty() {
...@@ -95,9 +107,10 @@ shared_ptr<BelCardRevision> BelCardRevision::parse(const string& input) { ...@@ -95,9 +107,10 @@ shared_ptr<BelCardRevision> BelCardRevision::parse(const string& input) {
void BelCardRevision::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardRevision::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("REV", make_fn(&BelCardRevision::create)) parser->setHandler("REV", make_fn(&BelCardRevision::create))
->setCollector("group", make_sfn(&BelCardRevision::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardRevision::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("REV-value", make_sfn(&BelCardRevision::setValue)); ->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("REV-value", make_sfn(&BelCardProperty::setValue));
} }
BelCardRevision::BelCardRevision() : BelCardProperty() { BelCardRevision::BelCardRevision() : BelCardProperty() {
...@@ -120,9 +133,16 @@ shared_ptr<BelCardSound> BelCardSound::parse(const string& input) { ...@@ -120,9 +133,16 @@ shared_ptr<BelCardSound> BelCardSound::parse(const string& input) {
void BelCardSound::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardSound::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("SOUND", make_fn(&BelCardSound::create)) parser->setHandler("SOUND", make_fn(&BelCardSound::create))
->setCollector("group", make_sfn(&BelCardSound::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardSound::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("SOUND-value", make_sfn(&BelCardSound::setValue)); ->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() { BelCardSound::BelCardSound() : BelCardProperty() {
...@@ -145,9 +165,10 @@ shared_ptr<BelCardUniqueId> BelCardUniqueId::parse(const string& input) { ...@@ -145,9 +165,10 @@ shared_ptr<BelCardUniqueId> BelCardUniqueId::parse(const string& input) {
void BelCardUniqueId::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardUniqueId::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("UID", make_fn(&BelCardUniqueId::create)) parser->setHandler("UID", make_fn(&BelCardUniqueId::create))
->setCollector("group", make_sfn(&BelCardUniqueId::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardUniqueId::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("UID-value", make_sfn(&BelCardUniqueId::setValue)); ->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("UID-value", make_sfn(&BelCardProperty::setValue));
} }
BelCardUniqueId::BelCardUniqueId() : BelCardProperty() { BelCardUniqueId::BelCardUniqueId() : BelCardProperty() {
...@@ -170,9 +191,9 @@ shared_ptr<BelCardClientProductIdMap> BelCardClientProductIdMap::parse(const str ...@@ -170,9 +191,9 @@ shared_ptr<BelCardClientProductIdMap> BelCardClientProductIdMap::parse(const str
void BelCardClientProductIdMap::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardClientProductIdMap::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("CLIENTPIDMAP", make_fn(&BelCardClientProductIdMap::create)) parser->setHandler("CLIENTPIDMAP", make_fn(&BelCardClientProductIdMap::create))
->setCollector("group", make_sfn(&BelCardClientProductIdMap::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardClientProductIdMap::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("CLIENTPIDMAP-value", make_sfn(&BelCardClientProductIdMap::setValue)); ->setCollector("CLIENTPIDMAP-value", make_sfn(&BelCardProperty::setValue));
} }
BelCardClientProductIdMap::BelCardClientProductIdMap() : BelCardProperty() { BelCardClientProductIdMap::BelCardClientProductIdMap() : BelCardProperty() {
...@@ -195,9 +216,15 @@ shared_ptr<BelCardURL> BelCardURL::parse(const string& input) { ...@@ -195,9 +216,15 @@ shared_ptr<BelCardURL> BelCardURL::parse(const string& input) {
void BelCardURL::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardURL::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("URL", make_fn(&BelCardURL::create)) parser->setHandler("URL", make_fn(&BelCardURL::create))
->setCollector("group", make_sfn(&BelCardURL::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardURL::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("URL-value", make_sfn(&BelCardURL::setValue)); ->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() { BelCardURL::BelCardURL() : BelCardProperty() {
......
...@@ -4,54 +4,60 @@ using namespace::std; ...@@ -4,54 +4,60 @@ using namespace::std;
using namespace::belr; using namespace::belr;
using namespace::belcard; using namespace::belcard;
shared_ptr<BelCardKind> BelCardKind::create() { shared_ptr<BelCardSource> BelCardSource::create() {
return BelCardGeneric::create<BelCardKind>(); return BelCardGeneric::create<BelCardSource>();
} }
shared_ptr<BelCardKind> BelCardKind::parse(const string& input) { shared_ptr<BelCardSource> BelCardSource::parse(const string& input) {
ABNFGrammarBuilder grammar_builder; ABNFGrammarBuilder grammar_builder;
shared_ptr<Grammar> grammar = grammar_builder.createFromAbnf((const char*)vcard_grammar, make_shared<CoreRules>()); shared_ptr<Grammar> grammar = grammar_builder.createFromAbnf((const char*)vcard_grammar, make_shared<CoreRules>());
Parser<shared_ptr<BelCardGeneric>> parser(grammar); Parser<shared_ptr<BelCardGeneric>> parser(grammar);
setHandlerAndCollectors(&parser); setHandlerAndCollectors(&parser);
BelCardParam::setHandlerAndCollectors(&parser); BelCardParam::setHandlerAndCollectors(&parser);
shared_ptr<BelCardGeneric> ret = parser.parseInput("KIND", input, NULL); shared_ptr<BelCardGeneric> ret = parser.parseInput("SOURCE", input, NULL);
return dynamic_pointer_cast<BelCardKind>(ret); return dynamic_pointer_cast<BelCardSource>(ret);
} }
void BelCardKind::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardSource::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("KIND", make_fn(&BelCardKind::create)) parser->setHandler("SOURCE", make_fn(&BelCardSource::create))
->setCollector("group", make_sfn(&BelCardKind::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardKind::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("KIND-value", make_sfn(&BelCardKind::setValue)); ->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() { BelCardSource::BelCardSource() : BelCardProperty() {
setName("KIND"); setName("SOURCE");
} }
shared_ptr<BelCardSource> BelCardSource::create() { shared_ptr<BelCardKind> BelCardKind::create() {
return BelCardGeneric::create<BelCardSource>(); return BelCardGeneric::create<BelCardKind>();
} }
shared_ptr<BelCardSource> BelCardSource::parse(const string& input) { shared_ptr<BelCardKind> BelCardKind::parse(const string& input) {
ABNFGrammarBuilder grammar_builder; ABNFGrammarBuilder grammar_builder;
shared_ptr<Grammar> grammar = grammar_builder.createFromAbnf((const char*)vcard_grammar, make_shared<CoreRules>()); shared_ptr<Grammar> grammar = grammar_builder.createFromAbnf((const char*)vcard_grammar, make_shared<CoreRules>());
Parser<shared_ptr<BelCardGeneric>> parser(grammar); Parser<shared_ptr<BelCardGeneric>> parser(grammar);
setHandlerAndCollectors(&parser); setHandlerAndCollectors(&parser);
BelCardParam::setHandlerAndCollectors(&parser); BelCardParam::setHandlerAndCollectors(&parser);
shared_ptr<BelCardGeneric> ret = parser.parseInput("SOURCE", input, NULL); shared_ptr<BelCardGeneric> ret = parser.parseInput("KIND", input, NULL);
return dynamic_pointer_cast<BelCardSource>(ret); return dynamic_pointer_cast<BelCardKind>(ret);
} }
void BelCardSource::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardKind::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("SOURCE", make_fn(&BelCardSource::create)) parser->setHandler("KIND", make_fn(&BelCardKind::create))
->setCollector("group", make_sfn(&BelCardSource::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardSource::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("SOURCE-value", make_sfn(&BelCardSource::setValue)); ->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("KIND-value", make_sfn(&BelCardProperty::setValue));
} }
BelCardSource::BelCardSource() : BelCardProperty() { BelCardKind::BelCardKind() : BelCardProperty() {
setName("SOURCE"); setName("KIND");
} }
shared_ptr<BelCardXML> BelCardXML::create() { shared_ptr<BelCardXML> BelCardXML::create() {
...@@ -70,9 +76,10 @@ shared_ptr<BelCardXML> BelCardXML::parse(const string& input) { ...@@ -70,9 +76,10 @@ shared_ptr<BelCardXML> BelCardXML::parse(const string& input) {
void BelCardXML::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardXML::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("XML", make_fn(&BelCardXML::create)) parser->setHandler("XML", make_fn(&BelCardXML::create))
->setCollector("group", make_sfn(&BelCardXML::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardXML::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("XML-value", make_sfn(&BelCardXML::setValue)); ->setCollector("VALUE-param", make_sfn(&BelCardProperty::setValueParam))
->setCollector("XML-value", make_sfn(&BelCardProperty::setValue));
} }
BelCardXML::BelCardXML() : BelCardProperty() { BelCardXML::BelCardXML() : BelCardProperty() {
......
...@@ -20,9 +20,15 @@ shared_ptr<BelCardTimezone> BelCardTimezone::parse(const string& input) { ...@@ -20,9 +20,15 @@ shared_ptr<BelCardTimezone> BelCardTimezone::parse(const string& input) {
void BelCardTimezone::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardTimezone::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("TZ", make_fn(&BelCardTimezone::create)) parser->setHandler("TZ", make_fn(&BelCardTimezone::create))
->setCollector("group", make_sfn(&BelCardTimezone::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardTimezone::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("TZ-value", make_sfn(&BelCardTimezone::setValue)); ->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() { BelCardTimezone::BelCardTimezone() : BelCardProperty() {
...@@ -45,9 +51,15 @@ shared_ptr<BelCardGeo> BelCardGeo::parse(const string& input) { ...@@ -45,9 +51,15 @@ shared_ptr<BelCardGeo> BelCardGeo::parse(const string& input) {
void BelCardGeo::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardGeo::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("GEO", make_fn(&BelCardGeo::create)) parser->setHandler("GEO", make_fn(&BelCardGeo::create))
->setCollector("group", make_sfn(&BelCardGeo::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardGeo::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("GEO-value", make_sfn(&BelCardGeo::setValue)); ->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() { BelCardGeo::BelCardGeo() : BelCardProperty() {
......
...@@ -20,9 +20,15 @@ shared_ptr<BelCardFullName> BelCardFullName::parse(const string& input) { ...@@ -20,9 +20,15 @@ shared_ptr<BelCardFullName> BelCardFullName::parse(const string& input) {
void BelCardFullName::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardFullName::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("FN", make_fn(&BelCardFullName::create)) parser->setHandler("FN", make_fn(&BelCardFullName::create))
->setCollector("group", make_sfn(&BelCardFullName::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardFullName::addParam)) ->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
->setCollector("FN-value", make_sfn(&BelCardFullName::setValue)); ->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() { BelCardFullName::BelCardFullName() : BelCardProperty() {
...@@ -45,8 +51,12 @@ shared_ptr<BelCardName> BelCardName::parse(const string& input) { ...@@ -45,8 +51,12 @@ shared_ptr<BelCardName> BelCardName::parse(const string& input) {
void BelCardName::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardName::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("N", make_fn(&BelCardName::create)) parser->setHandler("N", make_fn(&BelCardName::create))
->setCollector("group", make_sfn(&BelCardName::setGroup)) ->setCollector("group", make_sfn(&BelCardProperty::setGroup))
->setCollector("any-param", make_sfn(&BelCardName::addParam)) ->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-fn", make_sfn(&BelCardName::setFamilyName))
->setCollector("N-gn", make_sfn(&BelCardName::setGivenName)) ->setCollector("N-gn", make_sfn(&BelCardName::setGivenName))
->setCollector("N-an", make_sfn(&BelCardName::setAdditionalName)) ->setCollector("N-an", make_sfn(&BelCardName::setAdditionalName))
...@@ -125,9 +135,15 @@ shared_ptr<BelCardNickname> BelCardNickname::parse(const string& input) { ...@@ -125,9 +135,15 @@ shared_ptr<BelCardNickname> BelCardNickname::parse(const string& input) {
void BelCardNickname::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) { void BelCardNickname::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {