belcard_explanatory.cpp 10.4 KB
Newer Older
1 2 3 4 5 6 7
#include "belcard/belcard_explanatory.hpp"

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

shared_ptr<BelCardCategories> BelCardCategories::create() {
8
	return BelCardGeneric::create<BelCardCategories>();
9 10 11 12 13 14 15 16 17 18 19 20 21 22
}

shared_ptr<BelCardCategories> BelCardCategories::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("CATEGORIES", input, NULL);
	return dynamic_pointer_cast<BelCardCategories>(ret);
}

void BelCardCategories::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
	parser->setHandler("CATEGORIES", make_fn(&BelCardCategories::create))
23 24 25 26 27 28 29 30
			->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));
31 32 33 34 35 36 37
}

BelCardCategories::BelCardCategories() : BelCardProperty() {
	setName("CATEGORIES");
}

shared_ptr<BelCardNote> BelCardNote::create() {
38
	return BelCardGeneric::create<BelCardNote>();
39 40 41 42 43 44 45 46 47 48 49 50 51 52
}

shared_ptr<BelCardNote> BelCardNote::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("NOTE", input, NULL);
	return dynamic_pointer_cast<BelCardNote>(ret);
}

void BelCardNote::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
	parser->setHandler("NOTE", make_fn(&BelCardNote::create))
53 54 55 56 57 58 59 60 61
			->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));
62 63 64 65 66 67 68
}

BelCardNote::BelCardNote() : BelCardProperty() {
	setName("NOTE");
}

shared_ptr<BelCardProductId> BelCardProductId::create() {
69
	return BelCardGeneric::create<BelCardProductId>();
70 71 72 73 74 75 76 77 78 79 80 81 82 83
}

shared_ptr<BelCardProductId> BelCardProductId::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("PRODID", input, NULL);
	return dynamic_pointer_cast<BelCardProductId>(ret);
}

void BelCardProductId::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
	parser->setHandler("PRODID", make_fn(&BelCardProductId::create))
84 85 86 87
			->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));
88 89 90 91 92 93 94
}

BelCardProductId::BelCardProductId() : BelCardProperty() {
	setName("PRODID");
}

shared_ptr<BelCardRevision> BelCardRevision::create() {
95
	return BelCardGeneric::create<BelCardRevision>();
96 97 98 99 100 101 102 103 104 105 106 107 108 109
}

shared_ptr<BelCardRevision> BelCardRevision::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("REV", input, NULL);
	return dynamic_pointer_cast<BelCardRevision>(ret);
}

void BelCardRevision::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
	parser->setHandler("REV", make_fn(&BelCardRevision::create))
110 111 112 113
			->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));
114 115 116 117 118 119 120
}

BelCardRevision::BelCardRevision() : BelCardProperty() {
	setName("REV");
}

shared_ptr<BelCardSound> BelCardSound::create() {
121
	return BelCardGeneric::create<BelCardSound>();
122 123 124 125 126 127 128 129 130 131 132 133 134 135
}

shared_ptr<BelCardSound> BelCardSound::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("SOUND", input, NULL);
	return dynamic_pointer_cast<BelCardSound>(ret);
}

void BelCardSound::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
	parser->setHandler("SOUND", make_fn(&BelCardSound::create))
136 137 138 139 140 141 142 143 144 145
			->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));
146 147 148 149 150 151 152
}

BelCardSound::BelCardSound() : BelCardProperty() {
	setName("SOUND");
}

shared_ptr<BelCardUniqueId> BelCardUniqueId::create() {
153
	return BelCardGeneric::create<BelCardUniqueId>();
154 155 156 157 158 159 160 161 162 163 164 165 166 167
}

shared_ptr<BelCardUniqueId> BelCardUniqueId::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("UID", input, NULL);
	return dynamic_pointer_cast<BelCardUniqueId>(ret);
}

void BelCardUniqueId::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
	parser->setHandler("UID", make_fn(&BelCardUniqueId::create))
168 169 170 171
			->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));
172 173 174 175 176 177 178
}

BelCardUniqueId::BelCardUniqueId() : BelCardProperty() {
	setName("UID");
}

shared_ptr<BelCardClientProductIdMap> BelCardClientProductIdMap::create() {
179
	return BelCardGeneric::create<BelCardClientProductIdMap>();
180 181 182 183 184 185 186 187 188 189 190 191 192 193
}

shared_ptr<BelCardClientProductIdMap> BelCardClientProductIdMap::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("CLIENTPIDMAP", input, NULL);
	return dynamic_pointer_cast<BelCardClientProductIdMap>(ret);
}

void BelCardClientProductIdMap::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
	parser->setHandler("CLIENTPIDMAP", make_fn(&BelCardClientProductIdMap::create))
194 195 196
			->setCollector("group", make_sfn(&BelCardProperty::setGroup))
			->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
			->setCollector("CLIENTPIDMAP-value", make_sfn(&BelCardProperty::setValue));
197 198 199 200 201 202 203
}

BelCardClientProductIdMap::BelCardClientProductIdMap() : BelCardProperty() {
	setName("CLIENTPIDMAP");
}

shared_ptr<BelCardURL> BelCardURL::create() {
204
	return BelCardGeneric::create<BelCardURL>();
205 206 207 208 209 210 211 212 213 214 215 216 217 218
}

shared_ptr<BelCardURL> BelCardURL::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("URL", input, NULL);
	return dynamic_pointer_cast<BelCardURL>(ret);
}

void BelCardURL::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
	parser->setHandler("URL", make_fn(&BelCardURL::create))
219 220 221 222 223 224 225 226 227
			->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));
228 229 230 231 232
}

BelCardURL::BelCardURL() : BelCardProperty() {
	setName("URL");
}