dynamic: Add DynamicContent{Get,Set}Var
This commit is contained in:
parent
3e736db0ef
commit
e876b15c5d
11
dynamic/dynamiccontentgetvar.cpp
Normal file
11
dynamic/dynamiccontentgetvar.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "dynamiccontentgetvar.h"
|
||||||
|
|
||||||
|
std::string DynamicContentGetVar::render()
|
||||||
|
{
|
||||||
|
return (*this->map)[this->argument];
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicContentGetVar::setMap(std::map<std::string, std::string> &map)
|
||||||
|
{
|
||||||
|
this->map = ↦
|
||||||
|
}
|
19
dynamic/dynamiccontentgetvar.h
Normal file
19
dynamic/dynamiccontentgetvar.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef DYNAMICCONTENTGETVAR_H
|
||||||
|
#define DYNAMICCONTENTGETVAR_H
|
||||||
|
|
||||||
|
#include "dynamiccontent.h"
|
||||||
|
class DynamicContentGetVar : public DynamicContent
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::map<std::string, std::string> *map;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using DynamicContent::DynamicContent;
|
||||||
|
|
||||||
|
// DynamicContent interface
|
||||||
|
public:
|
||||||
|
std::string render();
|
||||||
|
void setMap(std::map<std::string, std::string> &map);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DYNAMICCONTENTGETVAR_H
|
21
dynamic/dynamiccontentsetvar.cpp
Normal file
21
dynamic/dynamiccontentsetvar.cpp
Normal file
@ -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<std::string, std::string> &map)
|
||||||
|
{
|
||||||
|
this->map = ↦
|
||||||
|
}
|
17
dynamic/dynamiccontentsetvar.h
Normal file
17
dynamic/dynamiccontentsetvar.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef DYNAMCCONTENTPUSHVAR_H
|
||||||
|
#define DYNAMCCONTENTPUSHVAR_H
|
||||||
|
#include "dynamiccontent.h"
|
||||||
|
class DynamicContentSetVar : public DynamicContent
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::map<std::string, std::string> *map;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using DynamicContent::DynamicContent;
|
||||||
|
|
||||||
|
std::string render();
|
||||||
|
void setArgument(std::string argument);
|
||||||
|
void setMap(std::map<std::string, std::string> &map);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DYNAMCCONTENTPUSHVAR_H
|
Loading…
Reference in New Issue
Block a user