cpp-restbed-server-deprecated.model-header.mustache Maven / Gradle / Ivy
{{>licenseInfo}}
{{#models}}{{#model}}/*
* {{classname}}.h
*
* {{description}}
*/
#ifndef {{classname}}_H_
#define {{classname}}_H_
{{{defaultInclude}}}
{{#imports}}{{{this}}}
{{/imports}}
#include
#include
{{#hasEnums}}
#include
{{/hasEnums}}
#include
{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}
///
/// {{description}}
///
{{#circularReferences}}
class {{{this}}};
{{/circularReferences}}
class {{declspec}} {{classname}} {{#interfaces}}{{#-first}}:{{/-first}}{{^-first}},{{/-first}} public {{{this}}}{{/interfaces}}
{
public:
{{classname}}() = default;
explicit {{classname}}(boost::property_tree::ptree const& pt);
virtual ~{{classname}}() = default;
std::string toJsonString(bool prettyJson = false);
void fromJsonString(std::string const& jsonString);
boost::property_tree::ptree toPropertyTree();
void fromPropertyTree(boost::property_tree::ptree const& pt);
/////////////////////////////////////////////
/// {{classname}} members
{{#vars}}
///
/// {{description}}
///
{{{dataType}}} {{getter}}() const;
void {{setter}}({{{dataType}}} value);
{{/vars}}
protected:
//////////////////////////////////////
// Override these for customization //
//////////////////////////////////////
virtual std::string toJsonString_internal(bool prettyJson = false);
virtual void fromJsonString_internal(std::string const& jsonString);
virtual boost::property_tree::ptree toPropertyTree_internal();
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
protected:
{{#vars}}
{{^isContainer}}
{{^isModel}}
{{{dataType}}} m_{{name}} = {{{defaultValue}}};
{{/isModel}}
{{#isModel}}
{{{dataType}}} m_{{name}};
{{/isModel}}
{{/isContainer}}
{{#isContainer}}
{{{dataType}}} m_{{name}};
{{/isContainer}}
{{/vars}}
{{#vars}}
{{#isEnum}}
const std::array m_{{enumName}} = {
{{#allowableValues}}{{#enumVars}}"{{{value}}}"{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
};
{{/isEnum}}
{{/vars}}
};
std::vector<{{classname}}> create{{classname}}VectorFromJsonString(const std::string& json);
{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}
#endif /* {{classname}}_H_ */
{{/model}}
{{/models}}