Parsodus/include/Parsodus/template.h

64 lines
1.5 KiB
C++

#pragma once
#ifndef PARSODUS_TEMPLATE_H
#define PARSODUS_TEMPLATE_H
#include <map>
#include <string>
#include <vector>
#include <mstch/mstch.hpp>
namespace pds {
namespace templ {
/**
* A changeable information structure for templates
*/
using TemplateContext = mstch::node;
/**
* Make a TemplateContext string
*/
TemplateContext make_string(std::string);
/**
* Make a TemplateContext map/dictionary
*/
TemplateContext make_map(std::map<const std::string, TemplateContext>);
/**
* Make a TemplateContext array/vector
*/
TemplateContext make_array(std::vector<TemplateContext>);
/**
* A generic wrapper around whichever templating system gets used
*/
class Template {
public:
/**
* Construct a Template from given filename
*
* @param filename The name of the file which contains the template rules
*/
Template(std::string filename);
/**
* Destructor
*/
~Template();
/**
* Render this template to `out` using the information in `context`
*
* @param out The ostream to render to
* @param context The information to provide the template rules while rendering
*/
void render(std::ostream& out, TemplateContext& context);
private:
std::string m_filename;
};
} //namespace templ
} //namespace pds
#endif //PARSODUS_TEMPLATE_H