Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated v2 fork with latest libraries, bug fixes and vcpkg manifest integration #55

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
[submodule "tests/mock_responses"]
path = tests/mock_responses
url = https://github.com/zerodha/kiteconnect-mocks
[submodule "include/PicoSHA2"]
path = include/PicoSHA2
url = https://github.com/okdshin/PicoSHA2.git
[submodule "include/fmt"]
path = include/fmt
url = https://github.com/fmtlib/fmt.git
[submodule "include/rapidjson"]
path = include/rapidjson
url = https://github.com/Tencent/rapidjson.git
[submodule "include/cpp-httplib"]
path = include/cpp-httplib
url = https://github.com/yhirose/cpp-httplib.git
[submodule "doxygen-awesome-css"]
path = doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
[submodule "docs/doxygen-awesome-css"]
path = docs/doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
cmake_minimum_required(VERSION 3.10)

# vcpkg Tool chain
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "Vcpkg toolchain file")

project(CppKiteConnect)

# set variables
Expand Down Expand Up @@ -56,6 +61,9 @@ if(BUILD_EXAMPLES)
target_include_directories(${example_name} PUBLIC ${UWS_INCLUDE} ${UV_INCLUDE})
target_link_libraries(${example_name} PUBLIC Threads::Threads OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB ${UWS_LIB} ${UV_LIB})
endif()

# Suppress warnings about cpp-httplib & openssl 3.0
#target_compile_options(${example_name} PRIVATE -Wno-deprecated-declarations)
endfunction(build_exmaple)

build_exmaple(example1)
Expand Down
3 changes: 3 additions & 0 deletions examples/example4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ void onClose(kc::ticker* ws, int code, const std::string& message) {
};

