C-libcurl.model-body.mustache Maven / Gradle / Ivy
{{#models}}
{{#model}}
#include
#include
#include
#include "{{classname}}.h"
{{#isEnum}}
char* {{classname}}_ToString({{classname}}_e {{classname}}){
char *{{classname}}Array[] = { {{#allowableValues}}{{#enumVars}}"{{{value}}}"{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} };
return {{classname}}Array[{{classname}}];
}
{{classname}}_e {{classname}}_FromString(char* {{classname}}){
int stringToReturn = 0;
char *{{classname}}Array[] = { {{#allowableValues}}{{#enumVars}}"{{{value}}}"{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} };
size_t sizeofArray = sizeof({{classname}}Array) / sizeof({{classname}}Array[0]);
while(stringToReturn < sizeofArray) {
if(strcmp({{classname}}, {{classname}}Array[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}
cJSON *{{classname}}_convertToJSON({{classname}}_e {{classname}}) {
cJSON *item = cJSON_CreateObject();
{{#isString}}
if(cJSON_AddStringToObject(item, "{{{classname}}}", {{{classname}}}_ToString({{{classname}}})) == NULL) {
goto fail;
}
{{/isString}}
{{#isNumeric}}
if(cJSON_AddNumberToObject(item, "{{{classname}}}", {{{classname}}}) == NULL) {
goto fail;
}
{{/isNumeric}}
return item;
fail:
cJSON_Delete(item);
return NULL;
}
{{classname}}_e {{classname}}_parseFromJSON(cJSON *{{classname}}JSON){
{{classname}}_e *{{classname}} = NULL;
{{#isEnum}}
{{#isNumeric}}
cJSON *{{{classname}}}Var = cJSON_GetObjectItemCaseSensitive({{classname}}JSON, "{{{classname}}}");
if(!cJSON_IsNumber({{{classname}}}Var))
{
goto end;
}
{{/isNumeric}}
{{#isString}}
{{{classname}}}_e {{classname}}Variable;
cJSON *{{{classname}}}Var = cJSON_GetObjectItemCaseSensitive({{classname}}JSON, "{{{classname}}}");
if(!cJSON_IsString({{{classname}}}Var) || ({{{classname}}}Var->valuestring == NULL)){
goto end;
}
{{classname}}Variable = {{classname}}_FromString({{{classname}}}Var->valuestring);
{{/isString}}
{{/isEnum}}
return {{classname}}Variable;
end:
return 0;
}
{{/isEnum}}
{{^isEnum}}
{{#vars}}
{{^isContainer}}
{{^isModel}}
{{#isEnum}}
char* {{name}}{{classname}}_ToString({{name}}_e {{name}}){
char *{{name}}Array[] = { {{#allowableValues}}{{#enumVars}}"{{{value}}}"{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} };
return {{name}}Array[{{name}}];
}
{{name}}_e {{name}}{{classname}}_FromString(char* {{name}}){
int stringToReturn = 0;
char *{{name}}Array[] = { {{#allowableValues}}{{#enumVars}}"{{{value}}}"{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} };
size_t sizeofArray = sizeof({{name}}Array) / sizeof({{name}}Array[0]);
while(stringToReturn < sizeofArray) {
if(strcmp({{name}}, {{name}}Array[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}
{{/isEnum}}
{{/isModel}}
{{/isContainer}}
{{#isContainer}}
{{#items}}
{{^isModel}}
{{#isEnum}}
char* {{name}}{{classname}}_ToString({{name}}_e {{name}}){
char *{{name}}Array[] = { {{#allowableValues}}{{#enumVars}}"{{{value}}}"{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} };
return {{name}}Array[{{name}} - 1];
}
{{name}}_e {{name}}{{classname}}_FromString(char* {{name}}){
int stringToReturn = 0;
char *{{name}}Array[] = { {{#allowableValues}}{{#enumVars}}"{{{value}}}"{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} };
size_t sizeofArray = sizeof({{name}}Array) / sizeof({{name}}Array[0]);
while(stringToReturn < sizeofArray) {
if(strcmp({{name}}, {{name}}Array[stringToReturn]) == 0) {
return stringToReturn + 1;
}
stringToReturn++;
}
return 0;
}
{{/isEnum}}
{{/isModel}}
{{/items}}
{{/isContainer}}
{{/vars}}
{{classname}}_t *{{classname}}_create(
{{#vars}}
{{^isContainer}}
{{^isPrimitiveType}}
{{#isModel}}
{{#isEnum}}
{{datatype}}_e {{name}}{{#hasMore}},{{/hasMore}}
{{/isEnum}}
{{^isEnum}}
{{datatype}}_t *{{name}}{{#hasMore}},{{/hasMore}}
{{/isEnum}}
{{/isModel}}
{{#isUuid}}
{{datatype}} *{{name}}{{#hasMore}},{{/hasMore}}
{{/isUuid}}
{{#isEmail}}
{{datatype}} *{{name}}{{#hasMore}},{{/hasMore}}
{{/isEmail}}
{{#isFreeFormObject}}
{{datatype}}_t *{{name}}{{#hasMore}},{{/hasMore}}
{{/isFreeFormObject}}
{{/isPrimitiveType}}
{{#isPrimitiveType}}
{{#isNumeric}}
{{datatype}} {{name}}{{#hasMore}},{{/hasMore}}
{{/isNumeric}}
{{#isBoolean}}
{{datatype}} {{name}}{{#hasMore}},{{/hasMore}}
{{/isBoolean}}
{{#isEnum}}
{{#isString}}
{{name}}_e {{name}}{{#hasMore}},{{/hasMore}}
{{/isString}}
{{/isEnum}}
{{^isEnum}}
{{#isString}}
{{datatype}} *{{name}}{{#hasMore}},{{/hasMore}}
{{/isString}}
{{/isEnum}}
{{#isByteArray}}
{{datatype}} {{name}}{{#hasMore}},{{/hasMore}}
{{/isByteArray}}
{{#isBinary}}
{{datatype}} {{name}}{{#hasMore}},{{/hasMore}}
{{/isBinary}}
{{#isDate}}
{{datatype}} *{{name}}{{#hasMore}},{{/hasMore}}
{{/isDate}}
{{#isDateTime}}
{{datatype}} *{{name}}{{#hasMore}},{{/hasMore}}
{{/isDateTime}}
{{/isPrimitiveType}}
{{/isContainer}}
{{#isContainer}}
{{#isListContainer}}
{{#isPrimitiveType}}
{{datatype}}_t *{{name}}{{#hasMore}},{{/hasMore}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{datatype}}_t *{{name}}{{#hasMore}},{{/hasMore}}
{{/isPrimitiveType}}
{{/isListContainer}}
{{#isMapContainer}}
{{datatype}} {{name}}{{#hasMore}},{{/hasMore}}
{{/isMapContainer}}
{{/isContainer}}
{{/vars}}
) {
{{classname}}_t *{{classname}}_local_var = malloc(sizeof({{classname}}_t));
if (!{{classname}}_local_var) {
return NULL;
}
{{#vars}}
{{classname}}_local_var->{{{name}}} = {{{name}}};
{{/vars}}
return {{classname}}_local_var;
}
void {{classname}}_free({{classname}}_t *{{classname}}) {
listEntry_t *listEntry;
{{#vars}}
{{^isContainer}}
{{^isPrimitiveType}}
{{#isModel}}
{{^isEnum}}
{{{complexType}}}_free({{{classname}}}->{{{name}}});
{{/isEnum}}
{{/isModel}}
{{#isUuid}}
free({{{classname}}}->{{{name}}});
{{/isUuid}}
{{#isEmail}}
free({{{classname}}}->{{{name}}});
{{/isEmail}}
{{#isFreeFormObject}}
object_free({{{classname}}}->{{{name}}});
{{/isFreeFormObject}}
{{/isPrimitiveType}}
{{#isPrimitiveType}}
{{^isEnum}}
{{#isString}}
free({{{classname}}}->{{{name}}});
{{/isString}}
{{/isEnum}}
{{#isBinary}}
free({{{classname}}}->{{{name}}}->data);
{{/isBinary}}
{{#isDate}}
free({{{classname}}}->{{{name}}});
{{/isDate}}
{{#isDateTime}}
free({{{classname}}}->{{{name}}});
{{/isDateTime}}
{{/isPrimitiveType}}
{{/isContainer}}
{{#isContainer}}
{{#isListContainer}}
{{#isPrimitiveType}}
list_ForEach(listEntry, {{classname}}->{{name}}) {
free(listEntry->data);
}
list_free({{classname}}->{{name}});
{{/isPrimitiveType}}
{{^isPrimitiveType}}
list_ForEach(listEntry, {{classname}}->{{name}}) {
{{complexType}}_free(listEntry->data);
}
list_free({{classname}}->{{name}});
{{/isPrimitiveType}}
{{/isListContainer}}
{{#isMapContainer}}
list_ForEach(listEntry, {{classname}}->{{name}}) {
keyValuePair_t *localKeyValue = (keyValuePair_t*) listEntry->data;
free (localKeyValue->key);
free (localKeyValue->value);
}
list_free({{classname}}->{{name}});
{{/isMapContainer}}
{{/isContainer}}
{{/vars}}
free({{classname}});
}
cJSON *{{classname}}_convertToJSON({{classname}}_t *{{classname}}) {
cJSON *item = cJSON_CreateObject();
{{#vars}}
// {{{classname}}}->{{{name}}}
{{#required}}
{{^isEnum}}
if (!{{{classname}}}->{{{name}}}) {
goto fail;
}
{{/isEnum}}
{{/required}}
{{^required}}{{^isEnum}}if({{{classname}}}->{{{name}}}) { {{/isEnum}}{{/required}}
{{^isContainer}}
{{#isPrimitiveType}}
{{#isNumeric}}
if(cJSON_AddNumberToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
goto fail; //Numeric
}
{{/isNumeric}}
{{#isBoolean}}
if(cJSON_AddBoolToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
goto fail; //Bool
}
{{/isBoolean}}
{{#isEnum}}
{{#isString}}
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{name}}}{{classname}}_ToString({{{classname}}}->{{{name}}})) == NULL)
{
goto fail; //Enum
}
{{/isString}}
{{/isEnum}}
{{^isEnum}}
{{#isString}}
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
goto fail; //String
}
{{/isString}}
{{/isEnum}}
{{#isByteArray}}
if(cJSON_AddNumberToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
goto fail; //Byte
}
{{/isByteArray}}
{{#isBinary}}
char* encoded_str_{{{name}}} = base64encode({{{classname}}}->{{{name}}}->data,{{{classname}}}->{{{name}}}->len);
if(cJSON_AddStringToObject(item, "{{{baseName}}}", encoded_str_{{{name}}}) == NULL) {
goto fail; //Binary
}
free (encoded_str_{{{name}}});
{{/isBinary}}
{{#isDate}}
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
goto fail; //Date
}
{{/isDate}}
{{#isDateTime}}
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
goto fail; //Date-Time
}
{{/isDateTime}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isModel}}
{{#isEnum}}
cJSON *{{{name}}}_enum_local_JSON = {{datatypeWithEnum}}_convertToJSON({{{classname}}}->{{{name}}});
if({{{name}}}_enum_local_JSON == NULL) {
goto fail; // enum
}
cJSON_AddItemToObject(item, "{{{baseName}}}", {{{name}}}_enum_local_JSON);
if(item->child == NULL) {
goto fail;
}
{{/isEnum}}
{{^isEnum}}
cJSON *{{{name}}}_local_JSON = {{complexType}}{{#isFreeFormObject}}object{{/isFreeFormObject}}_convertToJSON({{{classname}}}->{{{name}}});
if({{{name}}}_local_JSON == NULL) {
goto fail; //model
}
cJSON_AddItemToObject(item, "{{{baseName}}}", {{{name}}}_local_JSON);
if(item->child == NULL) {
goto fail;
}
{{/isEnum}}
{{/isModel}}
{{#isUuid}}
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
goto fail; //uuid
}
{{/isUuid}}
{{#isEmail}}
if(cJSON_AddStringToObject(item, "{{{baseName}}}", {{{classname}}}->{{{name}}}) == NULL) {
goto fail; //Email
}
{{/isEmail}}
{{#isFreeFormObject}}
cJSON *{{{name}}}_object = object_convertToJSON({{{classname}}}->{{{name}}});
if({{{name}}}_object == NULL) {
goto fail; //model
}
cJSON_AddItemToObject(item, "{{{baseName}}}", {{{name}}}_object);
if(item->child == NULL) {
goto fail;
}
{{/isFreeFormObject}}
{{/isPrimitiveType}}
{{/isContainer}}
{{#isContainer}}
{{#isListContainer}}
{{#isPrimitiveType}}
cJSON *{{{name}}} = cJSON_AddArrayToObject(item, "{{{baseName}}}");
if({{{name}}} == NULL) {
goto fail; //primitive container
}
listEntry_t *{{{name}}}ListEntry;
list_ForEach({{{name}}}ListEntry, {{{classname}}}->{{{name}}}) {
{{#items}}
{{#isString}}
if(cJSON_AddStringToObject({{{name}}}, "", (char*){{{name}}}ListEntry->data) == NULL)
{
goto fail;
}
{{/isString}}
{{^isString}}
if(cJSON_AddNumberToObject({{{name}}}, "", *(double *){{{name}}}ListEntry->data) == NULL)
{
goto fail;
}
{{/isString}}
{{/items}}
}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
cJSON *{{{name}}} = cJSON_AddArrayToObject(item, "{{{baseName}}}");
if({{{name}}} == NULL) {
goto fail; //nonprimitive container
}
listEntry_t *{{{name}}}ListEntry;
if ({{{classname}}}->{{{name}}}) {
list_ForEach({{{name}}}ListEntry, {{classname}}->{{{name}}}) {
cJSON *itemLocal = {{complexType}}_convertToJSON({{#isEnum}}{{#items}}({{datatypeWithEnum}}_e){{/items}}{{/isEnum}}{{{name}}}ListEntry->data);
if(itemLocal == NULL) {
goto fail;
}
cJSON_AddItemToArray({{{name}}}, itemLocal);
}
}
{{/isPrimitiveType}}
{{/isListContainer}}
{{#isMapContainer}}
cJSON *{{{name}}} = cJSON_AddObjectToObject(item, "{{{baseName}}}");
if({{{name}}} == NULL) {
goto fail; //primitive map container
}
cJSON *localMapObject = {{{name}}};
listEntry_t *{{{name}}}ListEntry;
if ({{{classname}}}->{{{name}}}) {
list_ForEach({{{name}}}ListEntry, {{{classname}}}->{{{name}}}) {
keyValuePair_t *localKeyValue = (keyValuePair_t*){{{name}}}ListEntry->data;
{{#items}}
{{#isString}}
if(cJSON_AddStringToObject(localMapObject, localKeyValue->key, (char*)localKeyValue->value) == NULL)
{
goto fail;
}
{{/isString}}
{{^isString}}
if(cJSON_AddNumberToObject(localMapObject, localKeyValue->key, *(double *)localKeyValue->value) == NULL)
{
goto fail;
}
{{/isString}}
{{/items}}
}
}
{{/isMapContainer}}
{{/isContainer}}
{{^required}}
{{^isEnum}} } {{/isEnum}}
{{/required}}
{{/vars}}
return item;
fail:
if (item) {
cJSON_Delete(item);
}
return NULL;
}
{{classname}}_t *{{classname}}_parseFromJSON(cJSON *{{classname}}JSON){
{{classname}}_t *{{classname}}_local_var = NULL;
{{#vars}}
// {{{classname}}}->{{{name}}}
cJSON *{{{name}}} = cJSON_GetObjectItemCaseSensitive({{classname}}JSON, "{{{baseName}}}");
{{#required}}
if (!{{{name}}}) {
goto end;
}
{{/required}}
{{^isContainer}}
{{#isPrimitiveType}}
{{#isNumeric}}
{{^required}}if ({{{name}}}) { {{/required}}
if(!cJSON_IsNumber({{{name}}}))
{
goto end; //Numeric
}
{{/isNumeric}}
{{#isBoolean}}
{{^required}}if ({{{name}}}) { {{/required}}
if(!cJSON_IsBool({{{name}}}))
{
goto end; //Bool
}
{{/isBoolean}}
{{#isEnum}}
{{#isString}}
{{{name}}}_e {{name}}Variable;
{{^required}}if ({{{name}}}) { {{/required}}
if(!cJSON_IsString({{{name}}}))
{
goto end; //Enum
}
{{name}}Variable = {{name}}{{classname}}_FromString({{{name}}}->valuestring);
{{/isString}}
{{/isEnum}}
{{^isEnum}}
{{#isString}}
{{^required}}if ({{{name}}}) { {{/required}}
if(!cJSON_IsString({{{name}}}))
{
goto end; //String
}
{{/isString}}
{{/isEnum}}
{{#isByteArray}}
{{^required}}if ({{{name}}}) { {{/required}}
if(!cJSON_IsNumber({{{name}}}))
{
goto end; //Byte
}
{{/isByteArray}}
{{#isBinary}}
binary_t* decoded_str_{{{name}}};
{{^required}}if ({{{name}}}) { {{/required}}
if(!cJSON_IsString({{{name}}}))
{
goto end; //Binary
}
char* decoded = base64decode({{{name}}}->valuestring, strlen({{{name}}}->valuestring));
decoded_str_{{{name}}}->data = malloc(strlen(decoded) - 1);
if (!decoded_str_{{{name}}}->data) {
goto end;
}
memcpy(decoded_str_{{{name}}}->data,decoded,(strlen(decoded)-1));
decoded_str_{{{name}}}->len = strlen(decoded) - 1;
{{/isBinary}}
{{#isDate}}
{{^required}}if ({{{name}}}) { {{/required}}
if(!cJSON_IsString({{{name}}}))
{
goto end; //Date
}
{{/isDate}}
{{#isDateTime}}
{{^required}}if ({{{name}}}) { {{/required}}
if(!cJSON_IsString({{{name}}}))
{
goto end; //DateTime
}
{{/isDateTime}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isModel}}
{{#isEnum}}
{{datatypeWithEnum}}_e {{name}}_local_nonprim_enum;
{{^required}}if ({{{name}}}) { {{/required}}
{{{name}}}_local_nonprim_enum = {{datatypeWithEnum}}_parseFromJSON({{{name}}}); //enum model
{{/isEnum}}
{{^isEnum}}
{{^isFreeFormObject}}{{complexType}}{{/isFreeFormObject}}{{#isFreeFormObject}}object{{/isFreeFormObject}}_t *{{name}}_local_nonprim = NULL;
{{^required}}if ({{{name}}}) { {{/required}}
{{{name}}}_local_nonprim = {{complexType}}{{#isFreeFormObject}}object{{/isFreeFormObject}}_parseFromJSON({{{name}}}); //nonprimitive
{{/isEnum}}
{{/isModel}}
{{#isUuid}}
{{^required}}if ({{{name}}}) { {{/required}}
if(!cJSON_IsString({{{name}}}))
{
goto end; //uuid
}
{{/isUuid}}
{{#isEmail}}
{{^required}}if ({{{name}}}) { {{/required}}
if(!cJSON_IsString({{{name}}}))
{
goto end; //email
}
{{/isEmail}}
{{#isFreeFormObject}}
object_t *{{name}}_local_object = NULL;
{{^required}}if ({{{name}}}) { {{/required}}
{{{name}}}_local_object = object_parseFromJSON({{{name}}}); //object
{{/isFreeFormObject}}
{{/isPrimitiveType}}
{{/isContainer}}
{{#isContainer}}
{{#isListContainer}}
{{#isPrimitiveType}}
list_t *{{{name}}}List;
{{^required}}if ({{{name}}}) { {{/required}}
cJSON *{{{name}}}_local;
if(!cJSON_IsArray({{{name}}})) {
goto end;//primitive container
}
{{{name}}}List = list_create();
cJSON_ArrayForEach({{{name}}}_local, {{{name}}})
{
{{#items}}
{{#isString}}
if(!cJSON_IsString({{{name}}}_local))
{
goto end;
}
list_addElement({{{name}}}List , strdup({{{name}}}_local->valuestring));
{{/isString}}
{{^isString}}
if(!cJSON_IsNumber({{{name}}}_local))
{
goto end;
}
list_addElement({{{name}}}List , &{{{name}}}_local->valuedouble);
{{/isString}}
{{/items}}
}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
list_t *{{{name}}}List;
{{^required}}if ({{{name}}}) { {{/required}}
cJSON *{{{name}}}_local_nonprimitive;
if(!cJSON_IsArray({{{name}}})){
goto end; //nonprimitive container
}
{{{name}}}List = list_create();
cJSON_ArrayForEach({{{name}}}_local_nonprimitive,{{{name}}} )
{
if(!cJSON_IsObject({{{name}}}_local_nonprimitive)){
goto end;
}
{{#isEnum}}{{#items}}{{datatypeWithEnum}}_e {{/items}}{{/isEnum}}{{^isEnum}}{{complexType}}_t *{{/isEnum}}{{{name}}}Item = {{complexType}}_parseFromJSON({{{name}}}_local_nonprimitive);
list_addElement({{{name}}}List, {{#isEnum}}{{#items}}(void *){{/items}}{{/isEnum}}{{{name}}}Item);
}
{{/isPrimitiveType}}
{{/isListContainer}}
{{#isMapContainer}}
list_t *{{{name}}}List;
{{^required}}if ({{{name}}}) { {{/required}}
cJSON *{{{name}}}_local_map;
if(!cJSON_IsObject({{{name}}})) {
goto end;//primitive map container
}
{{{name}}}List = list_create();
keyValuePair_t *localMapKeyPair;
cJSON_ArrayForEach({{{name}}}_local_map, {{{name}}})
{
cJSON *localMapObject = {{{name}}}_local_map;
{{#items}}
{{#isString}}
if(!cJSON_IsString(localMapObject))
{
goto end;
}
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),strdup(localMapObject->valuestring));
{{/isString}}
{{^isString}}
if(!cJSON_IsNumber(localMapObject))
{
goto end;
}
localMapKeyPair = keyValuePair_create(strdup(localMapObject->string),&localMapObject->valuedouble );
{{/isString}}
{{/items}}
list_addElement({{{name}}}List , localMapKeyPair);
}
{{/isMapContainer}}
{{/isContainer}}
{{^required}}
}
{{/required}}
{{/vars}}
{{classname}}_local_var = {{classname}}_create (
{{#vars}}
{{^isContainer}}
{{^isPrimitiveType}}
{{#isModel}}
{{#isEnum}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_nonprim_enum{{^required}} : -1{{/required}}{{#hasMore}},{{/hasMore}}
{{/isEnum}}
{{^isEnum}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_nonprim{{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isEnum}}
{{/isModel}}
{{#isUuid}}
{{^required}}{{{name}}} ? {{/required}}strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isUuid}}
{{#isEmail}}
{{^required}}{{{name}}} ? {{/required}}strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isEmail}}
{{#isFreeFormObject}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_object{{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isFreeFormObject}}
{{/isPrimitiveType}}
{{#isPrimitiveType}}
{{#isNumeric}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}->valuedouble{{^required}} : 0{{/required}}{{#hasMore}},{{/hasMore}}
{{/isNumeric}}
{{#isBoolean}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}->valueint{{^required}} : 0{{/required}}{{#hasMore}},{{/hasMore}}
{{/isBoolean}}
{{#isEnum}}
{{#isString}}
{{^required}}{{{name}}} ? {{/required}}{{name}}Variable{{^required}} : -1{{/required}}{{#hasMore}},{{/hasMore}}
{{/isString}}
{{/isEnum}}
{{^isEnum}}
{{#isString}}
{{^required}}{{{name}}} ? {{/required}}strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isString}}
{{/isEnum}}
{{#isByteArray}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}->valueint{{^required}} : 0{{/required}}{{#hasMore}},{{/hasMore}}
{{/isByteArray}}
{{#isBinary}}
{{^required}}{{{name}}} ? {{/required}}decoded_str_{{{name}}}{{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isBinary}}
{{#isDate}}
{{^required}}{{{name}}} ? {{/required}}strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isDate}}
{{#isDateTime}}
{{^required}}{{{name}}} ? {{/required}}strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isDateTime}}
{{/isPrimitiveType}}
{{/isContainer}}
{{#isContainer}}
{{#isListContainer}}
{{#isPrimitiveType}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}List{{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}List{{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isPrimitiveType}}
{{/isListContainer}}
{{#isMapContainer}}
{{^required}}{{{name}}} ? {{/required}}{{{name}}}List{{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
{{/isMapContainer}}
{{/isContainer}}
{{/vars}}
);
return {{classname}}_local_var;
end:
return NULL;
}
{{/isEnum}}
{{/model}}
{{/models}}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy