diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp | 139 |
1 files changed, 69 insertions, 70 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp index 98597e4..a1393cb 100644 --- a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp @@ -6,8 +6,7 @@ #include <Swiften/Serializer/PayloadSerializers/VCardSerializer.h> -#include <boost/shared_ptr.hpp> -#include <boost/smart_ptr/make_shared.hpp> +#include <memory> #include <Swiften/Base/DateTime.h> #include <Swiften/Base/foreach.h> @@ -21,229 +20,229 @@ namespace Swift { VCardSerializer::VCardSerializer() : GenericPayloadSerializer<VCard>() { } -std::string VCardSerializer::serializePayload(boost::shared_ptr<VCard> vcard) const { +std::string VCardSerializer::serializePayload(std::shared_ptr<VCard> vcard) const { XMLElement queryElement("vCard", "vcard-temp"); if (!vcard->getVersion().empty()) { - queryElement.addNode(boost::make_shared<XMLElement>("VERSION", "", vcard->getVersion())); + queryElement.addNode(std::make_shared<XMLElement>("VERSION", "", vcard->getVersion())); } if (!vcard->getFullName().empty()) { - queryElement.addNode(boost::make_shared<XMLElement>("FN", "", vcard->getFullName())); + queryElement.addNode(std::make_shared<XMLElement>("FN", "", vcard->getFullName())); } if (!vcard->getGivenName().empty() || !vcard->getFamilyName().empty() || !vcard->getMiddleName().empty() || !vcard->getPrefix().empty() || !vcard->getSuffix().empty()) { - boost::shared_ptr<XMLElement> nameElement(new XMLElement("N")); + std::shared_ptr<XMLElement> nameElement(new XMLElement("N")); if (!vcard->getFamilyName().empty()) { - nameElement->addNode(boost::make_shared<XMLElement>("FAMILY", "", vcard->getFamilyName())); + nameElement->addNode(std::make_shared<XMLElement>("FAMILY", "", vcard->getFamilyName())); } if (!vcard->getGivenName().empty()) { - nameElement->addNode(boost::make_shared<XMLElement>("GIVEN", "", vcard->getGivenName())); + nameElement->addNode(std::make_shared<XMLElement>("GIVEN", "", vcard->getGivenName())); } if (!vcard->getMiddleName().empty()) { - nameElement->addNode(boost::make_shared<XMLElement>("MIDDLE", "", vcard->getMiddleName())); + nameElement->addNode(std::make_shared<XMLElement>("MIDDLE", "", vcard->getMiddleName())); } if (!vcard->getPrefix().empty()) { - nameElement->addNode(boost::make_shared<XMLElement>("PREFIX", "", vcard->getPrefix())); + nameElement->addNode(std::make_shared<XMLElement>("PREFIX", "", vcard->getPrefix())); } if (!vcard->getSuffix().empty()) { - nameElement->addNode(boost::make_shared<XMLElement>("SUFFIX", "", vcard->getSuffix())); + nameElement->addNode(std::make_shared<XMLElement>("SUFFIX", "", vcard->getSuffix())); } queryElement.addNode(nameElement); } foreach(const VCard::EMailAddress& emailAddress, vcard->getEMailAddresses()) { - boost::shared_ptr<XMLElement> emailElement(new XMLElement("EMAIL")); - emailElement->addNode(boost::make_shared<XMLElement>("USERID", "", emailAddress.address)); + std::shared_ptr<XMLElement> emailElement(new XMLElement("EMAIL")); + emailElement->addNode(std::make_shared<XMLElement>("USERID", "", emailAddress.address)); if (emailAddress.isHome) { - emailElement->addNode(boost::make_shared<XMLElement>("HOME")); + emailElement->addNode(std::make_shared<XMLElement>("HOME")); } if (emailAddress.isWork) { - emailElement->addNode(boost::make_shared<XMLElement>("WORK")); + emailElement->addNode(std::make_shared<XMLElement>("WORK")); } if (emailAddress.isInternet) { - emailElement->addNode(boost::make_shared<XMLElement>("INTERNET")); + emailElement->addNode(std::make_shared<XMLElement>("INTERNET")); } if (emailAddress.isPreferred) { - emailElement->addNode(boost::make_shared<XMLElement>("PREF")); + emailElement->addNode(std::make_shared<XMLElement>("PREF")); } if (emailAddress.isX400) { - emailElement->addNode(boost::make_shared<XMLElement>("X400")); + emailElement->addNode(std::make_shared<XMLElement>("X400")); } queryElement.addNode(emailElement); } if (!vcard->getNickname().empty()) { - queryElement.addNode(boost::make_shared<XMLElement>("NICKNAME", "", vcard->getNickname())); + queryElement.addNode(std::make_shared<XMLElement>("NICKNAME", "", vcard->getNickname())); } if (!vcard->getPhoto().empty() || !vcard->getPhotoType().empty()) { XMLElement::ref photoElement(new XMLElement("PHOTO")); if (!vcard->getPhotoType().empty()) { - photoElement->addNode(boost::make_shared<XMLElement>("TYPE", "", vcard->getPhotoType())); + photoElement->addNode(std::make_shared<XMLElement>("TYPE", "", vcard->getPhotoType())); } if (!vcard->getPhoto().empty()) { - photoElement->addNode(boost::make_shared<XMLElement>("BINVAL", "", Base64::encode(vcard->getPhoto()))); + photoElement->addNode(std::make_shared<XMLElement>("BINVAL", "", Base64::encode(vcard->getPhoto()))); } queryElement.addNode(photoElement); } if (!vcard->getBirthday().is_not_a_date_time()) { - queryElement.addNode(boost::make_shared<XMLElement>("BDAY", "", dateTimeToString(vcard->getBirthday()))); + queryElement.addNode(std::make_shared<XMLElement>("BDAY", "", dateTimeToString(vcard->getBirthday()))); } foreach(const VCard::Telephone& telephone, vcard->getTelephones()) { - boost::shared_ptr<XMLElement> telElement(new XMLElement("TEL")); - telElement->addNode(boost::make_shared<XMLElement>("NUMBER", "", telephone.number)); + std::shared_ptr<XMLElement> telElement(new XMLElement("TEL")); + telElement->addNode(std::make_shared<XMLElement>("NUMBER", "", telephone.number)); if (telephone.isHome) { - telElement->addNode(boost::make_shared<XMLElement>("HOME")); + telElement->addNode(std::make_shared<XMLElement>("HOME")); } if (telephone.isWork) { - telElement->addNode(boost::make_shared<XMLElement>("WORK")); + telElement->addNode(std::make_shared<XMLElement>("WORK")); } if (telephone.isVoice) { - telElement->addNode(boost::make_shared<XMLElement>("VOICE")); + telElement->addNode(std::make_shared<XMLElement>("VOICE")); } if (telephone.isFax) { - telElement->addNode(boost::make_shared<XMLElement>("FAX")); + telElement->addNode(std::make_shared<XMLElement>("FAX")); } if (telephone.isPager) { - telElement->addNode(boost::make_shared<XMLElement>("PAGER")); + telElement->addNode(std::make_shared<XMLElement>("PAGER")); } if (telephone.isMSG) { - telElement->addNode(boost::make_shared<XMLElement>("MSG")); + telElement->addNode(std::make_shared<XMLElement>("MSG")); } if (telephone.isCell) { - telElement->addNode(boost::make_shared<XMLElement>("CELL")); + telElement->addNode(std::make_shared<XMLElement>("CELL")); } if (telephone.isVideo) { - telElement->addNode(boost::make_shared<XMLElement>("VIDEO")); + telElement->addNode(std::make_shared<XMLElement>("VIDEO")); } if (telephone.isBBS) { - telElement->addNode(boost::make_shared<XMLElement>("BBS")); + telElement->addNode(std::make_shared<XMLElement>("BBS")); } if (telephone.isModem) { - telElement->addNode(boost::make_shared<XMLElement>("MODEM")); + telElement->addNode(std::make_shared<XMLElement>("MODEM")); } if (telephone.isISDN) { - telElement->addNode(boost::make_shared<XMLElement>("ISDN")); + telElement->addNode(std::make_shared<XMLElement>("ISDN")); } if (telephone.isPCS) { - telElement->addNode(boost::make_shared<XMLElement>("PCS")); + telElement->addNode(std::make_shared<XMLElement>("PCS")); } if (telephone.isPreferred) { - telElement->addNode(boost::make_shared<XMLElement>("PREF")); + telElement->addNode(std::make_shared<XMLElement>("PREF")); } queryElement.addNode(telElement); } foreach(const VCard::Address& address, vcard->getAddresses()) { - boost::shared_ptr<XMLElement> adrElement = boost::make_shared<XMLElement>("ADR"); + std::shared_ptr<XMLElement> adrElement = std::make_shared<XMLElement>("ADR"); if (!address.poBox.empty()) { - adrElement->addNode(boost::make_shared<XMLElement>("POBOX", "", address.poBox)); + adrElement->addNode(std::make_shared<XMLElement>("POBOX", "", address.poBox)); } if (!address.addressExtension.empty()) { - adrElement->addNode(boost::make_shared<XMLElement>("EXTADD", "", address.addressExtension)); + adrElement->addNode(std::make_shared<XMLElement>("EXTADD", "", address.addressExtension)); } if (!address.street.empty()) { - adrElement->addNode(boost::make_shared<XMLElement>("STREET", "", address.street)); + adrElement->addNode(std::make_shared<XMLElement>("STREET", "", address.street)); } if (!address.locality.empty()) { - adrElement->addNode(boost::make_shared<XMLElement>("LOCALITY", "", address.locality)); + adrElement->addNode(std::make_shared<XMLElement>("LOCALITY", "", address.locality)); } if (!address.region.empty()) { - adrElement->addNode(boost::make_shared<XMLElement>("REGION", "", address.region)); + adrElement->addNode(std::make_shared<XMLElement>("REGION", "", address.region)); } if (!address.postalCode.empty()) { - adrElement->addNode(boost::make_shared<XMLElement>("PCODE", "", address.postalCode)); + adrElement->addNode(std::make_shared<XMLElement>("PCODE", "", address.postalCode)); } if (!address.country.empty()) { - adrElement->addNode(boost::make_shared<XMLElement>("CTRY", "", address.country)); + adrElement->addNode(std::make_shared<XMLElement>("CTRY", "", address.country)); } if (address.isHome) { - adrElement->addNode(boost::make_shared<XMLElement>("HOME")); + adrElement->addNode(std::make_shared<XMLElement>("HOME")); } if (address.isWork) { - adrElement->addNode(boost::make_shared<XMLElement>("WORK")); + adrElement->addNode(std::make_shared<XMLElement>("WORK")); } if (address.isPostal) { - adrElement->addNode(boost::make_shared<XMLElement>("POSTAL")); + adrElement->addNode(std::make_shared<XMLElement>("POSTAL")); } if (address.isParcel) { - adrElement->addNode(boost::make_shared<XMLElement>("PARCEL")); + adrElement->addNode(std::make_shared<XMLElement>("PARCEL")); } if (address.deliveryType == VCard::DomesticDelivery) { - adrElement->addNode(boost::make_shared<XMLElement>("DOM")); + adrElement->addNode(std::make_shared<XMLElement>("DOM")); } if (address.deliveryType == VCard::InternationalDelivery) { - adrElement->addNode(boost::make_shared<XMLElement>("INTL")); + adrElement->addNode(std::make_shared<XMLElement>("INTL")); } if (address.isPreferred) { - adrElement->addNode(boost::make_shared<XMLElement>("PREF")); + adrElement->addNode(std::make_shared<XMLElement>("PREF")); } queryElement.addNode(adrElement); } foreach(const VCard::AddressLabel& addressLabel, vcard->getAddressLabels()) { - boost::shared_ptr<XMLElement> labelElement = boost::make_shared<XMLElement>("LABEL"); + std::shared_ptr<XMLElement> labelElement = std::make_shared<XMLElement>("LABEL"); foreach(const std::string& line, addressLabel.lines) { - labelElement->addNode(boost::make_shared<XMLElement>("LINE", "", line)); + labelElement->addNode(std::make_shared<XMLElement>("LINE", "", line)); } if (addressLabel.isHome) { - labelElement->addNode(boost::make_shared<XMLElement>("HOME")); + labelElement->addNode(std::make_shared<XMLElement>("HOME")); } if (addressLabel.isWork) { - labelElement->addNode(boost::make_shared<XMLElement>("WORK")); + labelElement->addNode(std::make_shared<XMLElement>("WORK")); } if (addressLabel.isPostal) { - labelElement->addNode(boost::make_shared<XMLElement>("POSTAL")); + labelElement->addNode(std::make_shared<XMLElement>("POSTAL")); } if (addressLabel.isParcel) { - labelElement->addNode(boost::make_shared<XMLElement>("PARCEL")); + labelElement->addNode(std::make_shared<XMLElement>("PARCEL")); } if (addressLabel.deliveryType == VCard::DomesticDelivery) { - labelElement->addNode(boost::make_shared<XMLElement>("DOM")); + labelElement->addNode(std::make_shared<XMLElement>("DOM")); } if (addressLabel.deliveryType == VCard::InternationalDelivery) { - labelElement->addNode(boost::make_shared<XMLElement>("INTL")); + labelElement->addNode(std::make_shared<XMLElement>("INTL")); } if (addressLabel.isPreferred) { - labelElement->addNode(boost::make_shared<XMLElement>("PREF")); + labelElement->addNode(std::make_shared<XMLElement>("PREF")); } queryElement.addNode(labelElement); } foreach(const JID& jid, vcard->getJIDs()) { - queryElement.addNode(boost::make_shared<XMLElement>("JID", "", jid.toString())); + queryElement.addNode(std::make_shared<XMLElement>("JID", "", jid.toString())); } if (!vcard->getDescription().empty()) { - queryElement.addNode(boost::make_shared<XMLElement>("DESC", "", vcard->getDescription())); + queryElement.addNode(std::make_shared<XMLElement>("DESC", "", vcard->getDescription())); } foreach(const VCard::Organization& org, vcard->getOrganizations()) { - boost::shared_ptr<XMLElement> orgElement = boost::make_shared<XMLElement>("ORG"); + std::shared_ptr<XMLElement> orgElement = std::make_shared<XMLElement>("ORG"); if (!org.name.empty()) { - orgElement->addNode(boost::make_shared<XMLElement>("ORGNAME", "", org.name)); + orgElement->addNode(std::make_shared<XMLElement>("ORGNAME", "", org.name)); } if (!org.units.empty()) { foreach(const std::string& unit, org.units) { - orgElement->addNode(boost::make_shared<XMLElement>("ORGUNIT", "", unit)); + orgElement->addNode(std::make_shared<XMLElement>("ORGUNIT", "", unit)); } } queryElement.addNode(orgElement); } foreach(const std::string& title, vcard->getTitles()) { - queryElement.addNode(boost::make_shared<XMLElement>("TITLE", "", title)); + queryElement.addNode(std::make_shared<XMLElement>("TITLE", "", title)); } foreach(const std::string& role, vcard->getRoles()) { - queryElement.addNode(boost::make_shared<XMLElement>("ROLE", "", role)); + queryElement.addNode(std::make_shared<XMLElement>("ROLE", "", role)); } foreach(const std::string& url, vcard->getURLs()) { - queryElement.addNode(boost::make_shared<XMLElement>("URL", "", url)); + queryElement.addNode(std::make_shared<XMLElement>("URL", "", url)); } if (!vcard->getUnknownContent().empty()) { - queryElement.addNode(boost::make_shared<XMLRawTextNode>(vcard->getUnknownContent())); + queryElement.addNode(std::make_shared<XMLRawTextNode>(vcard->getUnknownContent())); } return queryElement.serialize(); } |