aboutsummaryrefslogtreecommitdiff
path: root/MemDriverWeb/minitmpl.cpp
blob: 3d7c34ce85463b72f08b5b3da3298c76425e4a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "pch.h"
#include "minitmpl.h"

std::map<std::string, template_cb> TemplateString::template_callbacks;

std::string TemplateString::doTemplateStr() {
	size_t pos = 0;
	in_cache = str();

	out_cache.clear();
	for (auto& key : template_callbacks) {
		while ((pos = in_cache.find(key.first, pos)) != std::string::npos) {
			in_cache.replace(pos, key.first.length(), key.second(out_cache));
			pos += out_cache.length();
		}
	}

	return in_cache;
}