diff --git a/.gitmodules b/.gitmodules index f5f142d..2908b0f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 04296d2..06c4851 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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) diff --git a/examples/example4.cpp b/examples/example4.cpp index de1436d..c2ba262 100644 --- a/examples/example4.cpp +++ b/examples/example4.cpp @@ -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")); diff --git a/include/PicoSHA2 b/include/PicoSHA2 deleted file mode 160000 index b699e6c..0000000 --- a/include/PicoSHA2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b699e6c900be6e00152db5a3d123c1db42ea13d0 diff --git a/include/cpp-httplib b/include/cpp-httplib deleted file mode 160000 index 676f1b5..0000000 --- a/include/cpp-httplib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 676f1b5a2682b1b682e3e8159142500e3c84443a diff --git a/include/fmt b/include/fmt deleted file mode 160000 index 7bdf062..0000000 --- a/include/fmt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7bdf0628b1276379886c7f6dda2cef2b3b374f0b diff --git a/include/kitepp/kite.hpp b/include/kitepp/kite.hpp index c72621b..65362b6 100644 --- a/include/kitepp/kite.hpp +++ b/include/kitepp/kite.hpp @@ -30,7 +30,7 @@ #include #include -#include "cpp-httplib/httplib.h" +#include "httplib.h" #include "responses/responses.hpp" #include "utils.hpp" diff --git a/include/kitepp/kite/api.hpp b/include/kitepp/kite/api.hpp index 82e82fe..38a13c4 100644 --- a/include/kitepp/kite/api.hpp +++ b/include/kitepp/kite/api.hpp @@ -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" diff --git a/include/kitepp/responses/gtt.hpp b/include/kitepp/responses/gtt.hpp index 0ee295f..3a27510 100644 --- a/include/kitepp/responses/gtt.hpp +++ b/include/kitepp/responses/gtt.hpp @@ -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 { diff --git a/include/kitepp/responses/market.hpp b/include/kitepp/responses/market.hpp index 5b86087..ff17a15 100644 --- a/include/kitepp/responses/market.hpp +++ b/include/kitepp/responses/market.hpp @@ -28,8 +28,8 @@ #include #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 { diff --git a/include/kitepp/responses/mf.hpp b/include/kitepp/responses/mf.hpp index 91327f1..f69f49b 100644 --- a/include/kitepp/responses/mf.hpp +++ b/include/kitepp/responses/mf.hpp @@ -28,8 +28,8 @@ #include #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 { diff --git a/include/kitepp/responses/order.hpp b/include/kitepp/responses/order.hpp index ab3ddcd..c26189c 100644 --- a/include/kitepp/responses/order.hpp +++ b/include/kitepp/responses/order.hpp @@ -29,8 +29,8 @@ #include #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 { diff --git a/include/kitepp/responses/portfolio.hpp b/include/kitepp/responses/portfolio.hpp index 264f133..673348e 100644 --- a/include/kitepp/responses/portfolio.hpp +++ b/include/kitepp/responses/portfolio.hpp @@ -28,8 +28,8 @@ #include #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 { diff --git a/include/kitepp/responses/user.hpp b/include/kitepp/responses/user.hpp index 92c71bb..6f6bb08 100644 --- a/include/kitepp/responses/user.hpp +++ b/include/kitepp/responses/user.hpp @@ -28,8 +28,8 @@ #include #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 { diff --git a/include/kitepp/responses/ws.hpp b/include/kitepp/responses/ws.hpp index d011b8f..76b33bb 100644 --- a/include/kitepp/responses/ws.hpp +++ b/include/kitepp/responses/ws.hpp @@ -29,8 +29,8 @@ #include #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 { diff --git a/include/kitepp/ticker/internal.hpp b/include/kitepp/ticker/internal.hpp index 073a3ec..5524d33 100644 --- a/include/kitepp/ticker/internal.hpp +++ b/include/kitepp/ticker/internal.hpp @@ -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 namespace kiteconnect { diff --git a/include/kitepp/ticker/ws.hpp b/include/kitepp/ticker/ws.hpp index 8ed54b2..7c2087c 100644 --- a/include/kitepp/ticker/ws.hpp +++ b/include/kitepp/ticker/ws.hpp @@ -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 namespace kiteconnect { diff --git a/include/kitepp/utils.hpp b/include/kitepp/utils.hpp index ad0502c..e34fd4a 100644 --- a/include/kitepp/utils.hpp +++ b/include/kitepp/utils.hpp @@ -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) @@ -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: @@ -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, @@ -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; @@ -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, @@ -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; @@ -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"); diff --git a/include/rapidjson b/include/rapidjson deleted file mode 160000 index 56f215e..0000000 --- a/include/rapidjson +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 56f215e5c367f71a90af53984148e556ffe83541 diff --git a/uWS/libuWS.a b/uWS/libuWS.a new file mode 100644 index 0000000..1896ddd Binary files /dev/null and b/uWS/libuWS.a differ diff --git a/vcpkg b/vcpkg new file mode 160000 index 0000000..f9bea5d --- /dev/null +++ b/vcpkg @@ -0,0 +1 @@ +Subproject commit f9bea5d58186dc14e7e33132e43b52222147f51e diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..e03c323 --- /dev/null +++ b/vcpkg.json @@ -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" + ] + } \ No newline at end of file