Commit b09eb288 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Renamed a few classes

parent 7f6d22ea
......@@ -22,8 +22,8 @@ namespace belcard {
class BelCard : public BelCardGeneric {
private:
shared_ptr<BelCardKind> _kind;
shared_ptr<BelCardFN> _fn;
shared_ptr<BelCardN> _n;
shared_ptr<BelCardFullName> _fn;
shared_ptr<BelCardName> _n;
shared_ptr<BelCardBirthday> _bday;
shared_ptr<BelCardAnniversary> _anniversary;
shared_ptr<BelCardGender> _gender;
......@@ -33,7 +33,7 @@ namespace belcard {
list<shared_ptr<BelCardNickname>> _nicknames;
list<shared_ptr<BelCardPhoto>> _photos;
list<shared_ptr<BelCardAddress>> _addr;
list<shared_ptr<BelCardTel>> _tel;
list<shared_ptr<BelCardPhoneNumber>> _tel;
list<shared_ptr<BelCardEmail>> _emails;
list<shared_ptr<BelCardImpp>> _impp;
list<shared_ptr<BelCardLang>> _langs;
......@@ -73,11 +73,11 @@ namespace belcard {
void setKind(const shared_ptr<BelCardKind> &kind);
const shared_ptr<BelCardKind> &getKind() const;
void setFN(const shared_ptr<BelCardFN> &fn);
const shared_ptr<BelCardFN> &getFN() const;
void setFullName(const shared_ptr<BelCardFullName> &fn);
const shared_ptr<BelCardFullName> &getFullName() const;
void setN(const shared_ptr<BelCardN> &n);
const shared_ptr<BelCardN> &getN() const;
void setName(const shared_ptr<BelCardName> &n);
const shared_ptr<BelCardName> &getName() const;
void setBirthday(const shared_ptr<BelCardBirthday> &bday);
const shared_ptr<BelCardBirthday> &getBirthday() const;
......@@ -106,8 +106,8 @@ namespace belcard {
void addAddress(const shared_ptr<BelCardAddress> &addr);
const list<shared_ptr<BelCardAddress>> &getAddresses() const;
void addTel(const shared_ptr<BelCardTel> &tel);
const list<shared_ptr<BelCardTel>> &getTel() const;
void addPhoneNumber(const shared_ptr<BelCardPhoneNumber> &tel);
const list<shared_ptr<BelCardPhoneNumber>> &getPhoneNumbers() const;
void addEmail(const shared_ptr<BelCardEmail> &email);
const list<shared_ptr<BelCardEmail>> &getEmails() const;
......
......@@ -12,13 +12,13 @@ using namespace::std;
using namespace::belr;
namespace belcard {
class BelCardTel : public BelCardProperty {
class BelCardPhoneNumber : public BelCardProperty {
public:
static shared_ptr<BelCardTel> create();
static shared_ptr<BelCardTel> parse(const string& input);
static shared_ptr<BelCardPhoneNumber> create();
static shared_ptr<BelCardPhoneNumber> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardTel();
BelCardPhoneNumber();
virtual void addParam(const shared_ptr<BelCardParam> &param) {
BelCardProperty::addParam(param);
......
......@@ -13,20 +13,20 @@ using namespace::std;
using namespace::belr;
namespace belcard {
class BelCardFN : public BelCardProperty {
class BelCardFullName : public BelCardProperty {
public:
static shared_ptr<BelCardFN> create();
static shared_ptr<BelCardFN> parse(const string& input);
static shared_ptr<BelCardFullName> create();
static shared_ptr<BelCardFullName> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser);
BelCardFN();
BelCardFullName();
virtual void addParam(const shared_ptr<BelCardParam> &param) {
BelCardProperty::addParam(param);
}
};
class BelCardN : public BelCardProperty {
class BelCardName : public BelCardProperty {
private:
string _family_name;
string _given_name;
......@@ -35,11 +35,11 @@ namespace belcard {
string _suffixes;
public:
static shared_ptr<BelCardN> create();
static shared_ptr<BelCardN> parse(const string& input);
static shared_ptr<BelCardName> create();
static shared_ptr<BelCardName> parse(const string& input);
static void setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) ;
BelCardN();
BelCardName();
void setFamilyName(const string &value);
const string &getFamilyName() const;
......
......@@ -14,15 +14,15 @@ void BelCard::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser
->setCollector("SOURCE", make_sfn(&BelCard::addSource))
->setCollector("KIND", make_sfn(&BelCard::setKind))
->setCollector("XML", make_sfn(&BelCard::addXML))
->setCollector("FN", make_sfn(&BelCard::setFN))
->setCollector("N", make_sfn(&BelCard::setN))
->setCollector("FN", make_sfn(&BelCard::setFullName))
->setCollector("N", make_sfn(&BelCard::setName))
->setCollector("BDAY", make_sfn(&BelCard::setBirthday))
->setCollector("ANNIVERSARY", make_sfn(&BelCard::setAnniversary))
->setCollector("GENDER", make_sfn(&BelCard::setGender))
->setCollector("NICKNAME", make_sfn(&BelCard::addNickname))
->setCollector("PHOTO", make_sfn(&BelCard::addPhoto))
->setCollector("ADR", make_sfn(&BelCard::addAddress))
->setCollector("TEL", make_sfn(&BelCard::addTel))
->setCollector("TEL", make_sfn(&BelCard::addPhoneNumber))
->setCollector("EMAIL", make_sfn(&BelCard::addEmail))
->setCollector("IMPP", make_sfn(&BelCard::addImpp))
->setCollector("LANG", make_sfn(&BelCard::addLang))
......@@ -60,19 +60,19 @@ const shared_ptr<BelCardKind> &BelCard::getKind() const {
return _kind;
}
void BelCard::setFN(const shared_ptr<BelCardFN> &fn) {
void BelCard::setFullName(const shared_ptr<BelCardFullName> &fn) {
_fn = fn;
addProperty(_fn);
}
const shared_ptr<BelCardFN> &BelCard::getFN() const {
const shared_ptr<BelCardFullName> &BelCard::getFullName() const {
return _fn;
}
void BelCard::setN(const shared_ptr<BelCardN> &n) {
void BelCard::setName(const shared_ptr<BelCardName> &n) {
_n = n;
addProperty(_n);
}
const shared_ptr<BelCardN> &BelCard::getN() const {
const shared_ptr<BelCardName> &BelCard::getName() const {
return _n;
}
......@@ -148,11 +148,11 @@ const list<shared_ptr<BelCardAddress>> &BelCard::getAddresses() const {
return _addr;
}
void BelCard::addTel(const shared_ptr<BelCardTel> &tel) {
void BelCard::addPhoneNumber(const shared_ptr<BelCardPhoneNumber> &tel) {
_tel.push_back(tel);
addProperty(tel);
}
const list<shared_ptr<BelCardTel>> &BelCard::getTel() const {
const list<shared_ptr<BelCardPhoneNumber>> &BelCard::getPhoneNumbers() const {
return _tel;
}
......
......@@ -4,28 +4,28 @@ using namespace::std;
using namespace::belr;
using namespace::belcard;
shared_ptr<BelCardTel> BelCardTel::create() {
return BelCardGeneric::create<BelCardTel>();
shared_ptr<BelCardPhoneNumber> BelCardPhoneNumber::create() {
return BelCardGeneric::create<BelCardPhoneNumber>();
}
shared_ptr<BelCardTel> BelCardTel::parse(const string& input) {
shared_ptr<BelCardPhoneNumber> BelCardPhoneNumber::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("TEL", input, NULL);
return dynamic_pointer_cast<BelCardTel>(ret);
return dynamic_pointer_cast<BelCardPhoneNumber>(ret);
}
void BelCardTel::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("TEL", make_fn(&BelCardTel::create))
->setCollector("group", make_sfn(&BelCardTel::setGroup))
->setCollector("any-param", make_sfn(&BelCardTel::addParam))
->setCollector("TEL-value", make_sfn(&BelCardTel::setValue));
void BelCardPhoneNumber::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("TEL", make_fn(&BelCardPhoneNumber::create))
->setCollector("group", make_sfn(&BelCardPhoneNumber::setGroup))
->setCollector("any-param", make_sfn(&BelCardPhoneNumber::addParam))
->setCollector("TEL-value", make_sfn(&BelCardPhoneNumber::setValue));
}
BelCardTel::BelCardTel() : BelCardProperty() {
BelCardPhoneNumber::BelCardPhoneNumber() : BelCardProperty() {
setName("TEL");
}
......
......@@ -4,96 +4,96 @@ using namespace::std;
using namespace::belr;
using namespace::belcard;
shared_ptr<BelCardFN> BelCardFN::create() {
return BelCardGeneric::create<BelCardFN>();
shared_ptr<BelCardFullName> BelCardFullName::create() {
return BelCardGeneric::create<BelCardFullName>();
}
shared_ptr<BelCardFN> BelCardFN::parse(const string& input) {
shared_ptr<BelCardFullName> BelCardFullName::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("FN", input, NULL);
return dynamic_pointer_cast<BelCardFN>(ret);
return dynamic_pointer_cast<BelCardFullName>(ret);
}
void BelCardFN::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("FN", make_fn(&BelCardFN::create))
->setCollector("group", make_sfn(&BelCardFN::setGroup))
->setCollector("any-param", make_sfn(&BelCardFN::addParam))
->setCollector("FN-value", make_sfn(&BelCardFN::setValue));
void BelCardFullName::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("FN", make_fn(&BelCardFullName::create))
->setCollector("group", make_sfn(&BelCardFullName::setGroup))
->setCollector("any-param", make_sfn(&BelCardFullName::addParam))
->setCollector("FN-value", make_sfn(&BelCardFullName::setValue));
}
BelCardFN::BelCardFN() : BelCardProperty() {
BelCardFullName::BelCardFullName() : BelCardProperty() {
setName("FN");
}
shared_ptr<BelCardN> BelCardN::create() {
return BelCardGeneric::create<BelCardN>();
shared_ptr<BelCardName> BelCardName::create() {
return BelCardGeneric::create<BelCardName>();
}
shared_ptr<BelCardN> BelCardN::parse(const string& input) {
shared_ptr<BelCardName> BelCardName::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("N", input, NULL);
return dynamic_pointer_cast<BelCardN>(ret);
return dynamic_pointer_cast<BelCardName>(ret);
}
void BelCardN::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("N", make_fn(&BelCardN::create))
->setCollector("group", make_sfn(&BelCardN::setGroup))
->setCollector("any-param", make_sfn(&BelCardN::addParam))
->setCollector("N-fn", make_sfn(&BelCardN::setFamilyName))
->setCollector("N-gn", make_sfn(&BelCardN::setGivenName))
->setCollector("N-an", make_sfn(&BelCardN::setAdditionalName))
->setCollector("N-prefixes", make_sfn(&BelCardN::setPrefixes))
->setCollector("N-suffixes", make_sfn(&BelCardN::setSuffixes));
void BelCardName::setHandlerAndCollectors(Parser<shared_ptr<BelCardGeneric>> *parser) {
parser->setHandler("N", make_fn(&BelCardName::create))
->setCollector("group", make_sfn(&BelCardName::setGroup))
->setCollector("any-param", make_sfn(&BelCardName::addParam))
->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));
}
BelCardN::BelCardN() : BelCardProperty() {
BelCardName::BelCardName() : BelCardProperty() {
setName("N");
}
void BelCardN::setFamilyName(const string &value) {
void BelCardName::setFamilyName(const string &value) {
_family_name = value;
}
const string &BelCardN::getFamilyName() const {
const string &BelCardName::getFamilyName() const {
return _family_name;
}
void BelCardN::setGivenName(const string &value) {
void BelCardName::setGivenName(const string &value) {
_given_name = value;
}
const string &BelCardN::getGivenName() const {
const string &BelCardName::getGivenName() const {
return _given_name;
}
void BelCardN::setAdditionalName(const string &value) {
void BelCardName::setAdditionalName(const string &value) {
_additional_name = value;
}
const string &BelCardN::getAdditionalName() const {
const string &BelCardName::getAdditionalName() const {
return _additional_name;
}
void BelCardN::setPrefixes(const string &value) {
void BelCardName::setPrefixes(const string &value) {
_prefixes = value;
}
const string &BelCardN::getPrefixes() const {
const string &BelCardName::getPrefixes() const {
return _prefixes;
}
void BelCardN::setSuffixes(const string &value) {
void BelCardName::setSuffixes(const string &value) {
_suffixes = value;
}
const string &BelCardN::getSuffixes() const {
const string &BelCardName::getSuffixes() const {
return _suffixes;
}
string BelCardN::serialize() const {
string BelCardName::serialize() const {
stringstream output;
if (getGroup().length() > 0) {
......
......@@ -28,8 +28,8 @@ shared_ptr<BelCard> BelCardParser::parse(const string &input) {
BelCardKind::setHandlerAndCollectors(&parser);
BelCardXML::setHandlerAndCollectors(&parser);
BelCardFN::setHandlerAndCollectors(&parser);
BelCardN::setHandlerAndCollectors(&parser);
BelCardFullName::setHandlerAndCollectors(&parser);
BelCardName::setHandlerAndCollectors(&parser);
BelCardNickname::setHandlerAndCollectors(&parser);
BelCardPhoto::setHandlerAndCollectors(&parser);
BelCardBirthday::setHandlerAndCollectors(&parser);
......@@ -38,7 +38,7 @@ shared_ptr<BelCard> BelCardParser::parse(const string &input) {
BelCardAddress::setHandlerAndCollectors(&parser);
BelCardTel::setHandlerAndCollectors(&parser);
BelCardPhoneNumber::setHandlerAndCollectors(&parser);
BelCardEmail::setHandlerAndCollectors(&parser);
BelCardImpp::setHandlerAndCollectors(&parser);
BelCardLang::setHandlerAndCollectors(&parser);
......
......@@ -5,9 +5,9 @@ using namespace::std;
using namespace::belcard;
static void tel_property(void) {
test_property<BelCardTel>("TEL;VALUE=uri;TYPE=work:tel:+33-9-52-63-65-05\r\n");
test_property<BelCardTel>("TEL;VALUE=uri;TYPE=\"voice,work\":tel:+33952636505\r\n");
test_property<BelCardTel>("TEL;VALUE=text;TYPE=work:+33 9 52 63 65 05\r\n");
test_property<BelCardPhoneNumber>("TEL;VALUE=uri;TYPE=work:tel:+33-9-52-63-65-05\r\n");
test_property<BelCardPhoneNumber>("TEL;VALUE=uri;TYPE=\"voice,work\":tel:+33952636505\r\n");
test_property<BelCardPhoneNumber>("TEL;VALUE=text;TYPE=work:+33 9 52 63 65 05\r\n");
}
static void email_property(void) {
......
......@@ -5,11 +5,11 @@ using namespace::std;
using namespace::belcard;
static void fn_property(void) {
test_property<BelCardFN>("FN:Sylvain Berfini\r\n");
test_property<BelCardFullName>("FN:Sylvain Berfini\r\n");
}
static void n_property(void) {
test_property<BelCardN>("N:Berfini;Sylvain;Pascal;;\r\n");
test_property<BelCardName>("N:Berfini;Sylvain;Pascal;;\r\n");
}
static void nickname_property(void) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment