diff --git a/dynamic/dynamiccontentgetvar.cpp b/dynamic/dynamiccontentgetvar.cpp new file mode 100644 index 0000000..dafda97 --- /dev/null +++ b/dynamic/dynamiccontentgetvar.cpp @@ -0,0 +1,11 @@ +#include "dynamiccontentgetvar.h" + +std::string DynamicContentGetVar::render() +{ + return (*this->map)[this->argument]; +} + +void DynamicContentGetVar::setMap(std::map &map) +{ + this->map = ↦ +} diff --git a/dynamic/dynamiccontentgetvar.h b/dynamic/dynamiccontentgetvar.h new file mode 100644 index 0000000..7e068ad --- /dev/null +++ b/dynamic/dynamiccontentgetvar.h @@ -0,0 +1,19 @@ +#ifndef DYNAMICCONTENTGETVAR_H +#define DYNAMICCONTENTGETVAR_H + +#include "dynamiccontent.h" +class DynamicContentGetVar : public DynamicContent +{ + private: + std::map *map; + + public: + using DynamicContent::DynamicContent; + + // DynamicContent interface + public: + std::string render(); + void setMap(std::map &map); +}; + +#endif // DYNAMICCONTENTGETVAR_H diff --git a/dynamic/dynamiccontentsetvar.cpp b/dynamic/dynamiccontentsetvar.cpp new file mode 100644 index 0000000..3923f00 --- /dev/null +++ b/dynamic/dynamiccontentsetvar.cpp @@ -0,0 +1,21 @@ +#include "dynamiccontentsetvar.h" + +std::string DynamicContentSetVar::render() +{ + auto result = utils::split(this->argument, '='); + if(result.size() == 2) + { + this->map->emplace(std::make_pair(result[0], result[1])); + } + return {}; +} + +void DynamicContentSetVar::setArgument(std::string argument) +{ + this->argument = argument; +} + +void DynamicContentSetVar::setMap(std::map &map) +{ + this->map = ↦ +} diff --git a/dynamic/dynamiccontentsetvar.h b/dynamic/dynamiccontentsetvar.h new file mode 100644 index 0000000..9d03083 --- /dev/null +++ b/dynamic/dynamiccontentsetvar.h @@ -0,0 +1,17 @@ +#ifndef DYNAMCCONTENTPUSHVAR_H +#define DYNAMCCONTENTPUSHVAR_H +#include "dynamiccontent.h" +class DynamicContentSetVar : public DynamicContent +{ + private: + std::map *map; + + public: + using DynamicContent::DynamicContent; + + std::string render(); + void setArgument(std::string argument); + void setMap(std::map &map); +}; + +#endif // DYNAMCCONTENTPUSHVAR_H