summaryrefslogtreecommitdiffstats
blob: 0d0aca8fc595609d17d0312198143edede039b92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (c) 2015 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#include <Swiften/Parser/PayloadParsers/ThreadParser.h>

#include <boost/optional.hpp>

namespace Swift {

ThreadParser::ThreadParser() : level_(0) {
}

ThreadParser::~ThreadParser() {
}

void ThreadParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) {
	++level_;
	if (element == "thread") {
		getPayloadInternal()->setParent(attributes.getAttributeValue("parent").get_value_or(""));
	}
}

void ThreadParser::handleEndElement(const std::string&, const std::string&) {
	--level_;
	if (level_ == 0) {
		getPayloadInternal()->setText(text_);
	}
}

void ThreadParser::handleCharacterData(const std::string& data) {
	if (level_ == 1) {
		text_ += data;
	}
}

}