From 24a73dcc331cb489b78187c314a636f3ecb50833 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 13 Mar 2025 08:57:17 -0500 Subject: [PATCH 1/7] Streamline and simplify configure and Makevars.in --- ChangeLog | 5 +++++ configure | 8 ++++---- src/Makevars.in | 32 +++++++++++++++++++++----------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index a04b3a2..be9b633 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2025-03-13 Dirk Eddelbuettel + + * configure: Streamline and simplify conditional compilation + * src/Makevars.in: Idem + 2025-03-12 John Laing * src/authenticate.cpp: Correct duplicate export declaration diff --git a/configure b/configure index 81a9920..72a35ad 100755 --- a/configure +++ b/configure @@ -39,7 +39,7 @@ else echo "Check https://www.bloomberg.com/professional/support/api-library/ for possible support first." echo "Contributions welcome, see https://github.com/Rblp/blp for integration with Rblapi." echo "The build will proceed but not be functional for lack of a library." - sed -e"s/@config@//" -e"s/@badsystem@/-DNoBlpHere/" src/Makevars.in > src/Makevars + sed -e"s/@have_blp@/-DNoBlpHere/" src/Makevars.in > src/Makevars exit 0 fi @@ -47,7 +47,7 @@ fi arch=$(uname -m) if [ "${arch}" = "x86_64" -a "${platform}" = "linux" ]; then echo "Setting up compilation for a ${platform} ${arch} system" - sed -e"s/@config@/-lblpapi3_64/" -e"s/@badsystem@//" src/Makevars.in > src/Makevars + sed -e"s/@have_blp@/yes/" src/Makevars.in > src/Makevars flavour="64" # this used to matter when Blp supported x86 on macos, they no longer do #if [ "${platform}" = "osx" ]; then @@ -55,7 +55,7 @@ if [ "${arch}" = "x86_64" -a "${platform}" = "linux" ]; then #fi elif [ "${arch}" = "arm64" -a "${platform}" = "osx" ]; then echo "Setting up compilation for a ${platform} ${arch} system" - sed -e"s/@config@/-lblpapi3_64/" -e"s/@badsystem@//" src/Makevars.in > src/Makevars + sed -e"s/@have_blp@/yes/" src/Makevars.in > src/Makevars flavour="64" cpu="arm" #elif [ "${arch}" = "i686" ]; then @@ -66,7 +66,7 @@ else echo "Unsupported platform and architecture combination: ${platform} ${arch}." echo "The build will proceed but not be functional for lack of a library." echo "If you need such a combination please get in touch with the Blp vendor." - sed -e"s/@config@//" -e"s/@badsystem@/-DNoBlpHere/" src/Makevars.in > src/Makevars + sed -e"s/@have_blp@/no/" src/Makevars.in > src/Makevars exit 0 fi diff --git a/src/Makevars.in b/src/Makevars.in index 785b808..4688af3 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -20,20 +20,30 @@ ## You should have received a copy of the GNU General Public License ## along with Rblpapi. If not, see . -## filled in by configure -BBG_LIB = @config@ -BBG_RPATH = '$$ORIGIN/../blp' +## ------ Overall 'do we expect to have blp support available' state filled in by configure +## +HAVE_BLP = @have_blp@ +## ------ Case of blp support available +## +ifeq ($(HAVE_BLP), yes) + +## this used to be filled in by configure but now both cases use the same value anyway +BBG_LIB = -lblpapi3_64 +BBG_RPATH = '$$ORIGIN/../blp' ## set include and linker options ## Bbg API files are assummed to be in the standard search path -PKG_CPPFLAGS = -I../inst/include/ -I. @badsystem@ +PKG_CPPFLAGS = -I../inst/include/ -I. -DHaveBlp PKG_LIBS = $(BBG_LIB) -L../inst/blp -Wl,-rpath,$(BBG_RPATH) all: $(SHLIB) - # we rely on configure to replace @badsystem@ here to create a side effect - # notice that that there are only two outcomes we need to differentiate: - # - either (on a 'good' system with blp) we will in an empty string, so command -v works as - # usual and we can run install_name_tool to add/update the rpath of shared librart - # - or on a bad system without blp we append -DNoBlpHere making command -v fail and avoiding - # an install_name_call that would fails as we have no Rblpapi.so to adjust - @if command -v install_name_tool@badsystem@; then echo "fixing"; install_name_tool -add_rpath @loader_path/../blp Rblpapi.so; fi + @if command -v install_name_tool; then echo "fixing"; install_name_tool -add_rpath @loader_path/../blp Rblpapi.so; fi + + +## ------ Alternate case of no blp support on build platform +else + +## use flag to compile without interfacing blp objects +PKG_CPPFLAGS = -DNoBlpHere + +endif From 0cea5cfc50338fb53a5de6182e498da4a8241458 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 13 Mar 2025 08:59:24 -0500 Subject: [PATCH 2/7] Add macos-13 to CI matrix for test on x86_64 macos without blp --- .github/workflows/ci.yaml | 3 ++- ChangeLog | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6c042b1..9aa94ff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,8 @@ jobs: strategy: matrix: include: - - {os: macOS-latest} + - {os: macos-13} + - {os: macos-latest} - {os: ubuntu-latest} runs-on: ${{ matrix.os }} diff --git a/ChangeLog b/ChangeLog index be9b633..4f9f91f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ * configure: Streamline and simplify conditional compilation * src/Makevars.in: Idem + * .github/workflows/ci.yaml: Add macos-13 build for no-blp x86_64 + 2025-03-12 John Laing * src/authenticate.cpp: Correct duplicate export declaration From 4c942f921cd974ebd933b2db480af9b462a7bd24 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 13 Mar 2025 09:07:21 -0500 Subject: [PATCH 3/7] Remove a bashism in configure --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 72a35ad..67a17de 100755 --- a/configure +++ b/configure @@ -39,13 +39,13 @@ else echo "Check https://www.bloomberg.com/professional/support/api-library/ for possible support first." echo "Contributions welcome, see https://github.com/Rblp/blp for integration with Rblapi." echo "The build will proceed but not be functional for lack of a library." - sed -e"s/@have_blp@/-DNoBlpHere/" src/Makevars.in > src/Makevars + sed -e"s/@have_blp@/no/" src/Makevars.in > src/Makevars exit 0 fi ## Populate Makevars arch=$(uname -m) -if [ "${arch}" = "x86_64" -a "${platform}" = "linux" ]; then +if [ "${arch}" = "x86_64" ] && [ "${platform}" = "linux" ]; then echo "Setting up compilation for a ${platform} ${arch} system" sed -e"s/@have_blp@/yes/" src/Makevars.in > src/Makevars flavour="64" @@ -53,7 +53,7 @@ if [ "${arch}" = "x86_64" -a "${platform}" = "linux" ]; then #if [ "${platform}" = "osx" ]; then # cpu="x86" #fi -elif [ "${arch}" = "arm64" -a "${platform}" = "osx" ]; then +elif [ "${arch}" = "arm64" ] && [ "${platform}" = "osx" ]; then echo "Setting up compilation for a ${platform} ${arch} system" sed -e"s/@have_blp@/yes/" src/Makevars.in > src/Makevars flavour="64" From f96e00ad502671153b8f7f9237b77865018c8270 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 13 Mar 2025 09:27:52 -0500 Subject: [PATCH 4/7] GNU make is a SystemRequirement (because of ifeq/endif) --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e4ddafc..30a1ae3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,13 +12,13 @@ VignetteBuilder: simplermarkdown LazyLoad: yes LinkingTo: Rcpp, BH Description: An R Interface to 'Bloomberg' is provided via the 'Blp API'. -SystemRequirements: A valid Bloomberg installation. The API headers and +SystemRequirements: GNU make. A valid Bloomberg installation. The API headers and dynamic library are downloaded from during the build step. See as well as for API documentation. Currently supported platforms are Windows and Linux (both for x86-64 processors only) as well as macOS (for arm64 only). Other os-cpu pairings - are not supported by Bloomberg and can therefore not be supported here. + are not supported by Bloomberg and can therefore not be fully supported here. URL: https://dirk.eddelbuettel.com/code/rblpapi.html, https://github.com/Rblp/Rblpapi BugReports: https://github.com/Rblp/Rblpapi/issues License: file LICENSE From 2190f2595bf5f88d7b41ea80f25d072debdbb404 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 13 Mar 2025 10:08:43 -0500 Subject: [PATCH 5/7] Roll micro version and date --- ChangeLog | 2 ++ DESCRIPTION | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4f9f91f..05a1322 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2025-03-13 Dirk Eddelbuettel + * DESCRIPTION (Version, Date): Roll micro version and date + * configure: Streamline and simplify conditional compilation * src/Makevars.in: Idem diff --git a/DESCRIPTION b/DESCRIPTION index 30a1ae3..64aee84 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Rblpapi Title: R Interface to 'Bloomberg' -Version: 0.3.15.2 -Date: 2025-03-09 +Version: 0.3.15.3 +Date: 2025-03-13 Authors@R: c(person("Whit", "Armstrong", role = "aut"), person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "edd@debian.org", comment = c(ORCID = "0000-0001-6419-907X")), From a6e602a5c69333a3da1bb4a5f9ff09a65464f6f8 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 13 Mar 2025 16:00:43 -0500 Subject: [PATCH 6/7] Cover 'yes/no' case fully from configure so no ifeq needed in make --- DESCRIPTION | 2 +- configure | 4 ++-- src/Makevars.in | 19 +++++-------------- src/Makevars.no_blp | 27 +++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 src/Makevars.no_blp diff --git a/DESCRIPTION b/DESCRIPTION index 64aee84..e41dbfe 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,7 +12,7 @@ VignetteBuilder: simplermarkdown LazyLoad: yes LinkingTo: Rcpp, BH Description: An R Interface to 'Bloomberg' is provided via the 'Blp API'. -SystemRequirements: GNU make. A valid Bloomberg installation. The API headers and +SystemRequirements: A valid Bloomberg installation. The API headers and dynamic library are downloaded from during the build step. See as well as for API diff --git a/configure b/configure index 67a17de..22594e6 100755 --- a/configure +++ b/configure @@ -39,7 +39,7 @@ else echo "Check https://www.bloomberg.com/professional/support/api-library/ for possible support first." echo "Contributions welcome, see https://github.com/Rblp/blp for integration with Rblapi." echo "The build will proceed but not be functional for lack of a library." - sed -e"s/@have_blp@/no/" src/Makevars.in > src/Makevars + cp -ax src/Makevars.no_blp src/Makevars exit 0 fi @@ -66,7 +66,7 @@ else echo "Unsupported platform and architecture combination: ${platform} ${arch}." echo "The build will proceed but not be functional for lack of a library." echo "If you need such a combination please get in touch with the Blp vendor." - sed -e"s/@have_blp@/no/" src/Makevars.in > src/Makevars + cp -ax src/Makevars.no_blp src/Makevars exit 0 fi diff --git a/src/Makevars.in b/src/Makevars.in index 4688af3..ae621a0 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -20,17 +20,17 @@ ## You should have received a copy of the GNU General Public License ## along with Rblpapi. If not, see . -## ------ Overall 'do we expect to have blp support available' state filled in by configure +## Overall 'do we expect to have blp support available' state filled in by configure ## +## (This variable is actually not used below and just left as a reminder 'how to' do +## such replacements with `sed` from `configure`. The build with blp uses the same library +## names throughout; we used to have 32 vs 64 bit builds in past.) HAVE_BLP = @have_blp@ -## ------ Case of blp support available -## -ifeq ($(HAVE_BLP), yes) - ## this used to be filled in by configure but now both cases use the same value anyway BBG_LIB = -lblpapi3_64 BBG_RPATH = '$$ORIGIN/../blp' + ## set include and linker options ## Bbg API files are assummed to be in the standard search path PKG_CPPFLAGS = -I../inst/include/ -I. -DHaveBlp @@ -38,12 +38,3 @@ PKG_LIBS = $(BBG_LIB) -L../inst/blp -Wl,-rpath,$(BBG_RPATH) all: $(SHLIB) @if command -v install_name_tool; then echo "fixing"; install_name_tool -add_rpath @loader_path/../blp Rblpapi.so; fi - - -## ------ Alternate case of no blp support on build platform -else - -## use flag to compile without interfacing blp objects -PKG_CPPFLAGS = -DNoBlpHere - -endif diff --git a/src/Makevars.no_blp b/src/Makevars.no_blp new file mode 100644 index 0000000..68f2af1 --- /dev/null +++ b/src/Makevars.no_blp @@ -0,0 +1,27 @@ +## -*- mode: makefile; -*- +## +## Makefile -- Unix build system +## +## Copyright (C) 2015-present Dirk Eddelbuettel and Jeroen Ooms +## Copyright (C) 2022-present Tomas Kalibera and Dirk Eddelbuettel +## +## This file is part of Rblpapi +## +## Rblpapi is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 2 of the License, or +## (at your option) any later version. +## +## Rblpapi is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Rblpapi. If not, see . + +## The 'no blp' build does not require headers or linking: when no blp is +## available, none is used: the build is 'naked' + +## use flag to compile without interfacing blp objects +PKG_CPPFLAGS = -DNoBlpHere From 74e34004d3debf75991200c0a89f0c67031de504 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Fri, 14 Mar 2025 15:12:23 -0500 Subject: [PATCH 7/7] Rework in terms of an affirming -DHaveBlp and streamline code --- ChangeLog | 23 ++++++++++++++++++ R/RcppExports.R | 9 +++++++ R/init.R | 12 ++++------ man/blpAuthenticate.Rd | 12 ++++------ man/getTicks.Rd | 2 +- man/haveBlp.Rd | 17 ++++++++++++++ src/Makevars.win | 5 ++-- src/RcppExports.cpp | 15 ++++++++++-- src/authenticate.cpp | 25 +++++++++----------- src/bdh.cpp | 24 +++++++------------ src/bdp.cpp | 21 +++++++---------- src/bds.cpp | 33 +++++++++++--------------- src/beqs.cpp | 46 +++++++++++++----------------------- src/blpConnect.cpp | 18 ++++++-------- src/blpVersion.cpp | 36 +++++++++++++++++----------- src/blpapi_utils.cpp | 2 +- src/bsrch.cpp | 37 ++++++++++------------------- src/fieldsearch.cpp | 20 +++++++--------- src/getBars.cpp | 29 +++++++---------------- src/getFieldInfo.cpp | 53 ++++++++++++++++++------------------------ src/getTicks.cpp | 30 +++++++----------------- src/lookup.cpp | 26 ++++++--------------- src/subscribe.cpp | 20 ++++++---------- 23 files changed, 235 insertions(+), 280 deletions(-) create mode 100644 man/haveBlp.Rd diff --git a/ChangeLog b/ChangeLog index 05a1322..730ddc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2025-03-14 Dirk Eddelbuettel + + * src/authenticate.cpp: Redefine in terms of -DHaveBlp flag and bring + if/else inside the function itself + * src/bdh.cpp: Idem + * src/bdp.cpp: Idem + * src/bds.cpp: Idem + * src/beqs.cpp: Idem + * src/blpConnect.cpp: Idem + * src/blpVersion.cpp: Idem + * src/blpapi_utils.cpp: Idem + * src/bsrch.cpp: Idem + * src/fieldsearch.cpp: Idem + * src/getBars.cpp: Idem + * src/getFieldInfo.cpp: Idem + * src/getTicks.cpp: Idem + * src/lookup.cpp: Idem + * src/subscribe.cpp: Idem + + * src/blpVersion.cpp: Define simple haveBlp() helper + * man/haveBlp.Rd: Documentation for haveBlp() + * R/init.R: Use more explicit haveBlp() + 2025-03-13 Dirk Eddelbuettel * DESCRIPTION (Version, Date): Roll micro version and date diff --git a/R/RcppExports.R b/R/RcppExports.R index 6012056..5f2071c 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -59,6 +59,15 @@ getRuntimeVersion <- function() { .Call(`_Rblpapi_getRuntimeVersion`) } +#' This function returns a boolean indicating whether Blp support is available. +#' +#' @title Get Blp availability in current build +#' @return A logical indicating whether Blp was available at build. +#' @author Dirk Eddelbuettel +haveBlp <- function() { + .Call(`_Rblpapi_haveBlp`) +} + bsrch_Impl <- function(con, domain, limit, verbose = FALSE) { .Call(`_Rblpapi_bsrch_Impl`, con, domain, limit, verbose) } diff --git a/R/init.R b/R/init.R index c78e78e..1d77631 100644 --- a/R/init.R +++ b/R/init.R @@ -21,16 +21,12 @@ .pkgenv <- new.env(parent=emptyenv()) .onAttach <- function(libname, pkgname) { - hrd <- getHeaderVersion() - rtm <- getRuntimeVersion() - if (nchar(hrd) + nchar(rtm) == 0) { - packageStartupMessage("No Blp available so no Rblapi functionality.") - } else { + if (haveBlp()) { packageStartupMessage(paste0("Rblpapi version ", packageVersion("Rblpapi"), - " using Blpapi headers ", hrd, " and run-time ", rtm, ".")) + " using Blpapi headers ", getHeaderVersion(), + " and run-time ", getRuntimeVersion(), ".")) packageStartupMessage(paste0("Please respect the Bloomberg licensing agreement ", "and terms of service.")) - if (getOption("blpAutoConnect", FALSE)) { con <- blpConnect() if (getOption("blpVerbose", FALSE)) { @@ -49,5 +45,7 @@ } assign("con", con, envir=.pkgenv) assign("blpAuth", blpAuth, envir=.pkgenv) + } else { + packageStartupMessage("No Blp available so no Rblapi functionality.") } } diff --git a/man/blpAuthenticate.Rd b/man/blpAuthenticate.Rd index 2a0bd4e..908089d 100644 --- a/man/blpAuthenticate.Rd +++ b/man/blpAuthenticate.Rd @@ -4,15 +4,11 @@ \alias{blpAuthenticate} \title{Authenticate Bloomberg API access} \usage{ -blpAuthenticate( - uuid = getOption("blpUUID", NULL), +blpAuthenticate(uuid = getOption("blpUUID", NULL), host = getOption("blpLoginHostname", "localhost"), - ip.address = getOption("blpLoginIP", NULL), - con = defaultConnection(), - default = TRUE, - isAuthId = getOption("blpIsAuthId", FALSE), - appName = getOption("blpAppName", NULL) -) + ip.address = getOption("blpLoginIP", NULL), con = defaultConnection(), + default = TRUE, isAuthId = getOption("blpIsAuthId", FALSE), + appName = getOption("blpAppName", NULL)) } \arguments{ \item{uuid}{An optional character variable with a unique user id diff --git a/man/getTicks.Rd b/man/getTicks.Rd index d2b0abe..5c9aeae 100644 --- a/man/getTicks.Rd +++ b/man/getTicks.Rd @@ -40,7 +40,7 @@ call, and retrieved via the internal function Depending on the value of \sQuote{returnAs}, either a \sQuote{data.frame} or \sQuote{data.table} object also containing non-numerical information such as condition codes, or a time-indexed -container of type \sQuote{xts} and \sQuote{zoo} with +container of type \sQuote{xts} or \sQuote{zoo} with a numeric matrix containing only \sQuote{value} and \sQuote{size}. } \description{ diff --git a/man/haveBlp.Rd b/man/haveBlp.Rd new file mode 100644 index 0000000..61c373a --- /dev/null +++ b/man/haveBlp.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/RcppExports.R +\name{haveBlp} +\alias{haveBlp} +\title{Get Blp availability in current build} +\usage{ +haveBlp() +} +\value{ +A logical indicating whether Blp was available at build. +} +\description{ +This function returns a boolean indicating whether Blp support is available. +} +\author{ +Dirk Eddelbuettel +} diff --git a/src/Makevars.win b/src/Makevars.win index 449a391..7dff8a1 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -2,7 +2,7 @@ ## ## Makefile.win -- Windows build system ## -## Copyright (C) 2015 - 2024 Whit Armstrong and Dirk Eddelbuettel +## Copyright (C) 2015 - 2025 Whit Armstrong and Dirk Eddelbuettel ## ## This file is part of Rblpapi ## @@ -28,8 +28,7 @@ else endif ## Standard compiler / linker flags including windows flavor -# CXX_STD = CXX11 -PKG_CPPFLAGS = -I../inst/include -I. +PKG_CPPFLAGS = -I../inst/include -I. -DHaveBlp PKG_LIBS = -lblpapi3_${WIN} -L${FLV} diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index f1d8cc3..3f40868 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -98,7 +98,7 @@ BEGIN_RCPP END_RCPP } // beqs_Impl -DataFrame beqs_Impl(SEXP con, std::string screenName, std::string screenType, std::string group, std::string pitdate, std::string languageId, bool verbose); +Rcpp::DataFrame beqs_Impl(SEXP con, std::string screenName, std::string screenType, std::string group, std::string pitdate, std::string languageId, bool verbose); RcppExport SEXP _Rblpapi_beqs_Impl(SEXP conSEXP, SEXP screenNameSEXP, SEXP screenTypeSEXP, SEXP groupSEXP, SEXP pitdateSEXP, SEXP languageIdSEXP, SEXP verboseSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; @@ -148,8 +148,18 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// haveBlp +bool haveBlp(); +RcppExport SEXP _Rblpapi_haveBlp() { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + rcpp_result_gen = Rcpp::wrap(haveBlp()); + return rcpp_result_gen; +END_RCPP +} // bsrch_Impl -DataFrame bsrch_Impl(SEXP con, std::string domain, std::string limit, bool verbose); +Rcpp::DataFrame bsrch_Impl(SEXP con, std::string domain, std::string limit, bool verbose); RcppExport SEXP _Rblpapi_bsrch_Impl(SEXP conSEXP, SEXP domainSEXP, SEXP limitSEXP, SEXP verboseSEXP) { BEGIN_RCPP Rcpp::RObject rcpp_result_gen; @@ -264,6 +274,7 @@ static const R_CallMethodDef CallEntries[] = { {"_Rblpapi_blpConnect_Impl", (DL_FUNC) &_Rblpapi_blpConnect_Impl, 4}, {"_Rblpapi_getHeaderVersion", (DL_FUNC) &_Rblpapi_getHeaderVersion, 0}, {"_Rblpapi_getRuntimeVersion", (DL_FUNC) &_Rblpapi_getRuntimeVersion, 0}, + {"_Rblpapi_haveBlp", (DL_FUNC) &_Rblpapi_haveBlp, 0}, {"_Rblpapi_bsrch_Impl", (DL_FUNC) &_Rblpapi_bsrch_Impl, 4}, {"_Rblpapi_fieldSearch_Impl", (DL_FUNC) &_Rblpapi_fieldSearch_Impl, 2}, {"_Rblpapi_getBars_Impl", (DL_FUNC) &_Rblpapi_getBars_Impl, 8}, diff --git a/src/authenticate.cpp b/src/authenticate.cpp index 4ee80af..8a3ea11 100644 --- a/src/authenticate.cpp +++ b/src/authenticate.cpp @@ -20,8 +20,7 @@ // You should have received a copy of the GNU General Public License // along with Rblpapi. If not, see . -#if !defined(NoBlpHere) - +#if defined(HaveBlp) #include #include #include @@ -32,7 +31,6 @@ #include #include #include -#include #include #include @@ -180,27 +178,26 @@ Identity* authenticateWithApp(SEXP con_) { } return identity_p; } +#else +#include +#endif // Simpler interface // // [[Rcpp::export]] -SEXP authenticate_Impl(SEXP con_, SEXP uuid_, SEXP ip_address_, SEXP is_auth_id_, - SEXP app_name_) { +SEXP authenticate_Impl(SEXP con_, SEXP uuid_, SEXP ip_address_, SEXP is_auth_id_, SEXP app_name_) { +#if defined(HaveBlp) Identity* identity_p = NULL; if (uuid_ == R_NilValue) { identity_p = authenticateWithApp(con_); } else { identity_p = authenticateWithId(con_, uuid_, ip_address_, is_auth_id_, app_name_); } - if(identity_p == NULL) { Rcpp::stop("Identity pointer is null\n"); } + if (identity_p == NULL) { + Rcpp::stop("Identity pointer is null\n"); + } return createExternalPointer(identity_p, identityFinalizer, "blpapi::Identity*"); -} - -#else // ie if defined(NoBlpHere) - -#include -SEXP authenticate_Impl(SEXP con_, SEXP uuid_, SEXP ip_address_, SEXP is_auth_id_, SEXP app_name_) { +#else // ie no Blp return R_NilValue; -} - #endif +} diff --git a/src/bdh.cpp b/src/bdh.cpp index c63a0f8..77aa3f2 100644 --- a/src/bdh.cpp +++ b/src/bdh.cpp @@ -19,8 +19,7 @@ // You should have received a copy of the GNU General Public License // along with Rblpapi. If not, see . -#if !defined(NoBlpHere) - +#if defined(HaveBlp) #include #include #include @@ -29,7 +28,6 @@ #include #include #include -#include #include using BloombergLP::blpapi::Session; @@ -89,6 +87,9 @@ Rcpp::List HistoricalDataResponseToDF(Event& event, const std::vector +#endif // Simpler interface with std::vector thanks to Rcpp::Attributes // [[Rcpp::export]] @@ -100,6 +101,8 @@ Rcpp::List bdh_Impl(SEXP con_, bool verbose, SEXP identity_, bool int_as_double) { +#if defined(HaveBlp) + Session* session = reinterpret_cast(checkExternalPointer(con_,"blpapi::Session*")); @@ -189,19 +192,8 @@ Rcpp::List bdh_Impl(SEXP con_, } ans.attr("names") = ans_names; return ans; -} -#else // ie if defined(NoBlpHere) - -#include -Rcpp::List bdh_Impl(SEXP con_, - std::vector securities, - std::vector fields, - std::string start_date_, SEXP end_date_, - SEXP options_, SEXP overrides_, - bool verbose, SEXP identity_, - bool int_as_double) { +#else // ie no Blp return Rcpp::List(); -} - #endif +} diff --git a/src/bdp.cpp b/src/bdp.cpp index 6fc583c..d91c92b 100644 --- a/src/bdp.cpp +++ b/src/bdp.cpp @@ -19,11 +19,8 @@ // You should have received a copy of the GNU General Public License // along with Rblpapi. If not, see . -#if !defined(NoBlpHere) - +#if defined(HaveBlp) // compare to RefDataExample.cpp - - #include #include #include @@ -33,7 +30,6 @@ #include #include #include -#include #include using BloombergLP::blpapi::Session; @@ -91,6 +87,9 @@ void getBDPResult(Event& event, Rcpp::List& res, const std::vector& } } } +#else +#include +#endif // Simpler interface with std::vector thanks to Rcpp::Attributes // @@ -98,6 +97,8 @@ void getBDPResult(Event& event, Rcpp::List& res, const std::vector& Rcpp::List bdp_Impl(SEXP con_, std::vector securities, std::vector fields, SEXP options_, SEXP overrides_, bool verbose, SEXP identity_) { +#if defined(HaveBlp) + // via Rcpp Attributes we get a try/catch block with error propagation to R "for free" Session* session = reinterpret_cast(checkExternalPointer(con_, "blpapi::Session*")); @@ -138,14 +139,8 @@ Rcpp::List bdp_Impl(SEXP con_, std::vector securities, std::vector< if (event.eventType() == Event::RESPONSE) { break; } } return res; -} -#else // ie if defined(NoBlpHere) - -#include -Rcpp::List bdp_Impl(SEXP con_, std::vector securities, std::vector fields, - SEXP options_, SEXP overrides_, bool verbose, SEXP identity_) { +#else // ie no Blp return Rcpp::List(); -} - #endif +} diff --git a/src/bds.cpp b/src/bds.cpp index bd5a279..af611ed 100644 --- a/src/bds.cpp +++ b/src/bds.cpp @@ -19,8 +19,7 @@ // You should have received a copy of the GNU General Public License // along with Rblpapi. If not, see . -#if !defined(NoBlpHere) - +#if defined(HaveBlp) #include #include #include @@ -29,7 +28,6 @@ #include #include #include -#include #include using BloombergLP::blpapi::Session; @@ -248,6 +246,9 @@ Rcpp::List BulkDataResponseToDF(Event& event, std::string& requested_field, std: ans.attr("names") = ans_names; return ans; } +#else +#include +#endif // only allow one field for bds in contrast to bdp // [[Rcpp::export]] @@ -255,6 +256,8 @@ Rcpp::List bds_Impl(SEXP con_, std::vector securities, std::string field, SEXP options_, SEXP overrides_, bool verbose, SEXP identity_) { +#if defined(HaveBlp) + Session* session = reinterpret_cast(checkExternalPointer(con_, "blpapi::Session*")); @@ -292,7 +295,10 @@ Rcpp::List bds_Impl(SEXP con_, std::vector securities, } if (event.eventType() == Event::RESPONSE) { break; } } - return R_NilValue; + return Rcpp::List(); +#else // ie no Blp + return Rcpp::List(); +#endif } // [[Rcpp::export]] @@ -300,6 +306,8 @@ Rcpp::List getPortfolio_Impl(SEXP con_, std::vector securities, std::string field, SEXP options_, SEXP overrides_, bool verbose, SEXP identity_) { +#if defined(HaveBlp) + Session* session = reinterpret_cast(checkExternalPointer(con_, "blpapi::Session*")); @@ -337,21 +345,8 @@ Rcpp::List getPortfolio_Impl(SEXP con_, std::vector securities, } if (event.eventType() == Event::RESPONSE) { break; } } - return R_NilValue; -} - -#else // ie if defined(NoBlpHere) - -#include -Rcpp::List bds_Impl(SEXP con_, std::vector securities, - std::string field, SEXP options_, SEXP overrides_, - bool verbose, SEXP identity_) { return Rcpp::List(); -} -Rcpp::List getPortfolio_Impl(SEXP con_, std::vector securities, - std::string field, SEXP options_, SEXP overrides_, - bool verbose, SEXP identity_) { +#else // ie no Blp return Rcpp::List(); -} - #endif +} diff --git a/src/beqs.cpp b/src/beqs.cpp index a389e2e..81d439b 100644 --- a/src/beqs.cpp +++ b/src/beqs.cpp @@ -20,8 +20,7 @@ // TODO: Date, Datetime, Int (?), ... results -#if !defined(NoBlpHere) - +#if defined(HaveBlp) #include #include #include @@ -30,18 +29,13 @@ #include #include #include -#include #include - - #include #include #include #include #include #include - - #include using namespace std; using namespace Rcpp; @@ -170,17 +164,20 @@ Rcpp::DataFrame processResponseEvent(Event event, const bool verbose) { Rcpp::DataFrame df(lst); return df; } - - +#else +#include +#endif // [[Rcpp::export]] -DataFrame beqs_Impl(SEXP con, - std::string screenName, - std::string screenType, - std::string group, - std::string pitdate, - std::string languageId, - bool verbose=false) { +Rcpp::DataFrame beqs_Impl(SEXP con, + std::string screenName, + std::string screenType, + std::string group, + std::string pitdate, + std::string languageId, + bool verbose=false) { + +#if defined(HaveBlp) Session* session = reinterpret_cast(checkExternalPointer(con, "blpapi::Session*")); @@ -242,19 +239,8 @@ DataFrame beqs_Impl(SEXP con, return ans; -} - -#else // ie if defined(NoBlpHere) - -#include -Rcpp::DataFrame beqs_Impl(SEXP con, - std::string screenName, - std::string screenType, - std::string group, - std::string pitdate, - std::string languageId, - bool verbose=false) { +#else // ie no Blp return Rcpp::DataFrame(); -} - #endif + +} diff --git a/src/blpConnect.cpp b/src/blpConnect.cpp index dc8f502..6539915 100644 --- a/src/blpConnect.cpp +++ b/src/blpConnect.cpp @@ -21,11 +21,9 @@ // You should have received a copy of the GNU General Public License // along with Rblpapi. If not, see . -#if !defined(NoBlpHere) - +#if defined(HaveBlp) #include #include -#include #include using BloombergLP::blpapi::Session; @@ -42,9 +40,13 @@ static void sessionFinalizer(SEXP session_) { R_ClearExternalPtr(session_); } } +#else +#include +#endif // [[Rcpp::export]] SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_, SEXP app_identity_key_) { +#if defined(HaveBlp) SessionOptions sessionOptions; sessionOptions.setServerHost(host.c_str()); sessionOptions.setServerPort(port); @@ -68,13 +70,7 @@ SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_, SEX } return createExternalPointer(sp, sessionFinalizer, "blpapi::Session*"); -} - -#else // ie if defined(NoBlpHere) - -#include -SEXP blpConnect_Impl(const std::string host, const int port, SEXP app_name_, SEXP app_identity_key_) { +#else // ie no Blp return R_NilValue; -} - #endif +} diff --git a/src/blpVersion.cpp b/src/blpVersion.cpp index b857930..fdb9a71 100644 --- a/src/blpVersion.cpp +++ b/src/blpVersion.cpp @@ -19,12 +19,12 @@ // You should have received a copy of the GNU General Public License // along with Rblpapi. If not, see . -#if !defined(NoBlpHere) - -#include +#if defined(HaveBlp) #include - using BloombergLP::blpapi::VersionInfo; +#else +#include +#endif // ' This function retrieves the version string of the Bloomberg API. // ' @@ -62,6 +62,7 @@ using BloombergLP::blpapi::VersionInfo; //' } // [[Rcpp::export]] std::string getHeaderVersion() { +#if defined(HaveBlp) // VersionInfo vi = VersionInfo::headerVersion(); // //Rcpp::Rcout << vi << std::endl; // char txt[128]; @@ -78,6 +79,9 @@ std::string getHeaderVersion() { BLPAPI_VERSION_PATCH, BLPAPI_VERSION_BUILD); return std::string(txt); +#else + return std::string(); +#endif } //' This function retrieves the version of Bloomberg API run-time. @@ -93,6 +97,7 @@ std::string getHeaderVersion() { //' } // [[Rcpp::export]] std::string getRuntimeVersion() { +#if defined(HaveBlp) // VersionInfo vi = VersionInfo::runtimeVersion(); // //Rcpp::Rcout << vi << std::endl; // char txt[128]; @@ -108,16 +113,21 @@ std::string getRuntimeVersion() { snprintf(txt, 127, "%d.%d.%d.%d", major, minor, patch, build); return std::string(txt); -} - -#else // ie if defined(NoBlpHere) - -#include -std::string getHeaderVersion() { - return std::string(); -} -std::string getRuntimeVersion() { +#else return std::string(); +#endif } +//' This function returns a boolean indicating whether Blp support is available. +//' +//' @title Get Blp availability in current build +//' @return A logical indicating whether Blp was available at build. +//' @author Dirk Eddelbuettel +// [[Rcpp::export]] +bool haveBlp() { +#if defined(HaveBlp) + return true; +#else + return false; #endif +} diff --git a/src/blpapi_utils.cpp b/src/blpapi_utils.cpp index 55c3623..5e8a71c 100644 --- a/src/blpapi_utils.cpp +++ b/src/blpapi_utils.cpp @@ -19,7 +19,7 @@ // You should have received a copy of the GNU General Public License // along with Rblpapi. If not, see . -#if !defined(NoBlpHere) +#if defined(HaveBlp) #include #include diff --git a/src/bsrch.cpp b/src/bsrch.cpp index 85814ae..6c50c85 100644 --- a/src/bsrch.cpp +++ b/src/bsrch.cpp @@ -18,8 +18,7 @@ // You should have received a copy of the GNU General Public License // along with Rblpapi. If not, see . -#if !defined(NoBlpHere) - +#if defined(HaveBlp) #include #include #include @@ -28,18 +27,13 @@ #include #include #include -#include #include - - #include #include #include #include #include #include - - #include using namespace std; using namespace Rcpp; @@ -173,14 +167,16 @@ Rcpp::DataFrame processBsrchResponse(Event event, const bool verbose) { Rcpp::DataFrame df(lst); return df; } - +#else +#include +#endif // [[Rcpp::export]] -DataFrame bsrch_Impl(SEXP con, - std::string domain, - std::string limit, - bool verbose=false) { - +Rcpp::DataFrame bsrch_Impl(SEXP con, + std::string domain, + std::string limit, + bool verbose=false) { +#if defined(HaveBlp) Session* session = reinterpret_cast(checkExternalPointer(con, "blpapi::Session*")); const std::string exrsrv = "//blp/exrsvc"; @@ -226,17 +222,8 @@ DataFrame bsrch_Impl(SEXP con, } return ans; - -} - -#else // ie if defined(NoBlpHere) - -#include -Rcpp::DataFrame bsrch_Impl(SEXP con, - std::string domain, - std::string limit, - bool verbose=false) { +#else // ie no Blp return Rcpp::DataFrame(); -} - #endif + +} diff --git a/src/fieldsearch.cpp b/src/fieldsearch.cpp index b5a4ac9..10a41a8 100644 --- a/src/fieldsearch.cpp +++ b/src/fieldsearch.cpp @@ -42,11 +42,9 @@ * IN THE SOFTWARE. */ -#if !defined(NoBlpHere) - +#if defined(HaveBlp) #include #include - namespace bbg = BloombergLP::blpapi; // shortcut to not globally import both namespace namespace { @@ -58,10 +56,13 @@ namespace { const bbg::Name FIELD_ERROR("fieldError"); const bbg::Name FIELD_MSG("message"); } +#else +#include +#endif // [[Rcpp::export]] Rcpp::DataFrame fieldSearch_Impl(SEXP con, std::string searchterm) { - +#if defined(HaveBlp) // via Rcpp Attributes we get a try/catch block with error propagation to R "for free" bbg::Session* session = reinterpret_cast(checkExternalPointer(con,"blpapi::Session*")); @@ -118,13 +119,8 @@ Rcpp::DataFrame fieldSearch_Impl(SEXP con, std::string searchterm) { return Rcpp::DataFrame::create(Rcpp::Named("Id") = fieldId, Rcpp::Named("Mnemonic") = fieldMnen, Rcpp::Named("Description") = fieldDesc); -} - -#else // ie if defined(NoBlpHere) - -#include -Rcpp::DataFrame fieldSearch_Impl(SEXP con, std::string searchterm) { +#else // ie no Blp return Rcpp::DataFrame(); -} - #endif + +} diff --git a/src/getBars.cpp b/src/getBars.cpp index cbcc79f..2200847 100644 --- a/src/getBars.cpp +++ b/src/getBars.cpp @@ -42,11 +42,9 @@ * IN THE SOFTWARE. */ -#if !defined(NoBlpHere) - +#if defined(HaveBlp) #include #include - #include #include #include @@ -61,7 +59,6 @@ #include #include #include - #include namespace bbg = BloombergLP::blpapi; // shortcut to not globally import both namespace @@ -154,6 +151,9 @@ void processResponseEvent(bbg::Event &event, Bars &bars, processMessage(msg, bars, barInterval, verbose); } } +#else +#include +#endif // [[Rcpp::export]] Rcpp::DataFrame getBars_Impl(SEXP con, @@ -164,7 +164,7 @@ Rcpp::DataFrame getBars_Impl(SEXP con, std::string endDateTime, Rcpp::Nullable options, bool verbose=false) { - +#if defined(HaveBlp) // via Rcpp Attributes we get a try/catch block with error propagation to R "for free" bbg::Session* session = reinterpret_cast(checkExternalPointer(con,"blpapi::Session*")); @@ -224,21 +224,8 @@ Rcpp::DataFrame getBars_Impl(SEXP con, Rcpp::Named("numEvents") = bars.numEvents, Rcpp::Named("volume") = bars.volume, Rcpp::Named("value") = bars.value); - -} - -#else // ie if defined(NoBlpHere) - -#include -Rcpp::DataFrame getBars_Impl(SEXP con, - std::string security, - std::string eventType, - int barInterval, - std::string startDateTime, - std::string endDateTime, - Rcpp::Nullable options, - bool verbose=false) { +#else // ie no Blp return Rcpp::DataFrame(); -} - #endif + +} diff --git a/src/getFieldInfo.cpp b/src/getFieldInfo.cpp index d64df34..fd9fd3b 100644 --- a/src/getFieldInfo.cpp +++ b/src/getFieldInfo.cpp @@ -15,11 +15,8 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////// -#if !defined(NoBlpHere) - -#include +#if defined(HaveBlp) #include - using BloombergLP::blpapi::Session; using BloombergLP::blpapi::Service; using BloombergLP::blpapi::Request; @@ -27,34 +24,30 @@ using BloombergLP::blpapi::Event; using BloombergLP::blpapi::Message; using BloombergLP::blpapi::MessageIterator; using BloombergLP::blpapi::Element; +#else +#include +#endif // [[Rcpp::export]] Rcpp::List fieldInfo_Impl(SEXP con_, std::vector fields) { - - Session* session = - reinterpret_cast(checkExternalPointer(con_, "blpapi::Session*")); - - // get the field info - std::vector fldinfos(getFieldTypes(session, fields)); - std::vector colnames {"id","mnemonic","datatype","ftype"}; - std::vector res_types(4,RblpapiT::String); - Rcpp::List res(allocateDataFrame(fields, colnames, res_types)); - R_len_t i(0); - for(auto f : fldinfos) { - SET_STRING_ELT(res[0],i,Rf_mkCharCE(f.id.c_str(), CE_UTF8)); - SET_STRING_ELT(res[1],i,Rf_mkCharCE(f.mnemonic.c_str(), CE_UTF8)); - SET_STRING_ELT(res[2],i,Rf_mkCharCE(f.datatype.c_str(), CE_UTF8)); - SET_STRING_ELT(res[3],i,Rf_mkCharCE(f.ftype.c_str(), CE_UTF8)); - ++i; - } - return res; -} - -#else // ie if defined(NoBlpHere) - -#include -Rcpp::List fieldInfo_Impl(SEXP con_, std::vector fields) { +#if defined(HaveBlp) + Session* session = reinterpret_cast(checkExternalPointer(con_, "blpapi::Session*")); + + // get the field info + std::vector fldinfos(getFieldTypes(session, fields)); + std::vector colnames {"id","mnemonic","datatype","ftype"}; + std::vector res_types(4,RblpapiT::String); + Rcpp::List res(allocateDataFrame(fields, colnames, res_types)); + R_len_t i(0); + for(auto f : fldinfos) { + SET_STRING_ELT(res[0],i,Rf_mkCharCE(f.id.c_str(), CE_UTF8)); + SET_STRING_ELT(res[1],i,Rf_mkCharCE(f.mnemonic.c_str(), CE_UTF8)); + SET_STRING_ELT(res[2],i,Rf_mkCharCE(f.datatype.c_str(), CE_UTF8)); + SET_STRING_ELT(res[3],i,Rf_mkCharCE(f.ftype.c_str(), CE_UTF8)); + ++i; + } + return res; +#else // ie no Blp return Rcpp::List(); -} - #endif +} diff --git a/src/getTicks.cpp b/src/getTicks.cpp index d2ecbb1..1974010 100644 --- a/src/getTicks.cpp +++ b/src/getTicks.cpp @@ -42,13 +42,12 @@ * IN THE SOFTWARE. */ -#if !defined(NoBlpHere) +#if defined(HaveBlp) #include #include #include #include - #include #include #include @@ -56,8 +55,6 @@ #include #include #include - - #include #include #include @@ -65,8 +62,6 @@ #include #include #include - -#include #include namespace bbg = BloombergLP::blpapi; // shortcut to not globally import both namespaces @@ -137,6 +132,9 @@ void processResponseEvent(bbg::Event &event, Ticks &ticks, const bool verbose) { processMessage(msg, ticks, verbose); } } +#else +#include +#endif // [[Rcpp::export]] Rcpp::DataFrame getTicks_Impl(SEXP con, @@ -146,7 +144,7 @@ Rcpp::DataFrame getTicks_Impl(SEXP con, std::string endDateTime, bool setCondCodes=true, bool verbose=false) { - +#if defined(HaveBlp) // via Rcpp Attributes we get a try/catch block with error propagation to R "for free" bbg::Session* session = reinterpret_cast(checkExternalPointer(con,"blpapi::Session*")); @@ -205,20 +203,8 @@ Rcpp::DataFrame getTicks_Impl(SEXP con, Rcpp::Named("value") = ticks.value, Rcpp::Named("size") = ticks.size, Rcpp::Named("condcode") = ticks.conditionCode); - -} - -#else // ie if defined(NoBlpHere) - -#include -Rcpp::DataFrame getTicks_Impl(SEXP con, - std::string security, - std::vector eventType, - std::string startDateTime, - std::string endDateTime, - bool setCondCodes=true, - bool verbose=false) { +#else // ie no Blp return Rcpp::DataFrame(); -} - #endif + +} diff --git a/src/lookup.cpp b/src/lookup.cpp index e03aebb..0221121 100644 --- a/src/lookup.cpp +++ b/src/lookup.cpp @@ -18,21 +18,17 @@ // You should have received a copy of the GNU General Public License // along with Rblpapi. If not, see . -#if !defined(NoBlpHere) +#if defined(HaveBlp) #include - #include #include #include #include #include - #include #include #include - -#include #include namespace bbg = BloombergLP::blpapi; // shortcut to not globally import both namespace @@ -86,6 +82,9 @@ void processResponseEvent(bbg::Event &event, InstrumentListResults &matches, con processMessage(msg, matches, verbose); } } +#else +#include +#endif // [[Rcpp::export]] Rcpp::DataFrame lookup_Impl(SEXP con, @@ -94,7 +93,7 @@ Rcpp::DataFrame lookup_Impl(SEXP con, std::string languageOverride="LANG_OVERRIDE_NONE", int maxResults=20, bool verbose=false) { - +#if defined(HaveBlp) // via Rcpp Attributes we get a try/catch block with error propagation to R "for free" bbg::Session* session = reinterpret_cast(checkExternalPointer(con,"blpapi::Session*")); @@ -142,18 +141,7 @@ Rcpp::DataFrame lookup_Impl(SEXP con, return Rcpp::DataFrame::create(Rcpp::Named("security") = matches.security, Rcpp::Named("description") = matches.description); -} - -#else // ie if defined(NoBlpHere) - -#include -Rcpp::DataFrame lookup_Impl(SEXP con, - std::string query, - std::string yellowKeyFilter="YK_FILTER_NONE", - std::string languageOverride="LANG_OVERRIDE_NONE", - int maxResults=20, - bool verbose=false) { +#else // ie no Blp return Rcpp::DataFrame(); -} - #endif +} diff --git a/src/subscribe.cpp b/src/subscribe.cpp index 65dbd5d..650af50 100644 --- a/src/subscribe.cpp +++ b/src/subscribe.cpp @@ -19,10 +19,9 @@ // You should have received a copy of the GNU General Public License // along with Rblpapi. If not, see . -#if !defined(NoBlpHere) +#if defined(HaveBlp) // compare to SimpleSubscriptionExample.cpp - #include #include #include @@ -35,7 +34,6 @@ #include #include #include -#include #include using BloombergLP::blpapi::Session; @@ -164,11 +162,14 @@ SEXP recursiveParse(const Element& e) { } } } +#else +#include +#endif // [[Rcpp::export]] SEXP subscribe_Impl(SEXP con_, std::vector securities, std::vector fields, Rcpp::Function fun, SEXP options_, SEXP identity_) { - +#if defined(HaveBlp) // via Rcpp Attributes we get a try/catch block with error propagation to R "for free" Session* session = reinterpret_cast(checkExternalPointer(con_, "blpapi::Session*")); @@ -231,14 +232,7 @@ SEXP subscribe_Impl(SEXP con_, std::vector securities, std::vector< session->unsubscribe(subscriptions); } return R_NilValue; -} - -#else // ie if defined(NoBlpHere) - -#include -SEXP subscribe_Impl(SEXP con_, std::vector securities, std::vector fields, - Rcpp::Function fun, SEXP options_, SEXP identity_) { +#else // ie no Blp return R_NilValue; -} - #endif +}