Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Commit

Permalink
Add calling test()
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrokeil committed Oct 27, 2017
1 parent 33bc2a1 commit da35c00
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .clang_complete
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-std=c++11 -std=gnu++11 -I./deps/fuerte/include -I./deps/velocypack/include
-std=c++11 -std=gnu++11 -I./deps/fuerte/include -I./deps/velocypack/include -I./go
11 changes: 0 additions & 11 deletions Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
FROM sandrokeil/phpcpp

COPY deps /tmp
RUN cd /tmp/velocypack/build && \
cmake .. -DCMAKE_CXX_FLAGS=-fPIC && \
make install

RUN apt-get update && apt-get install -y \
libc-dev \
libpcre3-dev

RUN cd /tmp/fuerte && \
mkdir buildir && \
cd buildir && \
cmake .. -DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=Release && \
make install
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ LINKER = g++

INC = `cat .clang_complete`

COMPILER_FLAGS = -Wall -c -O2 ${INC} -fpic -o
COMPILER_FLAGS = -Wall -c -O2 ${INC} go/arangodb.a -fpic -o
LINKER_FLAGS = -shared
LINKER_DEPENDENCIES = -lphpcpp -lboost_system -lboost_thread -L/root/local/lib -lfuerte -lvelocypack -lcurl
LINKER_DEPENDENCIES = -Bstatic -larangodb -lphpcpp -lboost_system -lboost_thread -L/root/local/lib -lcurl

#
# Command to remove files, copy files and create directories.
Expand Down
4 changes: 3 additions & 1 deletion go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ package main
import (
"C"

"fmt"
"github.com/arangodb/go-velocypack"
)

// main is required to build a shared library, but does nothing
func main() {}

//export test
func test() {
var b velocypack.Builder

b.Bytes()
fmt.Println(b.Bytes())

b.Close()
}
Expand Down
78 changes: 2 additions & 76 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,95 +3,21 @@
#include <algorithm>
#include <stdlib.h>

#include <fuerte/fuerte.h>
#include <fuerte/loop.h>
#include <fuerte/FuerteLogger.h>
#include <fuerte/connection.h>
#include <fuerte/requests.h>

#include <iostream>
#include <iomanip>
#include "velocypack/vpack.h"
#include "velocypack/velocypack-exception-macros.h"

#include <velocypack/Parser.h>
#include <velocypack/Iterator.h>
#include <velocypack/velocypack-aliases.h>

#include <chrono>
#include <iostream>
#include <fstream>
#include <boost/thread.hpp>
#include <boost/asio/io_service.hpp>
#include <thread>

namespace f = ::arangodb::fuerte;
namespace fu = ::arangodb::fuerte;
namespace vp = ::arangodb::velocypack;
#include <arangodb.h>

Php::Value vpack(Php::Parameters &params)
{
// there is one input array, cast the PHP variable to a vector of ints
std::vector<int> input = params[0];

vp::Builder b;

b.add(vp::Value(vp::ValueType::Object));
b.add("b", vp::Value(12));
b.add("a", vp::Value(true));
b.add("l", vp::Value(vp::ValueType::Array));
b.add(vp::Value(1));
b.add(vp::Value(2));
b.add(vp::Value(3));
b.close();
b.add("name", vp::Value("Gustav"));
b.close();

// now dump the resulting VPack value
std::cout << "Resulting VPack:" << b.slice() << std::endl;
std::cout << vp::HexDump(b.slice()) << std::endl;

std::cout << vp::valueTypeName(vp::ValueType::Object) << std::endl;


std::cout << "Connection test:" << std::endl;

auto conn = f::ConnectionBuilder().host("vst://arangodb:8529")
// .async(true)
// .user("hund")
// .password("arfarf")
.connect(*std::unique_ptr<f::EventLoopService>(new f::EventLoopService()));

VPackBuilder builder;
builder.openObject();
builder.add("name" , VPackValue("testobi"));
builder.close();
arangodb::fuerte::Request request = *fu::createRequest(fu::RestVerb::Post, "/_api/collection");
request.addVPack(builder.slice());
auto result = conn->sendRequest(std::move(request));
if (result->header.responseCode.get() >= 400){
std::cerr << fu::to_string(request);
std::cerr << fu::to_string(*result);
}

// std::cout << "Connection connected:" << std::endl;
//
// auto request = f::createRequest(f::RestVerb::Get, "/_api/version");
//
// std::cout << "request created:" << std::endl;
//
// auto result = conn->sendRequest(std::move(request));
//
// std::cout << "request send:" << std::endl;
//
//// std::cout << "Datbase connection status code:" << result->header.responseCode.get() << std::endl;
// std::cout << "Datbase connection status code:" << result->header << std::endl;
//
// auto slice = result->slices().front();
// auto version = slice.get("version").copyString();
// auto server = slice.get("server").copyString();
test();

// done
return input;
}

Expand Down

0 comments on commit da35c00

Please sign in to comment.