aboutsummaryrefslogtreecommitdiff
path: root/src/support/dom/document_cache.cc
blob: f8145598e666c6ce31d0678dafba15e1119a2031 (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
#include "document_cache.h"

namespace InputXSLT {

DomDocumentCache::DomDocumentCache():
	map_() { }

DomDocumentCache::item* DomDocumentCache::get(const std::string& key) {
	auto itemIter = this->map_.find(key);

	if ( itemIter == this->map_.end() ) {
		auto result = this->map_.emplace(
			std::make_pair(key, std::unique_ptr<item>(new item("content")))
		);

		if ( result.second ) {
			return (*(result.first)).second.get();
		} else {
			return nullptr;
		}
	} else {
		return (*itemIter).second.get();
	}
}

}