/*
belcard.hpp
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 .
*/
#ifndef belcard_hpp
#define belcard_hpp
#include "belcard_utils.hpp"
#include "belcard_generic.hpp"
#include "belcard_params.hpp"
#include "belcard_property.hpp"
#include "belcard_general.hpp"
#include "belcard_identification.hpp"
#include "belcard_addressing.hpp"
#include "belcard_communication.hpp"
#include "belcard_geographical.hpp"
#include "belcard_organizational.hpp"
#include "belcard_explanatory.hpp"
#include "belcard_security.hpp"
#include "belcard_calendar.hpp"
#include "belcard_rfc6474.hpp"
#include "bctoolbox/logging.h"
#include
#include
namespace belcard {
class BelCard : public BelCardGeneric {
private:
std::string _folded_string;
bool _skipFieldValidation = false;
std::shared_ptr _kind;
std::shared_ptr _fn;
std::shared_ptr _n;
std::shared_ptr _bday;
std::shared_ptr _anniversary;
std::shared_ptr _gender;
std::shared_ptr _pid;
std::shared_ptr _rev;
std::shared_ptr _uid;
std::shared_ptr _bplace;
std::shared_ptr _dplace;
std::shared_ptr _ddate;
std::list> _nicknames;
std::list> _photos;
std::list> _addr;
std::list> _tel;
std::list> _emails;
std::list> _impp;
std::list> _langs;
std::list> _sources;
std::list> _xml;
std::list> _timezones;
std::list> _geos;
std::list> _titles;
std::list> _roles;
std::list> _logos;
std::list> _organizations;
std::list> _members;
std::list> _related;
std::list> _categories;
std::list> _notes;
std::list> _sounds;
std::list> _clientpidmaps;
std::list> _urls;
std::list> _keys;
std::list> _fburls;
std::list> _caladruris;
std::list> _caluris;
std::list> _extended_properties;
std::list> _properties;
template
void set(std::shared_ptr &p, const std::shared_ptr &property);
template
void add(std::list> &property_list, const std::shared_ptr &property);
template
void remove(std::list> &property_list, const std::shared_ptr &property);
// The following are for belcard use only, they don't do any check on the value
void _setKind(const std::shared_ptr &kind);
void _setFullName(const std::shared_ptr &fn);
void _setName(const std::shared_ptr &n);
void _setBirthday(const std::shared_ptr &bday);
void _setAnniversary(const std::shared_ptr &anniversary);
void _setGender(const std::shared_ptr &gender);
void _setProductId(const std::shared_ptr &pid);
void _setRevision(const std::shared_ptr &rev);
void _setUniqueId(const std::shared_ptr &uid);
void _setBirthPlace(const std::shared_ptr &place);
void _setDeathPlace(const std::shared_ptr &place);
void _setDeathDate(const std::shared_ptr &date);
void _addNickname(const std::shared_ptr &nickname);
void _addPhoto(const std::shared_ptr &photo);
void _addAddress(const std::shared_ptr &addr);
void _addPhoneNumber(const std::shared_ptr &tel);
void _addEmail(const std::shared_ptr &email);
void _addImpp(const std::shared_ptr &impp);
void _addLang(const std::shared_ptr &lang);
void _addSource(const std::shared_ptr &source);
void _addXML(const std::shared_ptr &xml);
void _addTimezone(const std::shared_ptr &tz);
void _addGeo(const std::shared_ptr &geo);
void _addTitle(const std::shared_ptr &title);
void _addRole(const std::shared_ptr &role);
void _addLogo(const std::shared_ptr &logo);
void _addOrganization(const std::shared_ptr &org);
void _addMember(const std::shared_ptr &member);
void _addRelated(const std::shared_ptr &related);
void _addCategories(const std::shared_ptr &categories);
void _addNote(const std::shared_ptr ¬e);
void _addSound(const std::shared_ptr &sound);
void _addClientProductIdMap(const std::shared_ptr &clientpidmap);
void _addURL(const std::shared_ptr &url);
void _addKey(const std::shared_ptr &key);
void _addFBURL(const std::shared_ptr &fburl);
void _addCALADRURI(const std::shared_ptr &caladruri);
void _addCALURI(const std::shared_ptr &caluri);
void _addExtendedProperty(const std::shared_ptr &property);
public:
BELCARD_PUBLIC static void setHandlerAndCollectors(belr::Parser> *parser);
BELCARD_PUBLIC BelCard();
BELCARD_PUBLIC void setSkipFieldValidation(bool skip);
BELCARD_PUBLIC bool getSkipFieldValidation();
BELCARD_PUBLIC bool setKind(const std::shared_ptr &kind);
BELCARD_PUBLIC const std::shared_ptr &getKind() const;
BELCARD_PUBLIC bool setFullName(const std::shared_ptr &fn);
BELCARD_PUBLIC const std::shared_ptr &getFullName() const;
BELCARD_PUBLIC bool setName(const std::shared_ptr &n);
BELCARD_PUBLIC const std::shared_ptr &getName() const;
BELCARD_PUBLIC bool setBirthday(const std::shared_ptr &bday);
BELCARD_PUBLIC const std::shared_ptr &getBirthday() const;
BELCARD_PUBLIC bool setAnniversary(const std::shared_ptr &anniversary);
BELCARD_PUBLIC const std::shared_ptr &getAnniversary() const;
BELCARD_PUBLIC bool setGender(const std::shared_ptr &gender);
BELCARD_PUBLIC const std::shared_ptr &getGender() const;
BELCARD_PUBLIC bool setProductId(const std::shared_ptr &pid);
BELCARD_PUBLIC const std::shared_ptr &getProductId() const;
BELCARD_PUBLIC bool setRevision(const std::shared_ptr &rev);
BELCARD_PUBLIC const std::shared_ptr &getRevision() const;
BELCARD_PUBLIC bool setUniqueId(const std::shared_ptr &uid);
BELCARD_PUBLIC const std::shared_ptr &getUniqueId() const;
BELCARD_PUBLIC bool setBirthPlace(const std::shared_ptr &place);
BELCARD_PUBLIC const std::shared_ptr &getBirthPlace() const;
BELCARD_PUBLIC bool setDeathPlace(const std::shared_ptr &place);
BELCARD_PUBLIC const std::shared_ptr &getDeathPlace() const;
BELCARD_PUBLIC bool setDeathDate(const std::shared_ptr &date);
BELCARD_PUBLIC const std::shared_ptr &getDeathDate() const;
BELCARD_PUBLIC bool addNickname(const std::shared_ptr &nickname);
BELCARD_PUBLIC void removeNickname(const std::shared_ptr &nickname);
BELCARD_PUBLIC const std::list> &getNicknames() const;
BELCARD_PUBLIC bool addPhoto(const std::shared_ptr &photo);
BELCARD_PUBLIC void removePhoto(const std::shared_ptr &photo);
BELCARD_PUBLIC const std::list> &getPhotos() const;
BELCARD_PUBLIC bool addAddress(const std::shared_ptr &addr);
BELCARD_PUBLIC void removeAddress(const std::shared_ptr &addr);
BELCARD_PUBLIC const std::list> &getAddresses() const;
BELCARD_PUBLIC bool addPhoneNumber(const std::shared_ptr &tel);
BELCARD_PUBLIC void removePhoneNumber(const std::shared_ptr &tel);
BELCARD_PUBLIC const std::list> &getPhoneNumbers() const;
BELCARD_PUBLIC bool addEmail(const std::shared_ptr &email);
BELCARD_PUBLIC void removeEmail(const std::shared_ptr &email);
BELCARD_PUBLIC const std::list> &getEmails() const;
BELCARD_PUBLIC bool addImpp(const std::shared_ptr &impp);
BELCARD_PUBLIC void removeImpp(const std::shared_ptr &impp);
BELCARD_PUBLIC const std::list> &getImpp() const;
BELCARD_PUBLIC bool addLang(const std::shared_ptr &lang);
BELCARD_PUBLIC void removeLang(const std::shared_ptr &lang);
BELCARD_PUBLIC const std::list> &getLangs() const;
BELCARD_PUBLIC bool addSource(const std::shared_ptr &source);
BELCARD_PUBLIC void removeSource(const std::shared_ptr &source);
BELCARD_PUBLIC const std::list> &getSource() const;
BELCARD_PUBLIC bool addXML(const std::shared_ptr &xml);
BELCARD_PUBLIC void removeXML(const std::shared_ptr &xml);
BELCARD_PUBLIC const std::list> &getXML() const;
BELCARD_PUBLIC bool addTimezone(const std::shared_ptr &tz);
BELCARD_PUBLIC void removeTimezone(const std::shared_ptr &tz);
BELCARD_PUBLIC const std::list> &getTimezones() const;
BELCARD_PUBLIC bool addGeo(const std::shared_ptr &geo);
BELCARD_PUBLIC void removeGeo(const std::shared_ptr &geo);
BELCARD_PUBLIC const std::list> &getGeos() const;
BELCARD_PUBLIC bool addTitle(const std::shared_ptr &title);
BELCARD_PUBLIC void removeTitle(const std::shared_ptr &title);
BELCARD_PUBLIC const std::list> &getTitles() const;
BELCARD_PUBLIC bool addRole(const std::shared_ptr &role);
BELCARD_PUBLIC void removeRole(const std::shared_ptr &role);
BELCARD_PUBLIC const std::list> &getRoles() const;
BELCARD_PUBLIC bool addLogo(const std::shared_ptr &logo);
BELCARD_PUBLIC void removeLogo(const std::shared_ptr &logo);
BELCARD_PUBLIC const std::list> &getLogos() const;
BELCARD_PUBLIC bool addOrganization(const std::shared_ptr &org);
BELCARD_PUBLIC void removeOrganization(const std::shared_ptr &org);
BELCARD_PUBLIC const std::list> &getOrganizations() const;
BELCARD_PUBLIC bool addMember(const std::shared_ptr &member);
BELCARD_PUBLIC void removeMember(const std::shared_ptr &member);
BELCARD_PUBLIC const std::list> &getMembers() const;
BELCARD_PUBLIC bool addRelated(const std::shared_ptr &related);
BELCARD_PUBLIC void removeRelated(const std::shared_ptr &related);
BELCARD_PUBLIC const std::list> &getRelated() const;
BELCARD_PUBLIC bool addCategories(const std::shared_ptr &categories);
BELCARD_PUBLIC void removeCategories(const std::shared_ptr &categories);
BELCARD_PUBLIC const std::list> &getCategories() const;
BELCARD_PUBLIC bool addNote(const std::shared_ptr ¬e);
BELCARD_PUBLIC void removeNote(const std::shared_ptr ¬e);
BELCARD_PUBLIC const std::list> &getNotes() const;
BELCARD_PUBLIC bool addSound(const std::shared_ptr &sound);
BELCARD_PUBLIC void removeSound(const std::shared_ptr &sound);
BELCARD_PUBLIC const std::list> &getSounds() const;
BELCARD_PUBLIC bool addClientProductIdMap(const std::shared_ptr &clientpidmap);
BELCARD_PUBLIC void removeClientProductIdMap(const std::shared_ptr &clientpidmap);
BELCARD_PUBLIC const std::list> &getClientProductIdMaps() const;
BELCARD_PUBLIC bool addURL(const std::shared_ptr &url);
BELCARD_PUBLIC void removeURL(const std::shared_ptr &url);
BELCARD_PUBLIC const std::list> &getURLs() const;
BELCARD_PUBLIC bool addKey(const std::shared_ptr &key);
BELCARD_PUBLIC void removeKey(const std::shared_ptr &key);
BELCARD_PUBLIC const std::list> &getKeys() const;
BELCARD_PUBLIC bool addFBURL(const std::shared_ptr &fburl);
BELCARD_PUBLIC void removeFBURL(const std::shared_ptr &fburl);
BELCARD_PUBLIC const std::list> &getFBURLs() const;
BELCARD_PUBLIC bool addCALADRURI(const std::shared_ptr &caladruri);
BELCARD_PUBLIC void removeCALADRURI(const std::shared_ptr &caladruri);
BELCARD_PUBLIC const std::list> &getCALADRURIs() const;
BELCARD_PUBLIC bool addCALURI(const std::shared_ptr &caluri);
BELCARD_PUBLIC void removeCALURI(const std::shared_ptr &caluri);
BELCARD_PUBLIC const std::list> &getCALURIs() const;
BELCARD_PUBLIC bool addExtendedProperty(const std::shared_ptr &property);
BELCARD_PUBLIC void removeExtendedProperty(const std::shared_ptr &property);
BELCARD_PUBLIC const std::list> &getExtendedProperties() const;
BELCARD_PUBLIC void addProperty(const std::shared_ptr &property);
BELCARD_PUBLIC void removeProperty(const std::shared_ptr &property);
BELCARD_PUBLIC const std::list> &getProperties() const;
BELCARD_PUBLIC std::string& toFoldedString();
BELCARD_PUBLIC bool assertRFCCompliance() const;
BELCARD_PUBLIC virtual void serialize(std::ostream &output) const;
};
class BelCardList : public BelCardGeneric {
private:
std::list> _vCards;
public:
BELCARD_PUBLIC static void setHandlerAndCollectors(belr::Parser> *parser);
BELCARD_PUBLIC BelCardList();
BELCARD_PUBLIC void addCard(const std::shared_ptr &vcard);
BELCARD_PUBLIC const std::list> &getCards() const;
BELCARD_PUBLIC void serialize(std::ostream &output) const;
};
}
#endif