From caf93747fb255f7e5750618216c560440d3fa42f Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Wed, 3 Jul 2019 17:52:43 +0200 Subject: simple string based templating engine preps --- MemDriverWeb/minitmpl.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 MemDriverWeb/minitmpl.h (limited to 'MemDriverWeb/minitmpl.h') diff --git a/MemDriverWeb/minitmpl.h b/MemDriverWeb/minitmpl.h new file mode 100644 index 0000000..446930a --- /dev/null +++ b/MemDriverWeb/minitmpl.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +class TemplateString : public std::stringstream +{ +public: + std::string& doTemplateStr(const std::string& search, const std::string& replace) { + size_t pos = 0; + std::string s = this->str(); + while ((pos = s.find(search, pos)) != std::string::npos) { + s.replace(pos, search.length(), replace); + pos += replace.length(); + } + return s; + } +}; \ No newline at end of file -- cgit v1.2.3