Skip to content

Commit

Permalink
InstrumentProfileReader::resolveSourceURL
Browse files Browse the repository at this point in the history
  • Loading branch information
ttldtor committed Oct 12, 2023
1 parent 06693da commit 9d51f5a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/dxfeed_graal_cpp_api/ipf/InstrumentProfileReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions include/dxfeed_graal_cpp_api/isolated/Isolated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions src/internal/Isolate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<graal_isolatethread_t *>(threadHandle), address.c_str());
},
nullptr, address));
}

bool InstrumentProfileList::release(/* dxfg_instrument_profile_list * */ void *graalInstrumentProfileList) noexcept {
if (!graalInstrumentProfileList) {
return false;
Expand Down
4 changes: 4 additions & 0 deletions src/ipf/InstrumentProfileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::shared_ptr<InstrumentProfile>> fromGraalList(void *graalList) {
using ListType = dxfg_instrument_profile_list;
using SizeType = decltype(ListType::size);
Expand Down

0 comments on commit 9d51f5a

Please sign in to comment.