rollback tizen template

This commit is contained in:
wing328
2015-06-09 13:00:42 +08:00
parent 410144ea1c
commit 6617af5209
12 changed files with 747 additions and 766 deletions

View File

@@ -9,123 +9,123 @@ namespace Swagger {
{{#operations}}
{{classname}}::{{classname}}() {
{{classname}}::{{classname}}() {
}
{{classname}}::~{{classname}}() {
}
{{#operation}}
void
{{nickname}}Processor(HttpResponse* pHttpResponse, void (* handler)(void*, {{prefix}}Error*)) {
int code = pHttpResponse->GetHttpStatusCode();
if(code >= 200 && code < 300) {
{{#returnType}}ByteBuffer* pBuffer = pHttpResponse->ReadBodyN();
IJsonValue* pJson = JsonParser::ParseN(*pBuffer);
{{{returnType}}} out = {{{defaultResponse}}};
jsonToValue(out, pJson, L"{{returnType}}", L"{{returnBaseType}}");
if (pJson) {
if (pJson->GetType() == JSON_TYPE_OBJECT) {
JsonObject* pObject = static_cast< JsonObject* >(pJson);
pObject->RemoveAll(true);
}
else if (pJson->GetType() == JSON_TYPE_ARRAY) {
JsonArray* pArray = static_cast< JsonArray* >(pJson);
pArray->RemoveAll(true);
}
handler(out, null);
}
{{classname}}::~{{classname}}() {
else {
{{prefix}}Error* error = new {{prefix}}Error(0, new String(L"No parsable response received"));
handler(null, error);
}
{{/returnType}}{{^returnType}}handler(null, null);{{/returnType}}
}
else {
{{prefix}}Error* error = new {{prefix}}Error(code, new String(pHttpResponse->GetStatusText()));
{{#returnType}}handler(null, error);{{/returnType}}
{{^returnType}}handler(error, null);{{/returnType}}
}
}
{{#operation}}
void
{{nickname}}Processor(HttpResponse* pHttpResponse, void (* handler)(void*, {{prefix}}Error*)) {
int code = pHttpResponse->GetHttpStatusCode();
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}
{{classname}}::{{nickname}}WithCompletion({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}},{{/hasParams}} {{#returnType}}void (* success)({{returnType}}, {{prefix}}Error*){{/returnType}}{{^returnType}}void(*success)({{prefix}}Error*){{/returnType}}) {
client = new {{prefix}}ApiClient();
if(code >= 200 && code < 300) {
{{#returnType}}ByteBuffer* pBuffer = pHttpResponse->ReadBodyN();
IJsonValue* pJson = JsonParser::ParseN(*pBuffer);
client->success(&{{nickname}}Processor, (void(*)(void*, {{prefix}}Error*))success);
HashMap* headerParams = new HashMap(SingleObjectDeleter);
headerParams->Construct();
{{{returnType}}} out = {{{defaultResponse}}};
jsonToValue(out, pJson, L"{{returnType}}", L"{{returnBaseType}}");
{{#headerParams}}{{#collectionFormat}}
int sz = {{paramName}}->GetCount();
for(int i = 0; i < sz; i++) {
String itemAt = stringify({{paramName}}->GetAt(i), "{{baseType}}");
headerParams->Add(new String("{{paramName}}"), new String(itemAt));
}
{{/collectionFormat}}{{^collectionFormat}}
headerParams->Add(new String("{{baseName}}"), {{paramName}});
{{/collectionFormat}}
{{/headerParams}}
if (pJson) {
if (pJson->GetType() == JSON_TYPE_OBJECT) {
JsonObject* pObject = static_cast< JsonObject* >(pJson);
pObject->RemoveAll(true);
}
else if (pJson->GetType() == JSON_TYPE_ARRAY) {
JsonArray* pArray = static_cast< JsonArray* >(pJson);
pArray->RemoveAll(true);
}
handler(out, null);
}
else {
{{prefix}}Error* error = new {{prefix}}Error(0, new String(L"No parsable response received"));
handler(null, error);
}
{{/returnType}}{{^returnType}}handler(null, null);{{/returnType}}
}
else {
{{prefix}}Error* error = new {{prefix}}Error(code, new String(pHttpResponse->GetStatusText()));
{{#returnType}}handler(null, error);{{/returnType}}
{{^returnType}}handler(error, null);{{/returnType}}
}
}
HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct();
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}
{{classname}}::{{nickname}}WithCompletion({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}},{{/hasParams}} {{#returnType}}void (* success)({{returnType}}, {{prefix}}Error*){{/returnType}}{{^returnType}}void(*success)({{prefix}}Error*){{/returnType}}) {
client = new {{prefix}}ApiClient();
{{#queryParams}}{{#collectionFormat}}
int sz = {{paramName}}->GetCount();
for(int i = 0; i < sz; i++) {
String itemAt = stringify({{paramName}}->GetAt(i), "{{baseType}}");
queryParams->Add(new String("{{paramName}}"), new String(itemAt));
}
{{/collectionFormat}}{{^collectionFormat}}
queryParams->Add(new String("{{baseName}}"), {{paramName}});
{{/collectionFormat}}
{{/queryParams}}
client->success(&{{nickname}}Processor, (void(*)(void*, {{prefix}}Error*))success);
HashMap* headerParams = new HashMap(SingleObjectDeleter);
headerParams->Construct();
String* mBody = null;
{{#headerParams}}{{#collectionFormat}}
int sz = {{paramName}}->GetCount();
for(int i = 0; i < sz; i++) {
String itemAt = stringify({{paramName}}->GetAt(i), "{{baseType}}");
headerParams->Add(new String("{{paramName}}"), new String(itemAt));
}
{{/collectionFormat}}{{^collectionFormat}}
headerParams->Add(new String("{{baseName}}"), {{paramName}});
{{/collectionFormat}}
{{/headerParams}}
{{#bodyParams}}
{{#isContainer}}
if({{paramName}} != null) {
mBody = new String("");
int sz = {{paramName}}->GetCount();
for(int i = 0; i < sz; i++) {
{{prefix}}Object * obj = ({{prefix}}Object*){{paramName}}->GetAt(i);
String json = obj->asJson();
if(i > 0)
mBody->Append(",");
mBody->Append(json);
}
mBody->Append("]");
headerParams->Add(new String("Content-Type"), new String("application/json"));
}
{{/isContainer}}
{{^isContainer}}
if({{paramName}} != null) {
mBody = new String({{paramName}}->asJson());
headerParams->Add(new String("Content-Type"), new String("application/json"));
}
{{/isContainer}}
{{/bodyParams}}
HashMap* queryParams = new HashMap(SingleObjectDeleter);
queryParams->Construct();
String url(L"{{{path}}}");
{{#queryParams}}{{#collectionFormat}}
int sz = {{paramName}}->GetCount();
for(int i = 0; i < sz; i++) {
String itemAt = stringify({{paramName}}->GetAt(i), "{{baseType}}");
queryParams->Add(new String("{{paramName}}"), new String(itemAt));
}
{{/collectionFormat}}{{^collectionFormat}}
queryParams->Add(new String("{{baseName}}"), {{paramName}});
{{/collectionFormat}}
{{/queryParams}}
{{#pathParams}}
String s_{{paramName}}(L"{");
s_{{paramName}}.Append(L"{{{baseName}}}");
s_{{paramName}}.Append(L"}");
url.Replace(s_{{paramName}}, stringify({{{paramName}}}, L"{{dataType}}"));
{{/pathParams}}
String* mBody = null;
client->execute({{classname}}::getBasePath(), url, "{{httpMethod}}", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
{{#returnType}}return null;{{/returnType}}
}
{{#bodyParams}}
{{#isContainer}}
if({{paramName}} != null) {
mBody = new String("");
int sz = {{paramName}}->GetCount();
for(int i = 0; i < sz; i++) {
{{prefix}}Object * obj = ({{prefix}}Object*){{paramName}}->GetAt(i);
String json = obj->asJson();
if(i > 0)
mBody->Append(",");
mBody->Append(json);
}
mBody->Append("]");
headerParams->Add(new String("Content-Type"), new String("application/json"));
}
{{/isContainer}}
{{^isContainer}}
if({{paramName}} != null) {
mBody = new String({{paramName}}->asJson());
headerParams->Add(new String("Content-Type"), new String("application/json"));
}
{{/isContainer}}
{{/bodyParams}}
String url(L"{{{path}}}");
{{#pathParams}}
String s_{{paramName}}(L"{");
s_{{paramName}}.Append(L"{{{baseName}}}");
s_{{paramName}}.Append(L"}");
url.Replace(s_{{paramName}}, stringify({{{paramName}}}, L"{{dataType}}"));
{{/pathParams}}
client->execute({{classname}}::getBasePath(), url, "{{httpMethod}}", (IMap*)queryParams, mBody, (IMap*)headerParams, null, L"application/json");
{{#returnType}}return null;{{/returnType}}
}
{{/operation}}
{{/operation}}
{{/operations}}
} /* namespace Swagger */

View File

@@ -1,40 +1,37 @@
#ifndef {{classname}}_H_
#define {{classname}}_H_
#include
<FNet.h>
#include "{{prefix}}ApiClient.h"
#include "{{prefix}}Error.h"
#include <FNet.h>
#include "{{prefix}}ApiClient.h"
#include "{{prefix}}Error.h"
{{#imports}}{{{import}}}
{{/imports}}
{{#imports}}{{{import}}}
{{/imports}}
using namespace Tizen::Net::Http;
using namespace Tizen::Net::Http;
namespace Swagger {
namespace Swagger {
{{#operations}}
class {{classname}} {
public:
{{classname}}();
virtual ~{{classname}}();
{{#operations}}
class {{classname}} {
public:
{{classname}}();
virtual ~{{classname}}();
{{#operation}}
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}
{{nickname}}WithCompletion({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}
, {{/hasMore}}{{/allParams}}{{#hasParams}},{{/hasParams}} {{#returnType}}void (* handler)({{returnType}}
, {{prefix}}Error*){{/returnType}}{{^returnType}}void(* handler)({{prefix}}Error*){{/returnType}});
{{/operation}}
static String getBasePath() {
return L"{{basePath}}";
}
{{#operation}}
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}
{{nickname}}WithCompletion({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}},{{/hasParams}} {{#returnType}}void (* handler)({{returnType}}, {{prefix}}Error*){{/returnType}}{{^returnType}}void(* handler)({{prefix}}Error*){{/returnType}});
{{/operation}}
static String getBasePath() {
return L"{{basePath}}";
}
private:
{{prefix}}ApiClient* client;
};
private:
{{prefix}}ApiClient* client;
};
{{/operations}}
} /* namespace Swagger */
{{/operations}}
} /* namespace Swagger */
#endif /* {{classname}}_H_ */
#endif /* {{classname}}_H_ */

View File

@@ -5,120 +5,120 @@ using namespace Tizen::Base::Utility;
namespace Swagger {
{{prefix}}ApiClient::{{prefix}}ApiClient() {
enc = new Utf8Encoding();
enc = new Utf8Encoding();
}
void
{{prefix}}ApiClient::success(void (*success) (HttpResponse*, void (*cb)(void*, {{prefix}}Error*)), void (*cb)(void*, {{prefix}}Error*)) {
this->successFunction = success;
this->cb = cb;
this->successFunction = success;
this->cb = cb;
}
{{prefix}}ApiClient::~{{prefix}}ApiClient() {
if(enc)
delete enc;
if(enc)
delete enc;
}
result
{{prefix}}ApiClient::execute(String host, String path, String method, IMap* queryParams, String* body, IMap* headerParams, IMap* formParams, String contentType) {
NetHttpMethod httpMethod;
if(method.Equals(L"GET", false)) {
httpMethod = NET_HTTP_METHOD_GET;
}
else if(method.Equals(L"PUT", false)) {
httpMethod = NET_HTTP_METHOD_PUT;
}
else if(method.Equals(L"POST", false)) {
httpMethod = NET_HTTP_METHOD_POST;
}
else if(method.Equals(L"DELETE", false)) {
httpMethod = NET_HTTP_METHOD_DELETE;
}
else if(method.Equals(L"OPTIONS", false)) {
httpMethod = NET_HTTP_METHOD_OPTIONS;
}
else if(method.Equals(L"HEAD", false)) {
httpMethod = NET_HTTP_METHOD_HEAD;
}
else if(method.Equals(L"TRACE", false)) {
httpMethod = NET_HTTP_METHOD_TRACE;
}
NetHttpMethod httpMethod;
if(method.Equals(L"GET", false)) {
httpMethod = NET_HTTP_METHOD_GET;
}
else if(method.Equals(L"PUT", false)) {
httpMethod = NET_HTTP_METHOD_PUT;
}
else if(method.Equals(L"POST", false)) {
httpMethod = NET_HTTP_METHOD_POST;
}
else if(method.Equals(L"DELETE", false)) {
httpMethod = NET_HTTP_METHOD_DELETE;
}
else if(method.Equals(L"OPTIONS", false)) {
httpMethod = NET_HTTP_METHOD_OPTIONS;
}
else if(method.Equals(L"HEAD", false)) {
httpMethod = NET_HTTP_METHOD_HEAD;
}
else if(method.Equals(L"TRACE", false)) {
httpMethod = NET_HTTP_METHOD_TRACE;
}
String uri = String(host);
uri.Append(path);
String uri = String(host);
uri.Append(path);
HttpSession* __pHttpSession = null;
HttpTransaction* pHttpTransaction = null;
HttpRequest* pHttpRequest = null;
HttpSession* __pHttpSession = null;
HttpTransaction* pHttpTransaction = null;
HttpRequest* pHttpRequest = null;
if (__pHttpSession == null) {
__pHttpSession = new (std::nothrow) HttpSession();
__pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, uri, null);
__pHttpSession->SetAutoRedirectionEnabled(true);
}
pHttpTransaction = __pHttpSession->OpenTransactionN();
pHttpTransaction->AddHttpTransactionListener(*this);
if (__pHttpSession == null) {
__pHttpSession = new (std::nothrow) HttpSession();
__pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, uri, null);
__pHttpSession->SetAutoRedirectionEnabled(true);
}
pHttpTransaction = __pHttpSession->OpenTransactionN();
pHttpTransaction->AddHttpTransactionListener(*this);
pHttpRequest = const_cast< HttpRequest* >(pHttpTransaction->GetRequest());
pHttpRequest = const_cast< HttpRequest* >(pHttpTransaction->GetRequest());
HttpHeader *pHeader = pHttpRequest->GetHeader();
if(contentType != null && !contentType.Equals(L"", true)) {
pHeader->AddField(L"Accept", contentType);
}
if(queryParams != null) {
IMapEnumerator* pMapEnum = queryParams->GetMapEnumeratorN();
String queryParam = L"";
while (pMapEnum->MoveNext() == E_SUCCESS) {
if(queryParam.GetLength() == 0)
queryParam.Append(L"?");
else
queryParam.Append(L"&");
HttpHeader *pHeader = pHttpRequest->GetHeader();
if(contentType != null && !contentType.Equals(L"", true)) {
pHeader->AddField(L"Accept", contentType);
}
if(queryParams != null) {
IMapEnumerator* pMapEnum = queryParams->GetMapEnumeratorN();
String queryParam = L"";
while (pMapEnum->MoveNext() == E_SUCCESS) {
if(queryParam.GetLength() == 0)
queryParam.Append(L"?");
else
queryParam.Append(L"&");
String* pKey = static_cast< String* > (pMapEnum->GetKey());
String* pValue = static_cast< String* > (pMapEnum->GetValue());
String encoded;
UrlEncoder::Encode(*pKey, L"UTF-8", encoded);
String* pKey = static_cast< String* > (pMapEnum->GetKey());
String* pValue = static_cast< String* > (pMapEnum->GetValue());
String encoded;
UrlEncoder::Encode(*pKey, L"UTF-8", encoded);
queryParam.Append(encoded);
queryParam.Append("=");
UrlEncoder::Encode(*pValue, L"UTF-8", encoded);
queryParam.Append(encoded);
}
uri.Append(queryParam);
delete queryParams;
}
if(headerParams != null) {
IMapEnumerator* pMapEnum = headerParams->GetMapEnumeratorN();
while (pMapEnum->MoveNext() == E_SUCCESS) {
String* pKey = static_cast< String* > (pMapEnum->GetKey());
String* pValue = static_cast< String* > (pMapEnum->GetValue());
pHeader->AddField(*pKey, *pValue);
}
delete headerParams;
}
if(body != null) {
HttpStringEntity * pEntity = new HttpStringEntity();
String* cp = new String(*body);
result res = pEntity->Construct(*body, L"application/json", "utf-8", *enc);
res = pHttpRequest->SetEntity(*pEntity);
}
queryParam.Append(encoded);
queryParam.Append("=");
UrlEncoder::Encode(*pValue, L"UTF-8", encoded);
queryParam.Append(encoded);
}
uri.Append(queryParam);
delete queryParams;
}
if(headerParams != null) {
IMapEnumerator* pMapEnum = headerParams->GetMapEnumeratorN();
while (pMapEnum->MoveNext() == E_SUCCESS) {
String* pKey = static_cast< String* > (pMapEnum->GetKey());
String* pValue = static_cast< String* > (pMapEnum->GetValue());
pHeader->AddField(*pKey, *pValue);
}
delete headerParams;
}
if(body != null) {
HttpStringEntity * pEntity = new HttpStringEntity();
String* cp = new String(*body);
result res = pEntity->Construct(*body, L"application/json", "utf-8", *enc);
res = pHttpRequest->SetEntity(*pEntity);
}
pHttpRequest->SetUri(uri);
pHttpRequest->SetMethod(httpMethod);
pHttpRequest->SetUri(uri);
pHttpRequest->SetMethod(httpMethod);
AppLog("%ls", uri.GetPointer());
return pHttpTransaction->Submit();
AppLog("%ls", uri.GetPointer());
return pHttpTransaction->Submit();
}
void
{{prefix}}ApiClient::OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& pHttpTransaction) {
HttpResponse* pHttpResponse = pHttpTransaction.GetResponse();
HttpResponse* pHttpResponse = pHttpTransaction.GetResponse();
if(successFunction != null) {
successFunction(pHttpResponse, cb);
}
delete &httpSession;
delete &pHttpTransaction;
if(successFunction != null) {
successFunction(pHttpResponse, cb);
}
delete &httpSession;
delete &pHttpTransaction;
}
} /* namespace Swagger */

View File

@@ -1,75 +1,73 @@
#include
<FNet.h>
#include <FNet.h>
#include "{{prefix}}Helpers.h"
#include "{{prefix}}Error.h"
#include "{{prefix}}Helpers.h"
#include "{{prefix}}Error.h"
using namespace Tizen::Net::Http;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Text;
using namespace Tizen::Net::Http;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Text;
#ifndef APICLIENT_H_
#define APICLIENT_H_
#ifndef APICLIENT_H_
#define APICLIENT_H_
namespace Swagger {
namespace Swagger {
class {{prefix}}ApiClient: public IHttpTransactionEventListener {
public:
{{prefix}}ApiClient();
virtual ~{{prefix}}ApiClient();
class {{prefix}}ApiClient: public IHttpTransactionEventListener {
public:
{{prefix}}ApiClient();
virtual ~{{prefix}}ApiClient();
result
execute(String host, String path, String method, IMap* queryParams, String* body, IMap* headerParams, IMap*
formParams, String contentType);
result
execute(String host, String path, String method, IMap* queryParams, String* body, IMap* headerParams, IMap* formParams, String contentType);
void success(void (*res) (HttpResponse*, void (*cb)(void*, {{prefix}}Error*)), void (*cb)(void*, {{prefix}}Error*));
void success(void (*res) (HttpResponse*, void (*cb)(void*, {{prefix}}Error*)), void (*cb)(void*, {{prefix}}Error*));
virtual void
OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& pHttpTransaction);
virtual void
OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& pHttpTransaction);
virtual void
OnAudioInAudioFocusChanged(void) {
virtual void
OnAudioInAudioFocusChanged(void) {
AppLog("OnAudioInAudioFocusChanged");
}
}
virtual void
OnTransactionCertVerificationRequiredN(HttpSession& httpSession, HttpTransaction& httpTransaction,
Tizen::Base::String* pCert) {
virtual void
OnTransactionCertVerificationRequiredN(HttpSession& httpSession, HttpTransaction& httpTransaction,
Tizen::Base::String* pCert) {
AppLog("OnTransactionCertVerificationRequiredN");
httpTransaction.Resume();
delete pCert;
}
virtual void
OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction, int recommendedChunkSize) {
}
virtual void
OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction, int recommendedChunkSize) {
AppLog("OnTransactionReadyToWrite");
}
}
virtual void
OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen) {
virtual void
OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen) {
AppLog("OnTransactionReadyToRead");
}
virtual void
OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result r) {
}
virtual void
OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result r) {
AppLog("OnTransactionAborted: %ls", GetErrorMessage(r));
delete &httpTransaction;
}
virtual void
OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool
bAuthRequired) {
}
virtual void
OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool
bAuthRequired) {
AppLog("OnTransactionHeaderCompleted");
}
}
private:
void (*successFunction) (HttpResponse*, void (*success)(void*, {{prefix}}Error*));
void (*cb)(void*, {{prefix}}Error*);
Utf8Encoding* enc;
};
private:
void (*successFunction) (HttpResponse*, void (*success)(void*, {{prefix}}Error*));
void (*cb)(void*, {{prefix}}Error*);
Utf8Encoding* enc;
};
} /* namespace Swagger */
#endif /* APICLIENT_H_ */
} /* namespace Swagger */
#endif /* APICLIENT_H_ */

View File

@@ -6,49 +6,49 @@ using namespace Tizen::System;
namespace Swagger {
{{prefix}}Error::{{prefix}}Error() {
init();
init();
}
{{prefix}}Error::{{prefix}}Error(int code, String* message) {
init();
this->setCode(code);
this->setMessage(message);
init();
this->setCode(code);
this->setMessage(message);
}
{{prefix}}Error::~{{prefix}}Error() {
this->cleanup();
this->cleanup();
}
void
{{prefix}}Error::init() {
pCode = 0;
pMessage = null;
pCode = 0;
pMessage = null;
}
void
{{prefix}}Error::cleanup() {
if(pMessage != null) {
delete pMessage;
pMessage = null;
}
if(pMessage != null) {
delete pMessage;
pMessage = null;
}
}
int
{{prefix}}Error::getCode() {
return pCode;
return pCode;
}
void
{{prefix}}Error::setCode(int pCode) {
this->pCode = pCode;
this->pCode = pCode;
}
String*
{{prefix}}Error::getMessage() {
return pMessage;
return pMessage;
}
void
{{prefix}}Error::setMessage(String* pMessage) {
this->pMessage = pMessage;
this->pMessage = pMessage;
}
} /* namespace Swagger */

View File

@@ -1,15 +1,14 @@
#ifndef {{prefix}}Error_H_
#define {{prefix}}Error_H_
#include
<FBase.h>
#include <FBase.h>
using namespace Tizen::Base;
using namespace Tizen::Base;
namespace Swagger {
namespace Swagger {
class {{prefix}}Error {
public:
class {{prefix}}Error {
public:
{{prefix}}Error();
{{prefix}}Error(int code, String* message);
virtual ~{{prefix}}Error();
@@ -21,16 +20,16 @@
int getCode();
void setCode(int pCode);
String* getMessage();
void setMessage(String* pMessage);
private:
private:
int pCode;
String* pMessage;
};
};
} /* namespace Swagger */
} /* namespace Swagger */
#endif /* {{prefix}}Error_H_ */
#endif /* {{prefix}}Error_H_ */

View File

@@ -9,265 +9,265 @@ using namespace Tizen::Locales;
using namespace Tizen::System;
namespace Swagger {
JsonObject*
toJson(void* ptr, String type, String containerType) {
if(ptr == null)
return null;
if(containerType != null && !type.Equals(L"", false)) {
if(containerType.Equals(L"array", false)) {
if(type != null) {
IList* list = static_cast< IList* >(ptr);
JsonArray* array = new JsonArray();
int sz = list->GetCount();
for(int i = 0; i < sz; i++) {
void* itemAt = list->GetAt(i);
JsonObject* item = toJson(itemAt, type, null);
if(item != null)
array->Add(item);
}
return (JsonObject*)array;
}
return null;
}
}
else if(type.Equals(L"Boolean", false)) {
Boolean* v = static_cast< Boolean* >(ptr);
return (JsonObject*) new JsonBool(*v);
}
else if(type.Equals(L"String", false)) {
String* v = static_cast< String* >(ptr);
return (JsonObject*) new JsonString(*v);
}
else if(type.Equals(L"Integer", false)) {
Integer* v = static_cast< Integer* >(ptr);
return (JsonObject*) new JsonNumber(v->ToInt());
}
else if(type.Equals(L"Long", false)) {
Long* v = static_cast< Long* >(ptr);
return (JsonObject*) new JsonNumber(v->ToInt());
}
else if(type.Equals(L"Float", false)) {
Float* v = static_cast< Float* >(ptr);
return (JsonObject*) new JsonNumber(v->ToFloat());
}
else if(type.Equals(L"Double", false)) {
Double* v = static_cast< Double* >(ptr);
return (JsonObject*) new JsonNumber(v->ToDouble());
}
else if(type.Equals(L"DateTime", false)) {
DateTime* v = static_cast< DateTime* >(ptr);
DateTimeFormatter* pFormatter = DateTimeFormatter::CreateDateTimeFormatterN();
String date;
pFormatter->ApplyPattern(L"yyyy-MM-dd");
pFormatter->Format(*v, date);
JsonObject*
toJson(void* ptr, String type, String containerType) {
if(ptr == null)
return null;
if(containerType != null && !type.Equals(L"", false)) {
if(containerType.Equals(L"array", false)) {
if(type != null) {
IList* list = static_cast< IList* >(ptr);
JsonArray* array = new JsonArray();
int sz = list->GetCount();
for(int i = 0; i < sz; i++) {
void* itemAt = list->GetAt(i);
JsonObject* item = toJson(itemAt, type, null);
if(item != null)
array->Add(item);
}
return (JsonObject*)array;
}
return null;
}
}
else if(type.Equals(L"Boolean", false)) {
Boolean* v = static_cast< Boolean* >(ptr);
return (JsonObject*) new JsonBool(*v);
}
else if(type.Equals(L"String", false)) {
String* v = static_cast< String* >(ptr);
return (JsonObject*) new JsonString(*v);
}
else if(type.Equals(L"Integer", false)) {
Integer* v = static_cast< Integer* >(ptr);
return (JsonObject*) new JsonNumber(v->ToInt());
}
else if(type.Equals(L"Long", false)) {
Long* v = static_cast< Long* >(ptr);
return (JsonObject*) new JsonNumber(v->ToInt());
}
else if(type.Equals(L"Float", false)) {
Float* v = static_cast< Float* >(ptr);
return (JsonObject*) new JsonNumber(v->ToFloat());
}
else if(type.Equals(L"Double", false)) {
Double* v = static_cast< Double* >(ptr);
return (JsonObject*) new JsonNumber(v->ToDouble());
}
else if(type.Equals(L"DateTime", false)) {
DateTime* v = static_cast< DateTime* >(ptr);
DateTimeFormatter* pFormatter = DateTimeFormatter::CreateDateTimeFormatterN();
String date;
pFormatter->ApplyPattern(L"yyyy-MM-dd");
pFormatter->Format(*v, date);
String time;
pFormatter->ApplyPattern(L"hh:mm:ss");
pFormatter->Format(*v, time);
String formattedString = date + "T" + time;
delete pFormatter;
return (JsonObject*)new JsonString(formattedString);
}
else if(type.StartsWith(L"{{prefix}}", 0)) {
{{prefix}}Object* obj = static_cast< {{prefix}}Object* >(ptr);
return obj->asJsonObject();
}
return null;
}
String time;
pFormatter->ApplyPattern(L"hh:mm:ss");
pFormatter->Format(*v, time);
String formattedString = date + "T" + time;
delete pFormatter;
return (JsonObject*)new JsonString(formattedString);
}
else if(type.StartsWith(L"{{prefix}}", 0)) {
{{prefix}}Object* obj = static_cast< {{prefix}}Object* >(ptr);
return obj->asJsonObject();
}
return null;
}
void
toISO8601(String str, DateTime* dt) {
int idx, start;
int year, month, day, hour, minute, second;
void
toISO8601(String str, DateTime* dt) {
int idx, start;
int year, month, day, hour, minute, second;
start = 0;
str.IndexOf(L"-", start, idx);
String yearString;
str.SubString(0, idx, yearString);
Integer::Parse(yearString, year);
start = 0;
str.IndexOf(L"-", start, idx);
String yearString;
str.SubString(0, idx, yearString);
Integer::Parse(yearString, year);
start = idx+1;
str.IndexOf(L"-", start, idx);
String monthString;
str.SubString(start, idx - start, monthString);
Integer::Parse(monthString, month);
start = idx+1;
str.IndexOf(L"-", start, idx);
String monthString;
str.SubString(start, idx - start, monthString);
Integer::Parse(monthString, month);
start = idx+1;
str.IndexOf(L"T", start, idx);
String dayString;
str.SubString(start, idx - start, dayString);
Integer::Parse(dayString, day);
start = idx+1;
str.IndexOf(L"T", start, idx);
String dayString;
str.SubString(start, idx - start, dayString);
Integer::Parse(dayString, day);
start = idx+1;
str.IndexOf(L":", start, idx);
if(idx > 0) {
String hourString;
str.SubString(start, idx - start, hourString);
Integer::Parse(hourString, hour);
}
start = idx+1;
str.IndexOf(L":", start, idx);
if(idx > 0) {
String hourString;
str.SubString(start, idx - start, hourString);
Integer::Parse(hourString, hour);
}
start = idx+1;
str.IndexOf(L":", start, idx);
if(idx > 0) {
String minuteString;
str.SubString(start, idx - start, minuteString);
Integer::Parse(minuteString, minute);
}
start = idx+1;
str.IndexOf(L":", start, idx);
if(idx > 0) {
String minuteString;
str.SubString(start, idx - start, minuteString);
Integer::Parse(minuteString, minute);
}
start = idx+1;
str.IndexOf(L"+", start, idx);
if(idx > 0) {
String secondString;
str.SubString(start, idx - start, secondString);
Integer::Parse(secondString, second);
}
start = idx+1;
str.IndexOf(L"+", start, idx);
if(idx > 0) {
String secondString;
str.SubString(start, idx - start, secondString);
Integer::Parse(secondString, second);
}
dt->SetValue(year, month, day, hour, minute, second);
}
dt->SetValue(year, month, day, hour, minute, second);
}
void
jsonToValue(void* target, IJsonValue* ptr, String type, String innerType) {
if(target == null || ptr == null) {
return;
}
if(type.StartsWith(L"Boolean", 0)) {
JsonBool* json = static_cast< JsonBool* >(ptr);
Boolean* val = static_cast< Boolean* > (target);
val->value = json->ToBool();
}
else if(type.StartsWith(L"String", 0)) {
JsonString* json = static_cast< JsonString* >(ptr);
String* val = static_cast< String* > (target);
val->Clear();
val->Append(json->GetPointer());
}
else if(type.StartsWith(L"Integer", 0)) {
JsonNumber* json = static_cast< JsonNumber* >(ptr);
Integer* val = static_cast< Integer* > (target);
*val = json->ToInt();
}
else if(type.StartsWith(L"Long", 0)) {
JsonNumber* json = static_cast< JsonNumber* >(ptr);
Long* val = static_cast< Long* > (target);
*val = json->ToLong();
}
else if(type.StartsWith(L"DateTime", 0)) {
JsonString* json = static_cast< JsonString* >(ptr);
String str;
str.Append(json->GetPointer());
void
jsonToValue(void* target, IJsonValue* ptr, String type, String innerType) {
if(target == null || ptr == null) {
return;
}
if(type.StartsWith(L"Boolean", 0)) {
JsonBool* json = static_cast< JsonBool* >(ptr);
Boolean* val = static_cast< Boolean* > (target);
val->value = json->ToBool();
}
else if(type.StartsWith(L"String", 0)) {
JsonString* json = static_cast< JsonString* >(ptr);
String* val = static_cast< String* > (target);
val->Clear();
val->Append(json->GetPointer());
}
else if(type.StartsWith(L"Integer", 0)) {
JsonNumber* json = static_cast< JsonNumber* >(ptr);
Integer* val = static_cast< Integer* > (target);
*val = json->ToInt();
}
else if(type.StartsWith(L"Long", 0)) {
JsonNumber* json = static_cast< JsonNumber* >(ptr);
Long* val = static_cast< Long* > (target);
*val = json->ToLong();
}
else if(type.StartsWith(L"DateTime", 0)) {
JsonString* json = static_cast< JsonString* >(ptr);
String str;
str.Append(json->GetPointer());
DateTime* val = static_cast< DateTime* > (target);
toISO8601(str, val);
}
else if(type.StartsWith(L"{{prefix}}", 0)) {
{{prefix}}Object* obj = static_cast< {{prefix}}Object* > (target);
obj->fromJsonObject(ptr);
}
else if(type.StartsWith(L"IList", 0)) {
IList* obj = static_cast< IList* >(target);
JsonArray* pJsonArray = static_cast< JsonArray* >(ptr);
DateTime* val = static_cast< DateTime* > (target);
toISO8601(str, val);
}
else if(type.StartsWith(L"{{prefix}}", 0)) {
{{prefix}}Object* obj = static_cast< {{prefix}}Object* > (target);
obj->fromJsonObject(ptr);
}
else if(type.StartsWith(L"IList", 0)) {
IList* obj = static_cast< IList* >(target);
JsonArray* pJsonArray = static_cast< JsonArray* >(ptr);
IEnumeratorT< IJsonValue* >* pEnum = pJsonArray->GetEnumeratorN();
while (pEnum->MoveNext() == E_SUCCESS) {
IJsonValue* pJsonValue = null;
pEnum->GetCurrent(pJsonValue);
void* updatedTarget = null;
updatedTarget = create(innerType);
IEnumeratorT< IJsonValue* >* pEnum = pJsonArray->GetEnumeratorN();
while (pEnum->MoveNext() == E_SUCCESS) {
IJsonValue* pJsonValue = null;
pEnum->GetCurrent(pJsonValue);
void* updatedTarget = null;
updatedTarget = create(innerType);
if(updatedTarget != null) {
jsonToValue(updatedTarget, pJsonValue, innerType, L"");
obj->Add((Object*)updatedTarget);
}
}
delete pEnum;
}
}
if(updatedTarget != null) {
jsonToValue(updatedTarget, pJsonValue, innerType, L"");
obj->Add((Object*)updatedTarget);
}
}
delete pEnum;
}
}
Integer*
jsonToInteger(IJsonValue* value) {
if(value == null)
return null;
switch(value->GetType()) {
case JSON_TYPE_STRING:
break;
case JSON_TYPE_NUMBER: {
JsonNumber* number = static_cast< JsonNumber* >(value);
int num = number->ToInt();
return new Integer(num);
}
case JSON_TYPE_OBJECT:
break;
case JSON_TYPE_ARRAY:
break;
case JSON_TYPE_BOOL:
break;
case JSON_TYPE_NULL:
break;
}
return null;
}
Integer*
jsonToInteger(IJsonValue* value) {
if(value == null)
return null;
switch(value->GetType()) {
case JSON_TYPE_STRING:
break;
case JSON_TYPE_NUMBER: {
JsonNumber* number = static_cast< JsonNumber* >(value);
int num = number->ToInt();
return new Integer(num);
}
case JSON_TYPE_OBJECT:
break;
case JSON_TYPE_ARRAY:
break;
case JSON_TYPE_BOOL:
break;
case JSON_TYPE_NULL:
break;
}
return null;
}
Long*
jsonToLong(IJsonValue* value) {
if(value == null)
return null;
switch(value->GetType()) {
case JSON_TYPE_STRING:
break;
case JSON_TYPE_NUMBER: {
JsonNumber* number = static_cast< JsonNumber* >(value);
long int num = number->ToLong();
return new Long(num);
}
case JSON_TYPE_OBJECT:
break;
case JSON_TYPE_ARRAY:
break;
case JSON_TYPE_BOOL:
break;
case JSON_TYPE_NULL:
break;
}
return null;
}
Long*
jsonToLong(IJsonValue* value) {
if(value == null)
return null;
switch(value->GetType()) {
case JSON_TYPE_STRING:
break;
case JSON_TYPE_NUMBER: {
JsonNumber* number = static_cast< JsonNumber* >(value);
long int num = number->ToLong();
return new Long(num);
}
case JSON_TYPE_OBJECT:
break;
case JSON_TYPE_ARRAY:
break;
case JSON_TYPE_BOOL:
break;
case JSON_TYPE_NULL:
break;
}
return null;
}
String*
jsonToString(IJsonValue* value) {
if(value == null)
return null;
switch(value->GetType()) {
case JSON_TYPE_STRING: {
JsonString* string = static_cast< JsonString* >(value);
return new String(string->GetPointer());
}
case JSON_TYPE_NUMBER:
break;
case JSON_TYPE_OBJECT:
break;
case JSON_TYPE_ARRAY:
break;
case JSON_TYPE_BOOL:
break;
case JSON_TYPE_NULL:
break;
}
return null;
}
String*
jsonToString(IJsonValue* value) {
if(value == null)
return null;
switch(value->GetType()) {
case JSON_TYPE_STRING: {
JsonString* string = static_cast< JsonString* >(value);
return new String(string->GetPointer());
}
case JSON_TYPE_NUMBER:
break;
case JSON_TYPE_OBJECT:
break;
case JSON_TYPE_ARRAY:
break;
case JSON_TYPE_BOOL:
break;
case JSON_TYPE_NULL:
break;
}
return null;
}
String
stringify(void* ptr, String type) {
if(type.StartsWith(L"String", 0)) {
String * str = static_cast< String* > (ptr);
return String(str->GetPointer());
}
if(type.StartsWith(L"Integer", 0)) {
Integer* pInt = static_cast< Integer* > (ptr);
return pInt->ToString();
}
if(type.StartsWith(L"Long", 0)) {
Long* pLong = static_cast< Long* > (ptr);
return pLong->ToString();
}
return L"";
}
String
stringify(void* ptr, String type) {
if(type.StartsWith(L"String", 0)) {
String * str = static_cast< String* > (ptr);
return String(str->GetPointer());
}
if(type.StartsWith(L"Integer", 0)) {
Integer* pInt = static_cast< Integer* > (ptr);
return pInt->ToString();
}
if(type.StartsWith(L"Long", 0)) {
Long* pLong = static_cast< Long* > (ptr);
return pLong->ToString();
}
return L"";
}
} /* namespace Swagger */

View File

@@ -1,50 +1,45 @@
#ifndef HELPERS_H_
#define HELPERS_H_
#include
<FApp.h>
#include
<FBase.h>
#include
<FSystem.h>
#include
<FWebJson.h>
#include
<FLocales.h>
#include "{{prefix}}Helpers.h"
#include "{{prefix}}Object.h"
#include <FApp.h>
#include <FBase.h>
#include <FSystem.h>
#include <FWebJson.h>
#include <FLocales.h>
#include "{{prefix}}Helpers.h"
#include "{{prefix}}Object.h"
using Tizen::Base::String;
using Tizen::Base::DateTime;
using namespace Tizen::Web::Json;
using namespace Tizen::Base::Collection;
using Tizen::Base::String;
using Tizen::Base::DateTime;
using namespace Tizen::Web::Json;
using namespace Tizen::Base::Collection;
using Tizen::Base::Long;
using Tizen::Base::DateTime;
using Tizen::Base::String;
using Tizen::Base::Integer;
using Tizen::Base::Long;
using Tizen::Base::DateTime;
using Tizen::Base::String;
using Tizen::Base::Integer;
namespace Swagger {
JsonObject*
toJson(void* v, String type, String containerType);
namespace Swagger {
JsonObject*
toJson(void* v, String type, String containerType);
void
jsonToValue(void* target, IJsonValue* ptr, String type, String innerType);
void
jsonToValue(void* target, IJsonValue* ptr, String type, String innerType);
Integer*
jsonToInteger(IJsonValue* value);
Integer*
jsonToInteger(IJsonValue* value);
Long*
jsonToLong(IJsonValue* value);
Long*
jsonToLong(IJsonValue* value);
String*
jsonToString(IJsonValue* value);
String*
jsonToString(IJsonValue* value);
DateTime*
jsonToDateTime(IJsonValue* value);
DateTime*
jsonToDateTime(IJsonValue* value);
String
stringify(void* ptr, String type);
String
stringify(void* ptr, String type);
} /* namespace Swagger */
#endif /* HELPERS_H_ */
} /* namespace Swagger */
#endif /* HELPERS_H_ */

View File

@@ -1,159 +1,158 @@
{{#models}}{{#model}}
#include "{{classname}}.h"
#include
<FLocales.h>
#include "{{classname}}.h"
#include <FLocales.h>
using namespace Tizen::Base;
using namespace Tizen::System;
using namespace Tizen::Base::Utility;
using namespace Tizen::Base::Collection;
using namespace Tizen::Web::Json;
using namespace Tizen::Locales;
using namespace Tizen::Base;
using namespace Tizen::System;
using namespace Tizen::Base::Utility;
using namespace Tizen::Base::Collection;
using namespace Tizen::Web::Json;
using namespace Tizen::Locales;
namespace Swagger {
namespace Swagger {
{{classname}}::{{classname}}() {
init();
}
{{classname}}::{{classname}}() {
init();
}
{{classname}}::~{{classname}}() {
this->cleanup();
}
{{classname}}::~{{classname}}() {
this->cleanup();
}
void
{{classname}}::init() {
void
{{classname}}::init() {
{{#vars}}{{name}} = null;
{{/vars}}
}
}
void
{{classname}}::cleanup() {
void
{{classname}}::cleanup() {
{{#vars}}if({{name}} != null) {
{{#isContainer}}{{name}}->RemoveAll(true);{{/isContainer}}
{{#isContainer}}{{name}}->RemoveAll(true);{{/isContainer}}
delete {{name}};
{{name}} = null;
}
{{name}} = null;
}
{{/vars}}
}
}
{{classname}}*
{{classname}}::fromJson(String* json) {
this->cleanup();
String str(json->GetPointer());
int length = str.GetLength();
{{classname}}*
{{classname}}::fromJson(String* json) {
this->cleanup();
String str(json->GetPointer());
int length = str.GetLength();
ByteBuffer buffer;
buffer.Construct(length);
ByteBuffer buffer;
buffer.Construct(length);
for (int i = 0; i < length; ++i) {
byte b = str[i];
buffer.SetByte(b);
}
for (int i = 0; i < length; ++i) {
byte b = str[i];
buffer.SetByte(b);
}
IJsonValue* pJson = JsonParser::ParseN(buffer);
fromJsonObject(pJson);
if (pJson->GetType() == JSON_TYPE_OBJECT) {
JsonObject* pObject = static_cast< JsonObject* >(pJson);
pObject->RemoveAll(true);
}
else if (pJson->GetType() == JSON_TYPE_ARRAY) {
JsonArray* pArray = static_cast< JsonArray* >(pJson);
pArray->RemoveAll(true);
}
delete pJson;
return this;
}
IJsonValue* pJson = JsonParser::ParseN(buffer);
fromJsonObject(pJson);
if (pJson->GetType() == JSON_TYPE_OBJECT) {
JsonObject* pObject = static_cast< JsonObject* >(pJson);
pObject->RemoveAll(true);
}
else if (pJson->GetType() == JSON_TYPE_ARRAY) {
JsonArray* pArray = static_cast< JsonArray* >(pJson);
pArray->RemoveAll(true);
}
delete pJson;
return this;
}
void
{{classname}}::fromJsonObject(IJsonValue* pJson) {
JsonObject* pJsonObject = static_cast< JsonObject* >(pJson);
void
{{classname}}::fromJsonObject(IJsonValue* pJson) {
JsonObject* pJsonObject = static_cast< JsonObject* >(pJson);
if(pJsonObject != null) {
{{#vars}}JsonString* {{name}}Key = new JsonString(L"{{baseName}}");
if(pJsonObject != null) {
{{#vars}}JsonString* {{name}}Key = new JsonString(L"{{baseName}}");
IJsonValue* {{name}}Val = null;
pJsonObject->GetValue({{name}}Key, {{name}}Val);
if({{name}}Val != null) {
{{#isContainer}}{{name}} = {{defaultValue}};{{/isContainer}}
{{#isNotContainer}}{{name}} = {{defaultValue}};{{/isNotContainer}}
jsonToValue({{name}}, {{name}}Val, L"{{baseType}}", L"{{complexType}}");
{{#isContainer}}{{name}} = {{defaultValue}};{{/isContainer}}
{{#isNotContainer}}{{name}} = {{defaultValue}};{{/isNotContainer}}
jsonToValue({{name}}, {{name}}Val, L"{{baseType}}", L"{{complexType}}");
}
delete {{name}}Key;
{{/vars}}
}
}
{{/vars}}
}
}
{{classname}}::{{classname}}(String* json) {
init();
String str(json->GetPointer());
int length = str.GetLength();
{{classname}}::{{classname}}(String* json) {
init();
String str(json->GetPointer());
int length = str.GetLength();
ByteBuffer buffer;
buffer.Construct(length);
ByteBuffer buffer;
buffer.Construct(length);
for (int i = 0; i < length; ++i) {
byte b = str[i];
buffer.SetByte(b);
}
for (int i = 0; i < length; ++i) {
byte b = str[i];
buffer.SetByte(b);
}
IJsonValue* pJson = JsonParser::ParseN(buffer);
fromJsonObject(pJson);
if (pJson->GetType() == JSON_TYPE_OBJECT) {
JsonObject* pObject = static_cast< JsonObject* >(pJson);
pObject->RemoveAll(true);
}
else if (pJson->GetType() == JSON_TYPE_ARRAY) {
JsonArray* pArray = static_cast< JsonArray* >(pJson);
pArray->RemoveAll(true);
}
delete pJson;
}
IJsonValue* pJson = JsonParser::ParseN(buffer);
fromJsonObject(pJson);
if (pJson->GetType() == JSON_TYPE_OBJECT) {
JsonObject* pObject = static_cast< JsonObject* >(pJson);
pObject->RemoveAll(true);
}
else if (pJson->GetType() == JSON_TYPE_ARRAY) {
JsonArray* pArray = static_cast< JsonArray* >(pJson);
pArray->RemoveAll(true);
}
delete pJson;
}
String
{{classname}}::asJson ()
{
JsonObject* pJsonObject = asJsonObject();
String
{{classname}}::asJson ()
{
JsonObject* pJsonObject = asJsonObject();
char *pComposeBuf = new char[256];
JsonWriter::Compose(pJsonObject, pComposeBuf, 256);
String s = String(pComposeBuf);
char *pComposeBuf = new char[256];
JsonWriter::Compose(pJsonObject, pComposeBuf, 256);
String s = String(pComposeBuf);
delete pComposeBuf;
pJsonObject->RemoveAll(true);
delete pJsonObject;
delete pComposeBuf;
pJsonObject->RemoveAll(true);
delete pJsonObject;
return s;
}
return s;
}
JsonObject*
{{classname}}::asJsonObject() {
JsonObject *pJsonObject = new JsonObject();
pJsonObject->Construct();
JsonObject*
{{classname}}::asJsonObject() {
JsonObject *pJsonObject = new JsonObject();
pJsonObject->Construct();
{{#vars}}
JsonString *{{name}}Key = new JsonString(L"{{baseName}}");
pJsonObject->Add({{name}}Key, toJson({{getter}}(), "{{complexType}}", "{{containerType}}"));
JsonString *{{name}}Key = new JsonString(L"{{baseName}}");
pJsonObject->Add({{name}}Key, toJson({{getter}}(), "{{complexType}}", "{{containerType}}"));
{{/vars}}
return pJsonObject;
}
return pJsonObject;
}
{{#vars}}
{{datatype}}
{{classname}}::{{getter}}() {
return {{name}};
}
void
{{classname}}::{{setter}}({{datatype}} {{name}}) {
this->{{name}} = {{name}};
}
{{#vars}}
{{datatype}}
{{classname}}::{{getter}}() {
return {{name}};
}
void
{{classname}}::{{setter}}({{datatype}} {{name}}) {
this->{{name}} = {{name}};
}
{{/vars}}
{{/vars}}
} /* namespace Swagger */
} /* namespace Swagger */
{{/model}}
{{/models}}

View File

@@ -1,62 +1,58 @@
{{#models}}{{#model}}/*
* {{classname}}.h
*
* {{description}}
*/
* {{classname}}.h
*
* {{description}}
*/
#ifndef {{classname}}_H_
#define {{classname}}_H_
#include
<FApp.h>
#include
<FBase.h>
#include
<FSystem.h>
#include
<FWebJson.h>
#include "{{prefix}}Helpers.h"
#include "{{prefix}}Object.h"
#include <FApp.h>
#include <FBase.h>
#include <FSystem.h>
#include <FWebJson.h>
#include "{{prefix}}Helpers.h"
#include "{{prefix}}Object.h"
using namespace Tizen::Web::Json;
using namespace Tizen::Web::Json;
{{/model}}{{/models}}
{{#imports}}{{{import}}}
{{/imports}}
{{#models}}{{#model}}
namespace Swagger {
namespace Swagger {
class {{classname}}: public {{prefix}}Object {
public:
class {{classname}}: public {{prefix}}Object {
public:
{{classname}}();
{{classname}}(String* json);
virtual ~{{classname}}();
virtual ~{{classname}}();
void init();
void init();
void cleanup();
void cleanup();
String asJson ();
String asJson ();
JsonObject* asJsonObject();
JsonObject* asJsonObject();
void fromJsonObject(IJsonValue* json);
void fromJsonObject(IJsonValue* json);
{{classname}}* fromJson(String* obj);
{{#vars}}
{{datatype}} {{getter}}();
void {{setter}}({{datatype}} {{name}});
{{datatype}} {{getter}}();
void {{setter}}({{datatype}} {{name}});
{{/vars}}
private:
private:
{{#vars}}{{datatype}} {{name}};
{{/vars}}
};
};
} /* namespace Swagger */
} /* namespace Swagger */
#endif /* {{classname}}_H_ */
#endif /* {{classname}}_H_ */
{{/model}}
{{/models}}

View File

@@ -3,29 +3,29 @@
#include "{{prefix}}Object.h"
{{#models}}{{#model}}
#include "{{classname}}.h"{{/model}}{{/models}}
#include "{{classname}}.h"{{/model}}{{/models}}
namespace Swagger {
void*
create(String type) {
{{#models}}{{#model}}if(type.Equals(L"{{classname}}", true)) {
return new {{classname}}();
}
{{/model}}{{/models}}
if(type.Equals(L"String", true)) {
return new String();
}
if(type.Equals(L"Integer", true)) {
return new Integer();
}
if(type.Equals(L"Long", true)) {
return new Long();
}
if(type.Equals(L"DateTime", true)) {
return new DateTime();
}
return null;
}
void*
create(String type) {
{{#models}}{{#model}}if(type.Equals(L"{{classname}}", true)) {
return new {{classname}}();
}
{{/model}}{{/models}}
if(type.Equals(L"String", true)) {
return new String();
}
if(type.Equals(L"Integer", true)) {
return new Integer();
}
if(type.Equals(L"Long", true)) {
return new Long();
}
if(type.Equals(L"DateTime", true)) {
return new DateTime();
}
return null;
}
} /* namespace Swagger */
#endif /* ModelFactory_H_ */

View File

@@ -1,30 +1,27 @@
#ifndef _{{prefix}}_OBJECT_H_
#define _{{prefix}}_OBJECT_H_
#include
<FNet.h>
#include
<FWebJson.h>
#include
<FBase.h>
#include <FNet.h>
#include <FWebJson.h>
#include <FBase.h>
using Tizen::Base::String;
using Tizen::Base::String;
using namespace Tizen::Web::Json;
using namespace Tizen::Web::Json;
class {{prefix}}Object {
public:
virtual JsonObject* asJsonObject() {
return null;
}
virtual ~{{prefix}}Object() {}
virtual {{prefix}}Object* fromJson(String* obj) {
return null;
}
virtual void fromJsonObject(IJsonValue* obj) {}
virtual String asJson() {
return L"";
}
};
class {{prefix}}Object {
public:
virtual JsonObject* asJsonObject() {
return null;
}
virtual ~{{prefix}}Object() {}
virtual {{prefix}}Object* fromJson(String* obj) {
return null;
}
virtual void fromJsonObject(IJsonValue* obj) {}
virtual String asJson() {
return L"";
}
};
#endif /* _{{prefix}}_OBJECT_H_ */
#endif /* _{{prefix}}_OBJECT_H_ */