summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParsers/VCardParser.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/VCardParser.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/Swiften/Parser/PayloadParsers/VCardParser.cpp b/Swiften/Parser/PayloadParsers/VCardParser.cpp
index 7867b2c..f8779d1 100644
--- a/Swiften/Parser/PayloadParsers/VCardParser.cpp
+++ b/Swiften/Parser/PayloadParsers/VCardParser.cpp
@@ -1,42 +1,41 @@
/*
* Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Parser/PayloadParsers/VCardParser.h>
#include <cassert>
#include <Swiften/Base/DateTime.h>
-#include <Swiften/Base/foreach.h>
#include <Swiften/Parser/SerializingParser.h>
#include <Swiften/StringCodecs/Base64.h>
namespace Swift {
VCardParser::VCardParser() : unknownContentParser_(nullptr) {
}
void VCardParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
elementStack_.push_back(element);
std::string elementHierarchy = getElementHierarchy();
if (elementHierarchy == "/vCard/EMAIL") {
currentEMailAddress_ = VCard::EMailAddress();
}
if (elementHierarchy == "/vCard/TEL") {
currentTelephone_ = VCard::Telephone();
}
if (elementHierarchy == "/vCard/ADR") {
currentAddress_ = VCard::Address();
}
if (elementHierarchy == "/vCard/LABEL") {
currentAddressLabel_ = VCard::AddressLabel();
}
if (elementHierarchy == "/vCard/ORG") {
currentOrganization_ = VCard::Organization();
}
if (elementStack_.size() == 2) {
assert(!unknownContentParser_);
unknownContentParser_ = new SerializingParser();
unknownContentParser_->handleStartElement(element, ns, attributes);
@@ -255,37 +254,37 @@ void VCardParser::handleEndElement(const std::string& element, const std::string
}
else if (elementHierarchy == "/vCard/TITLE" && !currentText_.empty()) {
getPayloadInternal()->addTitle(currentText_);
}
else if (elementHierarchy == "/vCard/ROLE" && !currentText_.empty()) {
getPayloadInternal()->addRole(currentText_);
}
else if (elementHierarchy == "/vCard/URL" && !currentText_.empty()) {
getPayloadInternal()->addURL(currentText_);
}
else if (elementStack_.size() == 2 && unknownContentParser_) {
getPayloadInternal()->addUnknownContent(unknownContentParser_->getResult());
}
if (elementStack_.size() == 2 && unknownContentParser_) {
delete unknownContentParser_;
unknownContentParser_ = nullptr;
}
elementStack_.pop_back();
}
void VCardParser::handleCharacterData(const std::string& text) {
if (unknownContentParser_) {
unknownContentParser_->handleCharacterData(text);
}
currentText_ += text;
}
std::string VCardParser::getElementHierarchy() const {
std::string result;
- foreach(const std::string& element, elementStack_) {
+ for (const auto& element : elementStack_) {
result += "/" + element;
}
return result;
}
}