blob: 1573af83258aa3d11f3b97ff5d36a2acb5554284 (
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
|
#include "document_cache.h"
#include <stdexcept>
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 {
throw std::out_of_range("failed to instantiate DomDocumentCache");
}
} else {
return (*itemIter).second.get();
}
}
}
|