belcard_general.cpp 3.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
	belcard_general.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

21 22 23 24 25

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

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

30
void BelCardSource::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
31
	parser->setHandler("SOURCE", make_fn(BelCardGeneric::create<BelCardSource>))
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("MEDIATYPE-param", make_sfn(&BelCardProperty::setMediaTypeParam))
			->setCollector("ALTID-param", make_sfn(&BelCardProperty::setAlternativeIdParam))
			->setCollector("SOURCE-value", make_sfn(&BelCardProperty::setValue));
40 41
}

42 43
BelCardSource::BelCardSource() : BelCardProperty() {
	setName("SOURCE");
44 45
}

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

50
void BelCardKind::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
51
	parser->setHandler("KIND", make_fn(BelCardGeneric::create<BelCardKind>))
52 53 54 55
			->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));
56 57
}

58 59
BelCardKind::BelCardKind() : BelCardProperty() {
	setName("KIND");
60 61 62
}

shared_ptr<BelCardXML> BelCardXML::parse(const string& input) {
Sylvain Berfini's avatar
Sylvain Berfini committed
63
	return BelCardProperty::parseProperty<BelCardXML>("XML", input);
64 65 66
}

void BelCardXML::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
Sylvain Berfini's avatar
Sylvain Berfini committed
67
	parser->setHandler("XML", make_fn(BelCardGeneric::create<BelCardXML>))
68 69 70 71
			->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));
72 73 74 75 76
}

BelCardXML::BelCardXML() : BelCardProperty() {
	setName("XML");
}