belcard_explanatory.cpp 7.66 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
	belcard_explanatory.cpp
	Copyright (C) 2015  Belledonne Communications SARL

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

19
#include "belcard/belcard.hpp"
20
#include <belr/parser-impl.cc>
21 22 23 24 25 26

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

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

void BelCardCategories::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
31
	parser->setHandler("CATEGORIES", make_fn(BelCardGeneric::create<BelCardCategories>))
32 33 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("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));
40 41 42 43 44 45 46
}

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

shared_ptr<BelCardNote> BelCardNote::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
47
	return BelCardProperty::parseProperty<BelCardNote>("NOTE", input);
48 49 50
}

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

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

shared_ptr<BelCardProductId> BelCardProductId::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
68
	return BelCardProperty::parseProperty<BelCardProductId>("PRODID", input);
69 70 71
}

void BelCardProductId::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
72
	parser->setHandler("PRODID", make_fn(BelCardGeneric::create<BelCardProductId>))
73 74 75 76
			->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));
77 78 79 80 81 82 83
}

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

shared_ptr<BelCardRevision> BelCardRevision::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
84
	return BelCardProperty::parseProperty<BelCardRevision>("REV", input);
85 86 87
}

void BelCardRevision::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
88
	parser->setHandler("REV", make_fn(BelCardGeneric::create<BelCardRevision>))
89 90 91 92
			->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));
93 94 95 96 97 98 99
}

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

shared_ptr<BelCardSound> BelCardSound::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
100
	return BelCardProperty::parseProperty<BelCardSound>("SOUND", input);
101 102 103
}

void BelCardSound::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
104
	parser->setHandler("SOUND", make_fn(BelCardGeneric::create<BelCardSound>))
105 106 107 108 109 110 111 112 113 114
			->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));
115 116 117 118 119 120 121
}

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

shared_ptr<BelCardUniqueId> BelCardUniqueId::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
122
	return BelCardProperty::parseProperty<BelCardUniqueId>("UID", input);
123 124 125
}

void BelCardUniqueId::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
126
	parser->setHandler("UID", make_fn(BelCardGeneric::create<BelCardUniqueId>))
127 128 129 130
			->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));
131 132 133 134 135 136 137
}

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

shared_ptr<BelCardClientProductIdMap> BelCardClientProductIdMap::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
138
	return BelCardProperty::parseProperty<BelCardClientProductIdMap>("CLIENTPIDMAP", input);
139 140 141
}

void BelCardClientProductIdMap::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
142
	parser->setHandler("CLIENTPIDMAP", make_fn(BelCardGeneric::create<BelCardClientProductIdMap>))
143 144 145
			->setCollector("group", make_sfn(&BelCardProperty::setGroup))
			->setCollector("any-param", make_sfn(&BelCardProperty::addParam))
			->setCollector("CLIENTPIDMAP-value", make_sfn(&BelCardProperty::setValue));
146 147 148 149 150 151 152
}

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

shared_ptr<BelCardURL> BelCardURL::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
153
	return BelCardProperty::parseProperty<BelCardURL>("URL", input);
154 155 156
}

void BelCardURL::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
157
	parser->setHandler("URL", make_fn(BelCardGeneric::create<BelCardURL>))
158 159 160 161 162 163 164 165 166
			->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));
167 168 169 170 171
}

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