From 9d51f5ab90651646f2263b036f9497c6bb2b879b Mon Sep 17 00:00:00 2001 From: ttldtor Date: Thu, 12 Oct 2023 18:32:59 +0300 Subject: [PATCH] InstrumentProfileReader::resolveSourceURL --- .../dxfeed_graal_cpp_api/ipf/InstrumentProfileReader.hpp | 6 ++++++ include/dxfeed_graal_cpp_api/isolated/Isolated.hpp | 2 ++ src/internal/Isolate.cpp | 9 +++++++++ src/ipf/InstrumentProfileReader.cpp | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/include/dxfeed_graal_cpp_api/ipf/InstrumentProfileReader.hpp b/include/dxfeed_graal_cpp_api/ipf/InstrumentProfileReader.hpp index 6cc7c2d2..e4214e85 100644 --- a/include/dxfeed_graal_cpp_api/ipf/InstrumentProfileReader.hpp +++ b/include/dxfeed_graal_cpp_api/ipf/InstrumentProfileReader.hpp @@ -67,6 +67,12 @@ class DXFCPP_EXPORT InstrumentProfileReader final : public SharedEntity { */ bool wasComplete() const noexcept; + /** + * Converts a specified string address specification into an URL that will be read by + * InstrumentProfileReader::readFromFile() method. + */ + static std::string resolveSourceURL(const std::string &address) noexcept; + /** * Reads and returns instrument profiles from specified file. * This method recognizes data compression formats "zip" and "gzip" automatically. diff --git a/include/dxfeed_graal_cpp_api/isolated/Isolated.hpp b/include/dxfeed_graal_cpp_api/isolated/Isolated.hpp index 0c65b2ca..34f70855 100644 --- a/include/dxfeed_graal_cpp_api/isolated/Isolated.hpp +++ b/include/dxfeed_graal_cpp_api/isolated/Isolated.hpp @@ -31,6 +31,8 @@ struct InstrumentProfileReader { static /* dxfg_instrument_profile_list* */ void * readFromFile(/* dxfg_instrument_profile_reader_t * */ void *graalInstrumentProfileReaderHandle, const std::string &address, const std::string &user, const std::string &password) noexcept; + + static std::string resolveSourceURL(const std::string & address) noexcept; }; struct InstrumentProfileList { diff --git a/src/internal/Isolate.cpp b/src/internal/Isolate.cpp index b26f513d..79017eff 100644 --- a/src/internal/Isolate.cpp +++ b/src/internal/Isolate.cpp @@ -300,6 +300,15 @@ InstrumentProfileReader::readFromFile(/* dxfg_instrument_profile_reader_t * */ v user, password)); } +std::string InstrumentProfileReader::resolveSourceURL(const std::string &address) noexcept { + return dxfcpp::toString(runIsolatedOrElse( + [](auto threadHandle, auto &&address) { + return dxfg_InstrumentProfileReader_resolveSourceURL( + dxfcpp::bit_cast(threadHandle), address.c_str()); + }, + nullptr, address)); +} + bool InstrumentProfileList::release(/* dxfg_instrument_profile_list * */ void *graalInstrumentProfileList) noexcept { if (!graalInstrumentProfileList) { return false; diff --git a/src/ipf/InstrumentProfileReader.cpp b/src/ipf/InstrumentProfileReader.cpp index f8b7b37b..f323fe0d 100644 --- a/src/ipf/InstrumentProfileReader.cpp +++ b/src/ipf/InstrumentProfileReader.cpp @@ -38,6 +38,10 @@ bool InstrumentProfileReader::wasComplete() const noexcept { return isolated::ipf::InstrumentProfileReader::wasComplete(handle_.get()); } +std::string InstrumentProfileReader::resolveSourceURL(const std::string &address) noexcept { + return isolated::ipf::InstrumentProfileReader::resolveSourceURL(address); +} + std::vector> fromGraalList(void *graalList) { using ListType = dxfg_instrument_profile_list; using SizeType = decltype(ListType::size);