TemplatePage: Change 'content' to shared_ptr

This commit is contained in:
Albert S. 2021-10-10 22:32:13 +02:00
rodzic 92be470545
commit c9dc3416d7
2 zmienionych plików z 4 dodań i 3 usunięć

Wyświetl plik

@ -27,7 +27,7 @@ TemplatePage::TemplatePage()
TemplatePage::TemplatePage(std::string content)
{
this->content = content;
this->content = std::make_shared<std::string>(content);
}
void TemplatePage::setVar(const std::string &key, std::string value)
@ -40,5 +40,5 @@ std::string TemplatePage::render() const
Varreplacer replacer("{qswiki:");
replacer.addResolver("var",
[&](std::string_view key) { return utils::getKeyOrEmpty(this->varsMap, std::string(key)); });
return replacer.parse(this->content);
return replacer.parse(*this->content);
}

Wyświetl plik

@ -3,10 +3,11 @@
#include <string>
#include <string_view>
#include <map>
#include <memory>
class TemplatePage
{
private:
std::string content;
std::shared_ptr<const std::string> content;
std::map<std::string, std::string> varsMap;
public: