belcard_identification.cpp 7.57 KB
Newer Older
1 2 3 4 5 6
#include "belcard/belcard_identification.hpp"

using namespace::std;
using namespace::belr;
using namespace::belcard;

Sylvain Berfini's avatar
Sylvain Berfini committed
7
shared_ptr<BelCardFullName> BelCardFullName::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
8
	return BelCardProperty::parseProperty<BelCardFullName>("FN", input);
9 10
}

Sylvain Berfini's avatar
Sylvain Berfini committed
11
void BelCardFullName::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
12
	parser->setHandler("FN", make_fn(BelCardGeneric::create<BelCardFullName>))
13 14 15 16 17 18 19 20 21
			->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));
22 23
}

Sylvain Berfini's avatar
Sylvain Berfini committed
24
BelCardFullName::BelCardFullName() : BelCardProperty() {
25 26 27
	setName("FN");
}

Sylvain Berfini's avatar
Sylvain Berfini committed
28
shared_ptr<BelCardName> BelCardName::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
29
	return BelCardProperty::parseProperty<BelCardName>("N", input);
30 31
}

Sylvain Berfini's avatar
Sylvain Berfini committed
32
void BelCardName::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
33
	parser->setHandler("N", make_fn(BelCardGeneric::create<BelCardName>))
34 35 36 37 38 39
			->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))
Sylvain Berfini's avatar
Sylvain Berfini committed
40 41 42 43 44
			->setCollector("N-fn", make_sfn(&BelCardName::setFamilyName))
			->setCollector("N-gn", make_sfn(&BelCardName::setGivenName))
			->setCollector("N-an", make_sfn(&BelCardName::setAdditionalName))
			->setCollector("N-prefixes", make_sfn(&BelCardName::setPrefixes))
			->setCollector("N-suffixes", make_sfn(&BelCardName::setSuffixes));
45 46
}

Sylvain Berfini's avatar
Sylvain Berfini committed
47
BelCardName::BelCardName() : BelCardProperty() {
48 49 50
	setName("N");
}

Sylvain Berfini's avatar
Sylvain Berfini committed
51
void BelCardName::setFamilyName(const string &value) {
52 53
	_family_name = value;
}
Sylvain Berfini's avatar
Sylvain Berfini committed
54
const string &BelCardName::getFamilyName() const {
55 56 57
	return _family_name;
}

Sylvain Berfini's avatar
Sylvain Berfini committed
58
void BelCardName::setGivenName(const string &value) {
59 60
	_given_name = value;
}
Sylvain Berfini's avatar
Sylvain Berfini committed
61
const string &BelCardName::getGivenName() const {
62 63 64
	return _given_name;
}

Sylvain Berfini's avatar
Sylvain Berfini committed
65
void BelCardName::setAdditionalName(const string &value) {
66 67
	_additional_name = value;
}
Sylvain Berfini's avatar
Sylvain Berfini committed
68
const string &BelCardName::getAdditionalName() const {
69 70 71
	return _additional_name;
}

Sylvain Berfini's avatar
Sylvain Berfini committed
72
void BelCardName::setPrefixes(const string &value) {
73 74
	_prefixes = value;
}
Sylvain Berfini's avatar
Sylvain Berfini committed
75
const string &BelCardName::getPrefixes() const {
76 77 78
	return _prefixes;
}

Sylvain Berfini's avatar
Sylvain Berfini committed
79
void BelCardName::setSuffixes(const string &value) {
80 81
	_suffixes = value;
}
Sylvain Berfini's avatar
Sylvain Berfini committed
82
const string &BelCardName::getSuffixes() const {
83 84 85 86
	return _suffixes;
}

shared_ptr<BelCardNickname> BelCardNickname::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
87
	return BelCardProperty::parseProperty<BelCardNickname>("NICKNAME", input);
88 89 90
}

void BelCardNickname::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
91
	parser->setHandler("NICKNAME", make_fn(BelCardGeneric::create<BelCardNickname>))
92 93 94 95 96 97 98 99 100
			->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));
101 102 103 104 105 106 107
}

BelCardNickname::BelCardNickname() : BelCardProperty() {
	setName("NICKNAME");
}

shared_ptr<BelCardBirthday> BelCardBirthday::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
108
	return BelCardProperty::parseProperty<BelCardBirthday>("BDAY", input);
109 110 111
}

void BelCardBirthday::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
112
	parser->setHandler("BDAY", make_fn(BelCardGeneric::create<BelCardBirthday>))
113 114 115 116 117 118 119
			->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));
120 121 122 123 124 125 126
}

BelCardBirthday::BelCardBirthday() : BelCardProperty() {
	setName("BDAY");
}

shared_ptr<BelCardAnniversary> BelCardAnniversary::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
127
	return BelCardProperty::parseProperty<BelCardAnniversary>("ANNIVERSARY", input);
128 129 130
}

void BelCardAnniversary::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
131
	parser->setHandler("ANNIVERSARY", make_fn(BelCardGeneric::create<BelCardAnniversary>))
132 133 134 135 136 137
			->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));
138 139 140 141 142 143 144
}

BelCardAnniversary::BelCardAnniversary() : BelCardProperty() {
	setName("ANNIVERSARY");
}

shared_ptr<BelCardGender> BelCardGender::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
145
	return BelCardProperty::parseProperty<BelCardGender>("GENDER", input);
146 147 148
}

void BelCardGender::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
149
	parser->setHandler("GENDER", make_fn(BelCardGeneric::create<BelCardGender>))
150 151 152 153
			->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));
154 155 156 157 158 159 160
}

BelCardGender::BelCardGender() : BelCardProperty() {
	setName("GENDER");
}

shared_ptr<BelCardPhoto> BelCardPhoto::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
161
	return BelCardProperty::parseProperty<BelCardPhoto>("PHOTO", input);
162 163 164
}

void BelCardPhoto::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
165
	parser->setHandler("PHOTO", make_fn(BelCardGeneric::create<BelCardPhoto>))
166 167 168 169 170 171 172 173 174
			->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));
175 176 177 178 179
}

BelCardPhoto::BelCardPhoto() : BelCardProperty() {
	setName("PHOTO");
}