int main(int argc, char const* argv[]) {

fmt::print("fmt version is {}\n",FMT_VERSION);

kc::ticker Ticker(std::getenv("KITE_API_KEY"), 5, true, 5);

Ticker.setAccessToken(std::getenv("KITE_ACCESS_TOKEN"));
Expand Down
1 change: 0 additions & 1 deletion include/PicoSHA2
Submodule PicoSHA2 deleted from b699e6
1 change: 0 additions & 1 deletion include/cpp-httplib
Submodule cpp-httplib deleted from 676f1b
1 change: 0 additions & 1 deletion include/fmt
Submodule fmt deleted from 7bdf06
2 changes: 1 addition & 1 deletion include/kitepp/kite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <unordered_map>
#include <vector>

#include "cpp-httplib/httplib.h"
#include "httplib.h"

#include "responses/responses.hpp"
#include "utils.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/kitepp/kite/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#pragma once
#pragma clang diagnostic ignored "-Wundefined-inline"

#include "PicoSHA2/picosha2.h"
#include "picosha2.h"

#include "../kite.hpp"
#include "../utils.hpp"
Expand Down
4 changes: 2 additions & 2 deletions include/kitepp/responses/gtt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

#include "../utils.hpp"
#include "order.hpp"
#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/rapidjson.h"

namespace kiteconnect {

Expand Down
4 changes: 2 additions & 2 deletions include/kitepp/responses/market.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include <string>

#include "../utils.hpp"
#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/rapidjson.h"

namespace kiteconnect {

Expand Down
4 changes: 2 additions & 2 deletions include/kitepp/responses/mf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include <string>

#include "../utils.hpp"
#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/rapidjson.h"

namespace kiteconnect {

Expand Down
4 changes: 2 additions & 2 deletions include/kitepp/responses/order.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#include <string>

#include "../utils.hpp"
#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/rapidjson.h"

namespace kiteconnect {

Expand Down
4 changes: 2 additions & 2 deletions include/kitepp/responses/portfolio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include <string>

#include "../utils.hpp"
#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/rapidjson.h"

namespace kiteconnect {

Expand Down
4 changes: 2 additions & 2 deletions include/kitepp/responses/user.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include <string>

#include "../utils.hpp"
#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/rapidjson.h"

namespace kiteconnect {

Expand Down
4 changes: 2 additions & 2 deletions include/kitepp/responses/ws.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
#include <string>

#include "../utils.hpp"
#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/rapidjson.h"

namespace kiteconnect {

Expand Down
6 changes: 3 additions & 3 deletions include/kitepp/ticker/internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
#include "../utils.hpp"
#include "ws.hpp"

#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/rapidjson.h"
#include "rapidjson/include/rapidjson/writer.h"
#include "rapidjson/document.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/writer.h"
#include <uWS/uWS.h>

namespace kiteconnect {
Expand Down
6 changes: 3 additions & 3 deletions include/kitepp/ticker/ws.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
#include "../userconstants.hpp" //modes
#include "../utils.hpp"

#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/rapidjson.h"
#include "rapidjson/include/rapidjson/writer.h"
#include "rapidjson/document.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/writer.h"
#include <uWS/uWS.h>

namespace kiteconnect {
Expand Down
27 changes: 14 additions & 13 deletions include/kitepp/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@

#include "exceptions.hpp"

#include "cpp-httplib/httplib.h"
#include "httplib.h"
#define FMT_HEADER_ONLY 1
#include "fmt/include/fmt/format.h"
#include "rapidjson/include/rapidjson/document.h"
#include "rapidjson/include/rapidjson/encodings.h"
#include "rapidjson/include/rapidjson/rapidjson.h"
#include "rapidjson/include/rapidjson/stringbuffer.h"
#include "rapidjson/include/rapidjson/writer.h"
#include "fmt/format.h"
#include "fmt/args.h"
#include "rapidjson/document.h"
#include "rapidjson/encodings.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"

// Check endieness of platform
#if defined(_WIN32)
Expand Down Expand Up @@ -482,7 +483,7 @@ struct request {
} else {
// TODO convert enum to string
throw libException(
FMT("request failed ({0})", res.error()));
FMT("request failed ({0})", httplib::to_string(res.error())));
}
break;
case utils::http::METHOD::POST:
Expand All @@ -492,7 +493,7 @@ struct request {
data = res->body;
} else {
throw libException(
FMT("request failed ({0})", res.error()));
FMT("request failed ({0})", httplib::to_string(res.error())));
}
} else {
if (auto res = client.Post(path.c_str(), headers,
Expand All @@ -501,7 +502,7 @@ struct request {
data = res->body;
} else {
throw libException(
FMT("request failed({0})", res.error()));
FMT("request failed({0})", httplib::to_string(res.error())));
}
};
break;
Expand All @@ -512,7 +513,7 @@ struct request {
data = res->body;
} else {
throw libException(
FMT("request failed ({0})", res.error()));
FMT("request failed ({0})", httplib::to_string(res.error())));
}
} else {
if (auto res = client.Put(path.c_str(), headers,
Expand All @@ -521,7 +522,7 @@ struct request {
data = res->body;
} else {
throw libException(
FMT("request failed({0})", res.error()));
FMT("request failed({0})", httplib::to_string(res.error())));
}
}
break;
Expand All @@ -531,7 +532,7 @@ struct request {
data = res->body;
} else {
throw libException(
FMT("request failed ({0})", res.error()));
FMT("request failed ({0})", httplib::to_string(res.error())));
}
break;
default: throw libException("unsupported http method");
Expand Down
1 change: 0 additions & 1 deletion include/rapidjson
Submodule rapidjson deleted from 56f215
Binary file added uWS/libuWS.a
Binary file not shown.
1 change: 1 addition & 0 deletions vcpkg
Submodule vcpkg added at f9bea5
16 changes: 16 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "cppkiteconnect",
"version-string": "2.0.0",
"homepage": "https://github.com/zerodha/cppkiteconnect",
"description": "C++ Kite Connect API library / SDK",
"dependencies": [
"fmt",
"cpp-httplib",
"picosha2",
"rapidjson",
"zlib",
"gtest",
"libuv",
"openssl"
]
}