summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-11-23 07:09:39 (GMT)
committerTobias Markmann <tm@ayena.de>2016-11-23 11:30:02 (GMT)
commite405ff3561be3d3c0bd79d7d5173923a8828cf02 (patch)
tree9118ef838ebfaec1df90ec24761944b5d833774c /Swiften/Parser/PayloadParsers/FormParser.cpp
parent8a71b91be885652f37c5aab5e1ecf25af4599fbc (diff)
downloadswift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.zip
swift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.tar.bz2
Migrate remaining Swiften/Base/foreach.h use to range-based for loop
Test-Information: Build on macOS 10.12.1 and all tests pass. Change-Id: Iedaa3fa7e7672c77909fd0568bf30e9393cb87e0
Diffstat (limited to 'Swiften/Parser/PayloadParsers/FormParser.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/FormParser.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/Swiften/Parser/PayloadParsers/FormParser.cpp b/Swiften/Parser/PayloadParsers/FormParser.cpp
index 5ea75c5..dff45df 100644
--- a/Swiften/Parser/PayloadParsers/FormParser.cpp
+++ b/Swiften/Parser/PayloadParsers/FormParser.cpp
@@ -1,41 +1,39 @@
/*
* Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Parser/PayloadParsers/FormParser.h>
#include <map>
-#include <Swiften/Base/foreach.h>
-
namespace Swift {
FormParser::FormParser() : level_(TopLevel), parsingItem_(false), parsingReported_(false), parsingOption_(false), hasReportedRef_(false){
}
void FormParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) {
if (level_ == TopLevel) {
std::string type = attributes.getAttribute("type");
if (type == "form") {
getPayloadInternal()->setType(Form::FormType);
}
else if (type == "submit") {
getPayloadInternal()->setType(Form::SubmitType);
}
else if (type == "cancel") {
getPayloadInternal()->setType(Form::CancelType);
}
else if (type == "result") {
getPayloadInternal()->setType(Form::ResultType);
}
}
else if (level_ == PayloadLevel) {
if (element == "title") {
currentText_.clear();
}
else if (element == "instructions") {
currentText_.clear();
}
else if (element == "reported") {
parsingReported_ = true;
@@ -163,69 +161,69 @@ void FormParser::handleEndElement(const std::string& element, const std::string&
else if (currentField_) {
if (element == "required") {
currentField_->setRequired(true);
}
else if (element == "desc") {
currentField_->setDescription(currentText_);
}
else if (element == "option") {
currentField_->addOption(FormField::Option(currentOptionLabel_, currentOptionValue_));
parsingOption_ = false;
}
else if (element == "value") {
if (parsingOption_) {
currentOptionValue_ = currentText_;
}
else {
currentField_->addValue(currentText_);
}
}
}
if (level_ >= PayloadLevel && currentField_) {
if (element == "field") {
if (parsingReported_) {
getPayloadInternal()->addReportedField(currentField_);
}
else if (parsingItem_) {
currentFields_.push_back(currentField_);
}
else {
if (currentPages_.size() > 0) {
- foreach (std::shared_ptr<FormPage> page, currentPages_) {
- foreach (std::string pageRef, page->getFieldRefs()) {
+ for (const auto& page : currentPages_) {
+ for (const auto& pageRef : page->getFieldRefs()) {
if (pageRef == currentField_->getName()) {
page->addField(currentField_);
}
}
}
- foreach (std::shared_ptr<FormSection> section, currentSections_) {
- foreach (std::string sectionRef, section->getFieldRefs()) {
+ for (const auto& section : currentSections_) {
+ for (const auto& sectionRef : section->getFieldRefs()) {
if (sectionRef == currentField_->getName()) {
section->addField(currentField_);
}
}
}
} else {
getPayloadInternal()->addField(currentField_);
}
}
currentField_.reset();
}
}
if (level_ > PayloadLevel) {
if (element == "section") {
if (sectionStack_.size() > 1) {
// Add the section at the top of the stack to the level below
sectionStack_.at(sectionStack_.size()-2)->addChildSection(sectionStack_.at(sectionStack_.size()-1));
sectionStack_.pop_back();
}
else if (sectionStack_.size() == 1) {
// Add the remaining section on the stack to its parent page
currentPage_->addChildSection(sectionStack_.at(sectionStack_.size()-1));
sectionStack_.pop_back();
}
}
if (currentReportedRef_ && !hasReportedRef_) {
if (sectionStack_.size() > 0) {
sectionStack_.at(sectionStack_.size()-1)->addReportedRef(currentReportedRef_);
} else if (currentPage_) {
currentPage_->addReportedRef(currentReportedRef_);