Skip to content

Commit

Permalink
Initial commit for C++ API template
Browse files Browse the repository at this point in the history
  • Loading branch information
bicheichane committed Feb 12, 2019
1 parent 0bc1787 commit 1e11a30
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
40 changes: 40 additions & 0 deletions C++/Bindings/PhantasmaAPI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "pch.h"
#include "PhantasmaAPI.h"

PhantasmaAPI::PhantasmaAPI()
{
}


PhantasmaAPI::~PhantasmaAPI()
{
}

std::string FieldToString(value json, string_t field)
{
return utility::conversions::to_utf8string(json.at(field).as_string().c_str());
}

uint16_t FieldToNumber(value json, string_t field)
{
return json.at(field).as_integer();
}

{{#each types}}
struct {{#fix-type Key}}
{
{{#each Value}} {{#fix-type FieldType.Name}} {{#if FieldType.IsArray}}* {{/if}} {{Name}}; //{{Key.Description}}
};
{{/each}}

class PhantasmaAPI
{
public:
PhantasmaAPI(std::string host);
~PhantasmaAPI();

{{#each methods}}
//{{Info.Description}}
{{Info.ReturnType.Name}} {{Info.Name}} ({{#each Info.Parameters}}{{#fix-type Type.Name}} {{Name}})
};

35 changes: 35 additions & 0 deletions C++/Bindings/PhantasmaAPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "pch.h"
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include <cpprest/http_listener.h> // HTTP server
#include <cpprest/json.h> // JSON library
#include <cpprest/ws_client.h> // WebSocket client

using namespace utility; // Common utilities like string conversions
using namespace web; // Common features like URIs.
using namespace http; // Common HTTP functionality
using namespace client; // HTTP client features
using namespace concurrency::streams; // Asynchronous streams
using namespace json; // JSON library

#pragma once

{{#each types}}
struct {{#fix-type Key}}Result
{
{{#each Value}} {{#fix-type FieldType.Name}}{{#if FieldType.IsArray}}* {{/if}}{{Name}}; //{{Key.Description}}
{{/each}}
};


class PhantasmaAPI
{
public:
PhantasmaAPI();
~PhantasmaAPI();

{{#each methods}}
//{{Info.Description}}
{{Info.ReturnType.Name}} {{Info.Name}} ({{#each Info.Parameters}}{{#fix-type Type.Name}} {{Name}} {{#if !@last}}, {{/if}}{{/each}})
};

2 changes: 2 additions & 0 deletions C++/Bindings/language.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
String,std::string
UInt32,uint32_t
2 changes: 1 addition & 1 deletion SDK.Builder/SDK.Builder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static void Main(string[] args)

GenerateBindings(inputPath + @"PhantasmaSDK\Docs\", tempPath + @"\Docs\");

foreach (var lang in new[] { "C#", "JS", "PHP", "Python", "Go" })
foreach (var lang in new[] { "C#", "JS", "PHP", "Python", "Go", "C++" })
{
CopyFolder(inputPath + @"PhantasmaSDK\" + lang+ @"\Samples\", tempPath + lang + @"\Dapps\");
GenerateBindings(inputPath + @"PhantasmaSDK\" + lang + @"\Bindings\", tempPath + lang + @"\Libs\");
Expand Down

0 comments on commit 1e11a30

Please sign in to comment.