cpp-rest-sdk-client.model-header.mustache Maven / Gradle / Ivy
{{>licenseInfo}}
{{#models}}{{#model}}/*
* {{classname}}.h
*
* {{description}}
*/
#ifndef {{modelHeaderGuardPrefix}}_{{classname}}_H_
#define {{modelHeaderGuardPrefix}}_{{classname}}_H_
{{#oneOf}}
{{#-first}}
#include
{{/-first}}
{{/oneOf}}
{{^parent}}
{{{defaultInclude}}}
#include "{{packageName}}/ModelBase.h"
{{/parent}}
{{#imports}}{{{this}}}
{{/imports}}
{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}
{{#vendorExtensions.x-has-forward-declarations}}
{{#vendorExtensions.x-forward-declarations}}{{.}}
{{/vendorExtensions.x-forward-declarations}}
{{/vendorExtensions.x-has-forward-declarations}}
{{#oneOf}}{{#-first}}
class {{declspec}} {{classname}}
{
public:
{{classname}}() = default;
~{{classname}}() = default;
/////////////////////////////////////////////
void validate();
web::json::value toJson() const;
template
bool fromJson(const web::json::value& json) {
// convert json to Target type
Target target;
if (!target.fromJson(json)) {
return false;
}
m_variantValue = target;
return true;
}
void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const;
template
bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) {
// convert multipart to Target type
Target target;
if (!target.fromMultiPart(multipart, namePrefix)) {
return false;
}
m_variantValue = target;
return true;
}
/////////////////////////////////////////////
/// {{classname}} members
using VariantType = std::variant<{{#oneOf}}{{^-first}}, {{/-first}}{{{.}}}{{/oneOf}}>;
const VariantType& getVariant() const;
void setVariant(VariantType value);
protected:
VariantType m_variantValue;
};
{{/-first}}{{/oneOf}}
{{^oneOf}}
{{#isEnum}}
class {{declspec}} {{classname}}
: public {{{parent}}}{{^parent}}ModelBase{{/parent}}
{
public:
{{classname}}();
virtual ~{{classname}}();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override;
enum class e{{classname}}
{
{{#allowableValues}}
{{#enumVars}}
{{#enumDescription}}
///
/// {{.}}
///
{{/enumDescription}}
{{classname}}_{{{name}}}{{^last}},{{/last}}
{{/enumVars}}
{{/allowableValues}}
};
e{{classname}} getValue() const;
void setValue(e{{classname}} const value);
protected:
e{{classname}} m_value;
};
{{/isEnum}}
{{^isEnum}}
///
/// {{description}}
///
class {{declspec}} {{classname}}
: public {{{parent}}}{{^parent}}ModelBase{{/parent}}
{
public:
{{classname}}();
virtual ~{{classname}}();
/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;
web::json::value toJson() const override;
bool fromJson(const web::json::value& json) override;
void toMultipart(std::shared_ptr multipart, const utility::string_t& namePrefix) const override;
bool fromMultiPart(std::shared_ptr multipart, const utility::string_t& namePrefix) override;
/////////////////////////////////////////////
/// {{classname}} members
{{#vars}}
{{^isInherited}}
///
/// {{description}}
///
{{#isContainer}}{{{dataType}}}& {{getter}}();
{{/isContainer}}{{^isContainer}}{{{dataType}}} {{getter}}() const;
{{/isContainer}}bool {{nameInCamelCase}}IsSet() const;
void unset{{name}}();
{{#isPrimitiveType}}
void {{setter}}({{{dataType}}} value);
{{/isPrimitiveType}}
{{^isPrimitiveType}}
void {{setter}}(const {{{dataType}}}& value);
{{/isPrimitiveType}}
{{/isInherited}}
{{/vars}}
protected:
{{#vars}}
{{^isInherited}}
{{{dataType}}} m_{{name}};
bool m_{{name}}IsSet;
{{/isInherited}}
{{/vars}}
};
{{/isEnum}}
{{/oneOf}}
{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}
#endif /* {{modelHeaderGuardPrefix}}_{{classname}}_H_ */
{{/model}}
{{/models}}