From 4adeb06cbb946ec1ed10c90070e7036068113a9e Mon Sep 17 00:00:00 2001 From: mattfidler Date: Wed, 5 Aug 2026 11:26:11 -0500 Subject: [PATCH 01/13] fix: restore a fit's ID column as a factor The fit table round-trips through a plain .csv, so read.csv() brings ID back as an integer while a live fit carries a factor. Anything that joins the fit table against something derived from the fit then hits a type mismatch -- nlme::augPred() keeps its `id` a factor, so ggPMX::pmx_nlmixr() on a cached fit died in a data.table join with "Incompatible join types: x.ID (factor) and i.ID (integer)". Repaired in loadFit() rather than in the restore script written by saveFit(), so caches written by earlier versions are fixed on load too. Levels come from ranef/etaObf, which the restore script has already put back as factors with the fit's own levels. Co-Authored-By: Claude Opus 5 (1M context) --- NEWS.md | 9 +++++++ R/save.R | 48 ++++++++++++++++++++++++++++++++++++++ tests/testthat/test-save.R | 13 +++++++++++ 3 files changed, 70 insertions(+) diff --git a/NEWS.md b/NEWS.md index 4181c37..f75ac54 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,14 @@ # nlmixr2save 0.2.0 +* `loadFit()` (and therefore `:=`) now restores the fit table's `ID` column as a + factor. The table round-trips through a plain `.csv`, so `ID` came back as an + integer while a live fit carries a factor; anything joining the fit table to + something derived from the fit then hit a type mismatch, since + `nlme::augPred()` keeps its `id` a factor. `ggPMX::pmx_nlmixr()` on a cached + fit failed outright with "Incompatible join types: x.ID (factor) and i.ID + (integer)". The repair happens on load, so caches written by earlier versions + are fixed too. + * `nlmixrDataSimplify()` gained `est` and `control` arguments and no longer drops the covariate columns that `est="vae"` searches for. The VAE covariate search picks its covariates out of the data instead of out of the model, so diff --git a/R/save.R b/R/save.R index 984a2a5..0b4bc6c 100644 --- a/R/save.R +++ b/R/save.R @@ -703,6 +703,53 @@ saveFit.default <- function(fit, file, zip=TRUE, data=.nlmixr2saveData()) { } +#' Put the `ID` column of a restored fit back to a factor +#' +#' The fit table is written as a plain `.csv`, so `read.csv()` brings `ID` back +#' as an integer (or character) while a real fit carries a factor. Anything that +#' joins the fit table against something derived from the fit then hits a type +#' mismatch -- `nlme::augPred()` keeps `id` a factor, so `ggPMX::pmx_nlmixr()` +#' dies in a data.table join with "Incompatible join types: x.ID (factor) and +#' i.ID (integer)". +#' +#' Done here rather than in the restore script written by [saveFit()] so that +#' caches saved by earlier versions are repaired on load too. +#' +#' Levels come from `ranef`/`etaObf`, which the restore script has already put +#' back as factors with the fit's own levels; failing that, from the order the +#' IDs appear (the order nlmixr2est itself uses). +#' +#' @param fit restored object +#' @return `fit`, with `ID` a factor when it is a fit table that has one +#' @noRd +#' @author Matthew L. Fidler +.nlmixr2saveRestoreIdFactor <- function(fit) { + if (!inherits(fit, "nlmixr2FitData")) return(fit) + if (!is.data.frame(fit)) return(fit) + if (is.null(fit[["ID"]]) || is.factor(fit[["ID"]])) return(fit) + .env <- try(fit$env, silent=TRUE) + .levels <- NULL + if (is.environment(.env)) { + for (.n in c("ranef", "etaObf")) { + .df <- try(get(.n, envir=.env, inherits=FALSE), silent=TRUE) + if (is.data.frame(.df) && is.factor(.df$ID)) { + .levels <- levels(.df$ID) + break + } + } + } + if (is.null(.levels)) { + .levels <- unique(as.character(fit[["ID"]])) + } + ## `class<-` last: the class attribute of a fit carries the `.foceiEnv` + ## attribute that `$` dispatches through, and column assignment must not be + ## allowed to drop it. + .cls <- class(fit) + fit[["ID"]] <- factor(as.character(fit[["ID"]]), levels=.levels) + class(fit) <- .cls + fit +} + #' Load a fitted model object from a file #' #' @param file the base name of the files to load the fit from. @@ -734,6 +781,7 @@ loadFit <- function(file, checkVersion=.nlmixr2saveCheckVersion()) { .minfo(paste0("loading fit from ", .r)) source(.r, local=TRUE) ret <- get(file) + ret <- .nlmixr2saveRestoreIdFactor(ret) if (isTRUE(checkVersion)) { .nlmixr2saveWarnVersion(ret) } diff --git a/tests/testthat/test-save.R b/tests/testthat/test-save.R index 2e13e73..874d8e7 100644 --- a/tests/testthat/test-save.R +++ b/tests/testthat/test-save.R @@ -555,6 +555,19 @@ if (requireNamespace("nlmixr2est", quietly = TRUE) && fitEquals(fitF, fit2F) fitEquals(fitS, fit2S) + test_that("a restored fit keeps ID a factor", { + # the fit table round-trips through a plain .csv, so ID comes back as an + # integer unless it is put back. Anything joining the fit table to + # something derived from the fit then hits a type mismatch -- + # nlme::augPred() keeps `id` a factor, and ggPMX::pmx_nlmixr() dies in a + # data.table join on it. + expect_true(is.factor(fit2F$ID)) + expect_equal(levels(fit2F$ID), levels(fitF$ID)) + expect_equal(as.character(fit2F$ID), as.character(fitF$ID)) + expect_true(is.factor(fit2S$ID)) + expect_equal(levels(fit2S$ID), levels(fitS$ID)) + }) + test_that("saveFit(data=FALSE) omits the original data", { suppressMessages(saveFit(fitF, "fitFnd", data=FALSE)) expect_true(file.exists("fitFnd.zip")) From f34603d04242578a48e304386cd610aac51e6807 Mon Sep 17 00:00:00 2001 From: mattfidler Date: Thu, 6 Aug 2026 23:48:02 -0500 Subject: [PATCH 02/13] fix: record parHistData type levels for compressed fits nlmixr2est stores parHistData compressed unless control=list(compress=FALSE), so the fit environment holds a raw vector rather than a data frame. saveFit() read the type levels straight off that, found no data frame, and recorded nothing -- leaving loadFit() to fall back to its hardcoded level list. nlmixr2est has since added types that list predates ("Analytic Gradient (relaxed)" and friends), so those values came back as NA and the round-trip test for the SAEM IOV fit failed (the test-coverage job on main). Decompress with `fit$parHistData` before reading the levels, the same way the save loop already handles every other raw item. For caches saved before the levels were recorded, the loader now appends any unrecognized type to the fallback list rather than dropping it to NA. Co-Authored-By: Claude Opus 5 (1M context) --- NEWS.md | 10 ++++++++++ R/save.R | 11 ++++++++++- tests/testthat/test-save.R | 16 ++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index f75ac54..8f344b1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,16 @@ (integer)". The repair happens on load, so caches written by earlier versions are fixed too. +* `saveFit()` now records the `parHistData$type` factor levels for fits that + store `parHistData` compressed (the nlmixr2est default). It read the levels + straight out of the fit environment, where a compressed fit keeps a raw + vector rather than a data frame, so the levels were silently not recorded and + `loadFit()` fell back to a hardcoded level list. nlmixr2est has since added + types that list predates ("Analytic Gradient (relaxed)" and friends), and + those came back as `NA`. For caches saved before the levels were recorded, + `loadFit()` now appends any unrecognized type to the fallback list instead of + dropping it to `NA`. + * `nlmixrDataSimplify()` gained `est` and `control` arguments and no longer drops the covariate columns that `est="vae"` searches for. The VAE covariate search picks its covariates out of the data instead of out of the model, so diff --git a/R/save.R b/R/save.R index 0b4bc6c..c787a40 100644 --- a/R/save.R +++ b/R/save.R @@ -538,6 +538,10 @@ saveFit.nlmixr2FitCore <- function(fit, file, zip=TRUE, data=.nlmixr2saveData()) .parHistTypeLevel <- NULL if (exists("parHistData", envir=fit$env, inherits=FALSE)) { .phd <- get("parHistData", envir=fit$env) + if (is.raw(.phd)) { + # nlmixr2est stores parHistData compressed; `$` decompresses it + .phd <- fit$parHistData + } if (is.data.frame(.phd) && is.factor(.phd$type)) { .parHistTypeLevel <- levels(.phd$type) } @@ -648,7 +652,12 @@ saveFit.nlmixr2FitCore <- function(fit, file, zip=TRUE, data=.nlmixr2saveData()) # use the levels recorded from the fit; fall back to the # known level set for fits saved before they were recorded " .phLevels <- .parHistType.level\n", - " if (is.null(.phLevels)) .phLevels <- c(\"Gill83 Gradient\", \"Mixed Gradient\", \"Forward Difference\", \"Central Difference\", \"Scaled\", \"Unscaled\", \"Back-Transformed\", \"Forward Sensitivity\", \"Analytic Gradient\")\n", + " if (is.null(.phLevels)) {\n", + " .phLevels <- c(\"Gill83 Gradient\", \"Mixed Gradient\", \"Forward Difference\", \"Central Difference\", \"Scaled\", \"Unscaled\", \"Back-Transformed\", \"Forward Sensitivity\", \"Analytic Gradient\")\n", + # a fit saved before the levels were recorded can still use a + # type this list predates; append it rather than drop it to NA + " .phLevels <- c(.phLevels, setdiff(unique(as.character(env$parHistData$type)), .phLevels))\n", + " }\n", " env$parHistData$type <- factor(env$parHistData$type, levels=.phLevels)\n", " env$parHistData$iter <- as.integer(env$parHistData$iter)\n", "}\n", diff --git a/tests/testthat/test-save.R b/tests/testthat/test-save.R index 874d8e7..1aa59aa 100644 --- a/tests/testthat/test-save.R +++ b/tests/testthat/test-save.R @@ -631,6 +631,22 @@ if (requireNamespace("nlmixr2est", quietly = TRUE) && fit2IS <- loadFit("fitIS") fitEquals(fitIS, fit2IS) + test_that("a compressed fit still records its parHistData type levels", { + # nlmixr2est stores parHistData compressed (a raw vector in the env) + # unless compress=FALSE, so saveFit() has to decompress before it can + # read the type levels off it. Without that it fell through to the + # loader's hardcoded level list, which nlmixr2est has since outgrown + # ("Analytic Gradient (relaxed)" and friends), and those levels came + # back as NA. + expect_true(is.raw(get("parHistData", envir=fitIS$env))) + expect_equal(levels(fit2IS$parHistData$type), + levels(fitIS$parHistData$type)) + expect_false(anyNA(fit2IS$parHistData$type)) + expect_equal(levels(fit2IF$parHistData$type), + levels(fitIF$parHistData$type)) + expect_false(anyNA(fit2IF$parHistData$type)) + }) + one.cmt.nlm <- function() { ini({ tka <- 0.45 # Log Ka From 180d666a623bd87f3243f18ea03eab8c6a2349e6 Mon Sep 17 00:00:00 2001 From: mattfidler Date: Thu, 6 Aug 2026 23:59:54 -0500 Subject: [PATCH 03/13] fix: honor saveFit(zip=FALSE) for a fit table; cover the old-cache path Two things antigravity's review of PR #7 turned up. saveFit.nlmixr2FitData() wrote the fit .csv and then called the core method with a hardcoded zip=TRUE, so `zip=FALSE` was silently ignored for every fit that carries data -- which is the common case. Pass `zip` through. The PR claimed caches from earlier versions are repaired on load but only tested freshly written ones. Add a test that blanks `..id.level..` and `..parHistType.level..` out of the env script and injects a parHistData type the loader's fallback list predates, then asserts ID comes back a factor in order of appearance (not a character sort, which would put "10" before "2") and the unknown type is appended rather than dropped to NA. Also correct the NEWS claim about that fallback: it lives in the restore script inside the zip, so an existing cache only picks it up on re-save. Co-Authored-By: Claude Opus 5 (1M context) --- NEWS.md | 13 ++++++++++--- R/save.R | 2 +- tests/testthat/test-save.R | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8f344b1..8245908 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,9 +15,16 @@ vector rather than a data frame, so the levels were silently not recorded and `loadFit()` fell back to a hardcoded level list. nlmixr2est has since added types that list predates ("Analytic Gradient (relaxed)" and friends), and - those came back as `NA`. For caches saved before the levels were recorded, - `loadFit()` now appends any unrecognized type to the fallback list instead of - dropping it to `NA`. + those came back as `NA`. When the levels cannot be recorded at all, the + restore script now appends any unrecognized type to its hardcoded fallback + list rather than dropping it to `NA`. (Unlike the `ID` repair, this lives in + the restore script inside the zip, so an already-written cache picks it up + only once it is saved again.) + +* `saveFit(fit, zip=FALSE)` now actually leaves the fit unzipped for a fit table + (a `nlmixr2FitData`). The method wrote the fit `.csv` and then called the + core method with a hardcoded `zip=TRUE`, so the argument was silently ignored + for every fit that carries data. * `nlmixrDataSimplify()` gained `est` and `control` arguments and no longer drops the covariate columns that `est="vae"` searches for. The VAE covariate diff --git a/R/save.R b/R/save.R index c787a40..6a57abe 100644 --- a/R/save.R +++ b/R/save.R @@ -702,7 +702,7 @@ saveFit.nlmixr2FitData <- function(fit, file, zip=TRUE, data=.nlmixr2saveData()) file <- as.character(substitute(fit)) } utils::write.csv(fit, paste0(file, ".csv"), row.names=FALSE) - saveFit.nlmixr2FitCore(fit, file, zip=TRUE, data=data) + saveFit.nlmixr2FitCore(fit, file, zip=zip, data=data) } #' @rdname saveFit diff --git a/tests/testthat/test-save.R b/tests/testthat/test-save.R index 1aa59aa..5decc08 100644 --- a/tests/testthat/test-save.R +++ b/tests/testthat/test-save.R @@ -568,6 +568,42 @@ if (requireNamespace("nlmixr2est", quietly = TRUE) && expect_equal(levels(fit2S$ID), levels(fitS$ID)) }) + test_that("a cache saved before the levels were recorded still loads", { + # A cache written by an earlier nlmixr2save has no `..id.level..` and no + # `..parHistType.level..`. Simulate one by blanking both out of the + # env script (`env` is a plain environment when those lines run, so + # assigning NULL leaves exactly what a missing entry looks like to the + # restore script), and by injecting a parHistData type that postdates + # the loader's hardcoded fallback list. + suppressMessages(saveFit(fitS, "fitOld", zip=FALSE)) + # zip=FALSE has to be honored for a fit table too, not just for a core + expect_false(file.exists("fitOld.zip")) + expect_true(file.exists("fitOld-env.R")) + expect_true(file.exists("fitOld.csv")) + cat("env$`..id.level..` <- NULL\n", + "env$`..parHistType.level..` <- NULL\n", + file="fitOld-env.R", append=TRUE, sep="") + + .ph <- utils::read.csv("fitOld-parHistData.csv", check.names=FALSE) + .ph$type[1] <- "Future Gradient" + utils::write.csv(.ph, "fitOld-parHistData.csv", row.names=FALSE) + + .old <- suppressMessages(loadFit("fitOld", checkVersion=FALSE)) + + # ID is repaired from the order the IDs appear, not from a sort -- + # a character sort would put "10" before "2". + expect_true(is.factor(.old$ID)) + expect_equal(levels(.old$ID), unique(as.character(fitS$ID))) + expect_equal(as.character(.old$ID), as.character(fitS$ID)) + + # the unrecognized type is appended to the fallback list rather than + # dropped to NA + expect_true(is.factor(.old$parHistData$type)) + expect_false(anyNA(.old$parHistData$type)) + expect_true("Future Gradient" %in% levels(.old$parHistData$type)) + expect_equal(as.character(.old$parHistData$type[1]), "Future Gradient") + }) + test_that("saveFit(data=FALSE) omits the original data", { suppressMessages(saveFit(fitF, "fitFnd", data=FALSE)) expect_true(file.exists("fitFnd.zip")) From 555e7dee117077d59f4600a0ea68a4adeb1f3196 Mon Sep 17 00:00:00 2001 From: mattfidler Date: Fri, 7 Aug 2026 00:08:38 -0500 Subject: [PATCH 04/13] fix: repair parHistData$type levels a cache's own script dropped Second round of antigravity review on PR #7. The type levels are applied by the restore script stored *inside* the cache, so a cache written before nlmixr2est added a type ("Analytic Gradient (relaxed)" and friends) has no level for it and coerces it to NA on load. Re-saving cannot recover it -- by then the string is gone -- so the previous commit's NEWS claim that an old cache picks up the fix on re-save was wrong. Repair it in loadFit() instead, the same way the ID column is repaired: the -parHistData.csv still holds the original strings and has not been cleaned up at that point, so read the column back and append whatever levels the script was missing. Existing caches are fixed in place. Also add the test that distinguishes the two sources of ID levels: theo_sd's IDs appear in level order, so the round-trip test could not tell a ranef- derived level set from the appearance-order fallback. Reversing the recorded levels makes them disagree and pins down that ranef wins. Co-Authored-By: Claude Opus 5 (1M context) --- NEWS.md | 14 +++++++---- R/save.R | 49 ++++++++++++++++++++++++++++++++++++++ tests/testthat/test-save.R | 45 ++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8245908..485859d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,11 +15,15 @@ vector rather than a data frame, so the levels were silently not recorded and `loadFit()` fell back to a hardcoded level list. nlmixr2est has since added types that list predates ("Analytic Gradient (relaxed)" and friends), and - those came back as `NA`. When the levels cannot be recorded at all, the - restore script now appends any unrecognized type to its hardcoded fallback - list rather than dropping it to `NA`. (Unlike the `ID` repair, this lives in - the restore script inside the zip, so an already-written cache picks it up - only once it is saved again.) + those came back as `NA`. + +* `loadFit()` now repairs a `parHistData$type` that the cache's *own* restore + script dropped to `NA`. Those levels are applied by the script stored inside + the cache, so a cache written before nlmixr2est added a type has no level for + it and coerces it to `NA` -- and re-saving cannot recover it, because by then + the string is already gone. `loadFit()` reads the column back from the + `-parHistData.csv` in the cache and appends whatever the script was missing, + so existing caches are repaired in place. * `saveFit(fit, zip=FALSE)` now actually leaves the fit unzipped for a fit table (a `nlmixr2FitData`). The method wrote the fit `.csv` and then called the diff --git a/R/save.R b/R/save.R index 6a57abe..ac519c6 100644 --- a/R/save.R +++ b/R/save.R @@ -759,6 +759,53 @@ saveFit.default <- function(fit, file, zip=TRUE, data=.nlmixr2saveData()) { fit } +#' Repair `parHistData$type` levels a cache's own restore script dropped +#' +#' The factor levels for `parHistData$type` are applied by the restore script +#' stored *inside* the cache. A script written before a given nlmixr2est +#' version knows nothing of the types that version added ("Analytic Gradient +#' (relaxed)" and friends), so it coerces them to `NA` -- and re-saving cannot +#' recover them, because by then the strings are already gone. +#' +#' The `-parHistData.csv` still holds the original strings and has not been +#' cleaned up yet at this point in [loadFit()], so read the column back from +#' there and append whatever the script's level list was missing. +#' +#' @param fit restored object +#' @param file base name the fit was loaded from +#' @return `fit`, invisibly; `parHistData` is repaired in the fit environment +#' @noRd +#' @author Matthew L. Fidler +.nlmixr2saveRestoreParHistType <- function(fit, file) { + # a fit table dispatches `$env` through its class attribute; a data-less fit + # (`nlmixr2saveShare(noFit=TRUE)`) restores as the environment itself + .env <- if (is.environment(fit)) fit else try(fit$env, silent=TRUE) + if (!is.environment(.env)) return(invisible(fit)) + if (!exists("parHistData", envir=.env, inherits=FALSE)) return(invisible(fit)) + .phd <- try(get("parHistData", envir=.env, inherits=FALSE), silent=TRUE) + # only NA types are worth repairing; a cache whose script knew the levels is + # already correct + if (!is.data.frame(.phd) || !is.factor(.phd$type) || !anyNA(.phd$type)) { + return(invisible(fit)) + } + .csv <- paste0(file, "-parHistData.csv") + if (!file.exists(.csv)) return(invisible(fit)) + .raw <- try(utils::read.csv(.csv, check.names=FALSE), silent=TRUE) + if (!is.data.frame(.raw) || is.null(.raw$type) || nrow(.raw) != nrow(.phd)) { + return(invisible(fit)) + } + .type <- as.character(.raw$type) + .levels <- c(levels(.phd$type), setdiff(unique(.type[!is.na(.type)]), + levels(.phd$type))) + ## `class<-` last: for a saem fit the class attribute of parHistData carries + ## the `niter` attribute, which column assignment must not drop. + .cls <- class(.phd) + .phd$type <- factor(.type, levels=.levels) + class(.phd) <- .cls + assign("parHistData", .phd, envir=.env) + invisible(fit) +} + #' Load a fitted model object from a file #' #' @param file the base name of the files to load the fit from. @@ -791,6 +838,8 @@ loadFit <- function(file, checkVersion=.nlmixr2saveCheckVersion()) { source(.r, local=TRUE) ret <- get(file) ret <- .nlmixr2saveRestoreIdFactor(ret) + # must run before the unzipped files are removed below; it reads the csv + .nlmixr2saveRestoreParHistType(ret, file) if (isTRUE(checkVersion)) { .nlmixr2saveWarnVersion(ret) } diff --git a/tests/testthat/test-save.R b/tests/testthat/test-save.R index 5decc08..f5ab4cb 100644 --- a/tests/testthat/test-save.R +++ b/tests/testthat/test-save.R @@ -604,6 +604,51 @@ if (requireNamespace("nlmixr2est", quietly = TRUE) && expect_equal(as.character(.old$parHistData$type[1]), "Future Gradient") }) + test_that("restored ID levels come from ranef, not the row order", { + # theo_sd's IDs appear in level order, so the two candidate sources + # agree and the round-trip test above cannot tell them apart. Reverse + # the recorded levels so they disagree: the restore script hands them + # to ranef/etaObf, and the repair must follow ranef rather than fall + # back to the order the rows happen to appear in. + suppressMessages(saveFit(fitS, "fitRev", zip=FALSE)) + cat("env$`..id.level..` <- rev(env$`..id.level..`)\n", + file="fitRev-env.R", append=TRUE, sep="") + .rev <- suppressMessages(loadFit("fitRev", checkVersion=FALSE)) + + expect_true(is.factor(.rev$ID)) + expect_equal(levels(.rev$ID), rev(levels(fitS$ID))) + # the labels still line up with the rows; only the coding changed + expect_equal(as.character(.rev$ID), as.character(fitS$ID)) + # and this is genuinely not the appearance-order fallback + expect_false(identical(levels(.rev$ID), unique(as.character(.rev$ID)))) + }) + + test_that("a cache whose own script dropped a type is repaired on load", { + # The type levels are applied by the restore script stored inside the + # cache, so a cache written before nlmixr2est added a type has a script + # that coerces it to NA. Simulate that script by pinning it to a level + # list that omits the type, and injecting that type into the csv. + suppressMessages(saveFit(fitS, "fitDrop", zip=FALSE)) + .ph <- utils::read.csv("fitDrop-parHistData.csv", check.names=FALSE) + .ph$type[1] <- "Future Gradient" + utils::write.csv(.ph, "fitDrop-parHistData.csv", row.names=FALSE) + .lv <- levels(fitS$parHistData$type) + cat("env$`..parHistType.level..` <- ", deparse1(.lv), "\n", + file="fitDrop-env.R", append=TRUE, sep="") + + .drop <- suppressMessages(loadFit("fitDrop", checkVersion=FALSE)) + # loadFit() re-reads the csv, so the string survives even though the + # cache's own script had no level for it + expect_false(anyNA(.drop$parHistData$type)) + expect_true("Future Gradient" %in% levels(.drop$parHistData$type)) + expect_equal(as.character(.drop$parHistData$type[1]), "Future Gradient") + # the levels the script did know keep their original order + expect_equal(levels(.drop$parHistData$type)[seq_along(.lv)], .lv) + # saem's niter attribute on the class survives the column assignment + expect_equal(attr(class(.drop$parHistData), "niter"), + attr(class(fitS$parHistData), "niter")) + }) + test_that("saveFit(data=FALSE) omits the original data", { suppressMessages(saveFit(fitF, "fitFnd", data=FALSE)) expect_true(file.exists("fitFnd.zip")) From 7ff0355eb3b343fae64a283131753348169f8c5f Mon Sep 17 00:00:00 2001 From: mattfidler Date: Fri, 7 Aug 2026 00:22:20 -0500 Subject: [PATCH 05/13] fix: anchor the fit file pattern so caches cannot clobber each other Third round of antigravity review on PR #7, adversarial pass. The list of files belonging to a fit was matched with an unanchored pattern, so a cache named "fit" also matched "myfit-env.R": saveFit() zipped the other cache's files into its own archive and then unlinked them, and loadFit() deleted them on cleanup. Previously this needed unzipped files to be lying around; the preceding commit made saveFit(zip=FALSE) actually leave them, so anchor the pattern. Folded the three copies into one helper. Two smaller hardening fixes from the same pass: - .nlmixr2saveRestoreParHistType() read the csv with inferred column types, so a level like "01" would come back as 1 and "T" as TRUE. Read as character. - .nlmixr2saveRestoreIdFactor() applied the ranef levels directly. ranef should cover every subject in the fit table, but union the two rather than let a missing one turn into NA while fixing the column's type. Co-Authored-By: Claude Opus 5 (1M context) --- NEWS.md | 7 ++++++ R/save.R | 44 +++++++++++++++++++++++++++----------- tests/testthat/test-save.R | 21 ++++++++++++++++++ 3 files changed, 60 insertions(+), 12 deletions(-) diff --git a/NEWS.md b/NEWS.md index 485859d..01a68ec 100644 --- a/NEWS.md +++ b/NEWS.md @@ -25,6 +25,13 @@ `-parHistData.csv` in the cache and appends whatever the script was missing, so existing caches are repaired in place. +* Saving or loading a fit no longer disturbs another cache whose base name it + is a suffix of. The list of files belonging to a fit was matched with an + unanchored pattern, so a cache named `fit` also matched `myfit-env.R` -- + zipping another cache's files into its own archive and then deleting them + from disk. This is reachable whenever unzipped files are lying around, which + `saveFit(zip=FALSE)` leaves by design. + * `saveFit(fit, zip=FALSE)` now actually leaves the fit unzipped for a fit table (a `nlmixr2FitData`). The method wrote the fit `.csv` and then called the core method with a hardcoded `zip=TRUE`, so the argument was silently ignored diff --git a/R/save.R b/R/save.R index ac519c6..b4ffff0 100644 --- a/R/save.R +++ b/R/save.R @@ -8,6 +8,24 @@ .saveFitEnv$fun <- "" .saveFitEnv$restore <- FALSE +#' The unzipped files belonging to one saved fit +#' +#' Anchored at the start of the base name: unanchored, a cache named `fit` +#' also matches `myfit-env.R`, and the caller then zips another cache's files +#' into this one and unlinks them. That is reachable whenever unzipped files +#' are left lying around, which `saveFit(zip=FALSE)` does by design. +#' +#' @param file base name of the fit, possibly with a directory +#' @return the matching paths, relative to the working directory +#' @noRd +#' @author Matthew L. Fidler +.nlmixr2saveFitFiles <- function(file) { + .files <- list.files(dirname(file), + pattern=paste0("^", basename(file), "(-|[.]csv$|[.]R$)"), + full.names=TRUE) + gsub("^[.]/", "", .files) +} + .minfo <- function (text, ..., .envir = parent.frame()) { .opt <- getOption("nlmixr2save.quiet", FALSE) if (checkmate::testLogical(.opt, @@ -556,9 +574,7 @@ saveFit.nlmixr2FitCore <- function(fit, file, zip=TRUE, data=.nlmixr2saveData()) .str <- .str[.str != "NULL = NULL"] .str <- paste0("env <- list(", paste(.str, collapse=",\n"), ")\nenv <- list2env(env)\n") writeLines(.str, con = paste0(file,"-env.R")) - .files <- c(list.files(dirname(file), pattern=paste0(basename(file), "(-|[.]csv$|[.]R$)"), - full.names=TRUE)) - .files <- gsub("^[.]/", "", .files) + .files <- .nlmixr2saveFitFiles(file) # nlmixr2est <= 6.0 stores parFixedDf with named "Estimate"/"SE" columns; # the $parFixed refactor (nlmixr2est#645) stores them unnamed. Record # which structure this fit uses so the restore script rebuilds it exactly. @@ -684,9 +700,7 @@ saveFit.nlmixr2FitCore <- function(fit, file, zip=TRUE, data=.nlmixr2saveData()) con = paste0(file,".R")) if (isTRUE(zip)) { .minfo("zipping fit files") - .files <- c(list.files(dirname(file), pattern=paste0(basename(file), "(-|[.]csv$|[.]R$)"), - full.names=TRUE)) - .files <- gsub("^[.]/", "", .files) + .files <- .nlmixr2saveFitFiles(file) zip::zip(zipfile = paste0(file, ".zip"), files = .files) .minfo("removing unzipped fit files") @@ -747,14 +761,19 @@ saveFit.default <- function(fit, file, zip=TRUE, data=.nlmixr2saveData()) { } } } + .id <- as.character(fit[["ID"]]) if (is.null(.levels)) { - .levels <- unique(as.character(fit[["ID"]])) + .levels <- unique(.id) + } else { + # ranef should cover every subject in the table, but never turn an ID the + # table does have into NA on the way to fixing its type + .levels <- c(.levels, setdiff(unique(.id), .levels)) } ## `class<-` last: the class attribute of a fit carries the `.foceiEnv` ## attribute that `$` dispatches through, and column assignment must not be ## allowed to drop it. .cls <- class(fit) - fit[["ID"]] <- factor(as.character(fit[["ID"]]), levels=.levels) + fit[["ID"]] <- factor(.id, levels=.levels) class(fit) <- .cls fit } @@ -790,7 +809,10 @@ saveFit.default <- function(fit, file, zip=TRUE, data=.nlmixr2saveData()) { } .csv <- paste0(file, "-parHistData.csv") if (!file.exists(.csv)) return(invisible(fit)) - .raw <- try(utils::read.csv(.csv, check.names=FALSE), silent=TRUE) + # colClasses="character": type is a level name, and letting read.csv infer + # would turn a level like "01" into 1 or "T" into TRUE on the way back + .raw <- try(utils::read.csv(.csv, check.names=FALSE, colClasses="character"), + silent=TRUE) if (!is.data.frame(.raw) || is.null(.raw$type) || nrow(.raw) != nrow(.phd)) { return(invisible(fit)) } @@ -844,9 +866,7 @@ loadFit <- function(file, checkVersion=.nlmixr2saveCheckVersion()) { .nlmixr2saveWarnVersion(ret) } if (.didUnzip) { - .files <- list.files(dirname(file), pattern=paste0(basename(file), "(-|[.]csv$|[.]R$)"), - full.names=TRUE) - .files <- gsub("^[.]/", "", .files) + .files <- .nlmixr2saveFitFiles(file) .minfo("removing unzipped fit files") lapply(.files, unlink) } diff --git a/tests/testthat/test-save.R b/tests/testthat/test-save.R index f5ab4cb..14462b0 100644 --- a/tests/testthat/test-save.R +++ b/tests/testthat/test-save.R @@ -604,6 +604,27 @@ if (requireNamespace("nlmixr2est", quietly = TRUE) && expect_equal(as.character(.old$parHistData$type[1]), "Future Gradient") }) + test_that("saving one fit leaves another cache's files alone", { + # the file list was matched with an unanchored pattern, so a cache + # named "fit" also picked up "myfit-env.R" -- zipping another cache's + # files into its own archive and then unlinking them. Reachable + # whenever unzipped files are lying around, which zip=FALSE leaves by + # design. + suppressMessages(saveFit(fitS, "myClobber", zip=FALSE)) + .before <- sort(list.files(pattern="^myClobber")) + expect_true(length(.before) > 1) + + suppressMessages(saveFit(fitS, "Clobber")) + expect_true(file.exists("Clobber.zip")) + # the other cache is untouched, and was not swept into the new zip + expect_equal(sort(list.files(pattern="^myClobber")), .before) + expect_false(any(grepl("^myClobber", zip::zip_list("Clobber.zip")$filename))) + + # and loading does not delete it either + expect_error(suppressMessages(loadFit("Clobber", checkVersion=FALSE)), NA) + expect_equal(sort(list.files(pattern="^myClobber")), .before) + }) + test_that("restored ID levels come from ranef, not the row order", { # theo_sd's IDs appear in level order, so the two candidate sources # agree and the round-trip test above cannot tell them apart. Reverse From 3a2cb324ba0f1390efb6d723666ad1295c06fff4 Mon Sep 17 00:00:00 2001 From: mattfidler Date: Fri, 7 Aug 2026 00:32:53 -0500 Subject: [PATCH 06/13] fix: match a fit's files literally, and stop a test masking its own fix Fourth round of antigravity review on PR #7. Anchoring the file pattern last commit left the base name interpolated into a regexp unescaped. A base name is a variable name or a nlmixr2save.prefix, so it can hold metacharacters: `my.fit` is an ordinary R name, and as a pattern its `.` also matches `my_fit`'s files -- which the caller then zips and unlinks. `fit+1` fails the other way, matching nothing, leaving a cache that cannot be loaded. Match the names literally with startsWith() instead. The old-cache test asserted the restore script appends an unrecognized type, but loadFit() repairs an NA type from the csv right afterwards, so the test passed whether or not the script did its job. Source the restore script directly to pin down the script's own behavior, then check loadFit() as well. Co-Authored-By: Claude Opus 5 (1M context) --- NEWS.md | 5 ++++- R/save.R | 23 +++++++++++++++-------- test.csv | 3 +++ tests/testthat/test-save.R | 15 ++++++++++++--- 4 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 test.csv diff --git a/NEWS.md b/NEWS.md index 01a68ec..937b255 100644 --- a/NEWS.md +++ b/NEWS.md @@ -30,7 +30,10 @@ unanchored pattern, so a cache named `fit` also matched `myfit-env.R` -- zipping another cache's files into its own archive and then deleting them from disk. This is reachable whenever unzipped files are lying around, which - `saveFit(zip=FALSE)` leaves by design. + `saveFit(zip=FALSE)` leaves by design. The names are now matched literally + rather than as a regexp, so a base name holding a metacharacter (`my.fit` is + an ordinary R name, and as a pattern its `.` also matched `my_fit`) is + matched exactly. * `saveFit(fit, zip=FALSE)` now actually leaves the fit unzipped for a fit table (a `nlmixr2FitData`). The method wrote the fit `.csv` and then called the diff --git a/R/save.R b/R/save.R index b4ffff0..b6995d6 100644 --- a/R/save.R +++ b/R/save.R @@ -10,20 +10,27 @@ #' The unzipped files belonging to one saved fit #' -#' Anchored at the start of the base name: unanchored, a cache named `fit` -#' also matches `myfit-env.R`, and the caller then zips another cache's files -#' into this one and unlinks them. That is reachable whenever unzipped files -#' are left lying around, which `saveFit(zip=FALSE)` does by design. +#' That is `-*` plus `.csv` and `.R`. +#' +#' Matched literally rather than by regexp. A base name is a variable name or +#' a `nlmixr2save.prefix`, so it can hold regexp metacharacters -- `my.fit` is +#' an ordinary R name, and as a pattern its `.` also matches `my_fit`'s files. +#' The caller zips what it gets back and then unlinks it, so matching one +#' character too many silently destroys another cache; matching one too few +#' leaves a cache that cannot be loaded. #' #' @param file base name of the fit, possibly with a directory #' @return the matching paths, relative to the working directory #' @noRd #' @author Matthew L. Fidler .nlmixr2saveFitFiles <- function(file) { - .files <- list.files(dirname(file), - pattern=paste0("^", basename(file), "(-|[.]csv$|[.]R$)"), - full.names=TRUE) - gsub("^[.]/", "", .files) + .base <- basename(file) + .all <- list.files(dirname(file)) + .keep <- startsWith(.all, .base) & + (substring(.all, nchar(.base) + 1L, nchar(.base) + 1L) == "-" | + .all == paste0(.base, ".csv") | + .all == paste0(.base, ".R")) + gsub("^[.]/", "", file.path(dirname(file), .all[.keep])) } .minfo <- function (text, ..., .envir = parent.frame()) { diff --git a/test.csv b/test.csv new file mode 100644 index 0000000..5513e4b --- /dev/null +++ b/test.csv @@ -0,0 +1,3 @@ +"a","type" +1,"A" + diff --git a/tests/testthat/test-save.R b/tests/testthat/test-save.R index 14462b0..27be042 100644 --- a/tests/testthat/test-save.R +++ b/tests/testthat/test-save.R @@ -597,10 +597,19 @@ if (requireNamespace("nlmixr2est", quietly = TRUE) && expect_equal(as.character(.old$ID), as.character(fitS$ID)) # the unrecognized type is appended to the fallback list rather than - # dropped to NA - expect_true(is.factor(.old$parHistData$type)) + # dropped to NA. Source the restore script directly rather than going + # through loadFit(): loadFit() also repairs an NA type from the csv, + # which would mask a broken script. + .se <- new.env() + source("fitOld.R", local=.se) + .script <- get("fitOld", envir=.se) + expect_true(is.factor(.script$parHistData$type)) + expect_false(anyNA(.script$parHistData$type)) + expect_true("Future Gradient" %in% levels(.script$parHistData$type)) + expect_equal(as.character(.script$parHistData$type[1]), "Future Gradient") + + # and the same holds through loadFit() expect_false(anyNA(.old$parHistData$type)) - expect_true("Future Gradient" %in% levels(.old$parHistData$type)) expect_equal(as.character(.old$parHistData$type[1]), "Future Gradient") }) From 2ba5d54b2b23115f71396f42c97e0ccf72f8451d Mon Sep 17 00:00:00 2001 From: mattfidler Date: Fri, 7 Aug 2026 00:47:52 -0500 Subject: [PATCH 07/13] fix: find a fit's files when its name starts with a dot Fifth round of antigravity review on PR #7. `.fit` is an ordinary R name and saveFit() takes the base name from the variable, but list.files() omits dot files unless asked, so saveFit(.fit) zipped nothing and loadFit() cleaned up nothing. This predates the PR -- the regexp the helper replaced had the same hole -- but the helper is where it belongs. Pass all.files=TRUE and drop "." / "..". Also normalize dirname("") to ".": file.path("", x) is rooted at the filesystem, so a base name with no directory part and no name would have pointed the zip and the unlink at /. Adds a fit-free unit test for the helper covering the boundaries that matter: a longer name starting the same way, the .zip itself, a metacharacter in the name, a dot name, and a nested directory. Co-Authored-By: Claude Opus 5 (1M context) --- R/save.R | 10 ++++++++-- tests/testthat/test-save.R | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/R/save.R b/R/save.R index b6995d6..d319161 100644 --- a/R/save.R +++ b/R/save.R @@ -25,12 +25,18 @@ #' @author Matthew L. Fidler .nlmixr2saveFitFiles <- function(file) { .base <- basename(file) - .all <- list.files(dirname(file)) + .dir <- dirname(file) + # dirname("fit") is "." but dirname("") is "", and file.path("", x) would + # make that an absolute path at the filesystem root + if (.dir == "") .dir <- "." + # all.files: a base name can start with a dot, since `.fit` is an ordinary + # R name and saveFit() takes the base name from the variable + .all <- setdiff(list.files(.dir, all.files=TRUE), c(".", "..")) .keep <- startsWith(.all, .base) & (substring(.all, nchar(.base) + 1L, nchar(.base) + 1L) == "-" | .all == paste0(.base, ".csv") | .all == paste0(.base, ".R")) - gsub("^[.]/", "", file.path(dirname(file), .all[.keep])) + gsub("^[.]/", "", file.path(.dir, .all[.keep])) } .minfo <- function (text, ..., .envir = parent.frame()) { diff --git a/tests/testthat/test-save.R b/tests/testthat/test-save.R index 27be042..89b4ec4 100644 --- a/tests/testthat/test-save.R +++ b/tests/testthat/test-save.R @@ -12,6 +12,38 @@ test_that(".assignParent errors on non-environment", { expect_error(.assignParent(1), "env must be an environment") }) +test_that(".nlmixr2saveFitFiles matches one fit's files and no others", { + # what comes back is zipped and then unlinked, so matching one file too many + # destroys another cache and one too few leaves an unloadable one + withr::with_tempdir({ + file.create(c("fit-env.R", "fit-ui.R", "fit.csv", "fit.R", "fit.zip", + "myfit-env.R", "myfit.csv", "fitExtra-env.R", "fit2.csv", + "my.fit-env.R", "my.fit.csv", "my_fit-env.R", "my_fit.csv", + "fit+1-env.R", ".dot-env.R", ".dot.csv")) + + expect_equal(sort(.nlmixr2saveFitFiles("fit")), + c("fit-env.R", "fit-ui.R", "fit.R", "fit.csv")) + # not the .zip, and not a longer name that merely starts the same way + expect_false(any(c("fit.zip", "fit2.csv", "fitExtra-env.R", "myfit.csv") %in% + .nlmixr2saveFitFiles("fit"))) + # a base name is a variable name, so it can hold regexp metacharacters: + # as a pattern, "my.fit" would also match my_fit's files + expect_equal(sort(.nlmixr2saveFitFiles("my.fit")), + c("my.fit-env.R", "my.fit.csv")) + expect_equal(sort(.nlmixr2saveFitFiles("my_fit")), + c("my_fit-env.R", "my_fit.csv")) + expect_equal(.nlmixr2saveFitFiles("fit+1"), "fit+1-env.R") + # `.dot` is an ordinary R name, and its files are hidden + expect_equal(sort(.nlmixr2saveFitFiles(".dot")), c(".dot-env.R", ".dot.csv")) + expect_equal(length(.nlmixr2saveFitFiles("nosuch")), 0) + + dir.create("sub") + file.create(c("sub/a-env.R", "sub/a.csv", "sub/ab.csv")) + expect_equal(sort(.nlmixr2saveFitFiles(file.path("sub", "a"))), + c("sub/a-env.R", "sub/a.csv")) + }) +}) + test_that("saveFitRandom adds and removes registered random functions", { .old <- saveFitRandom() on.exit(saveFitRandom(.old), add = TRUE) From d9cea4d5441f6355e9115ab304c485ec56e9e494 Mon Sep 17 00:00:00 2001 From: mattfidler Date: Fri, 7 Aug 2026 02:27:02 -0500 Subject: [PATCH 08/13] ci: make a killed coverage job leave evidence behind The test-coverage job has died twice at ~21-25 min with exit 143 and no test output at all. The runner is torn down rather than the step failing, so none of the always() diagnostic steps run and the partial testthat.Rout is never uploaded -- there is nothing to diagnose from. This does not reproduce locally: covr::package_coverage() finishes in 4-6 min and passes under a warm cache, a cold cache, 4 CPUs, and CI's exact invocation including install_path. So the evidence has to come from CI. Give the step a 20 minute timeout so it fails on its own terms and leaves the always() steps to run, and add a step that reports memory, disk, cpu and any kernel OOM messages. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/test-coverage.yaml | 17 + ....6#Rcpp#include#Rcpp#InputParameter.h.gcov | 119 + ...library#4.6#Rcpp#include#Rcpp#Named.h.gcov | 88 + ...rary#4.6#Rcpp#include#Rcpp#RNGScope.h.gcov | 45 + ...brary#4.6#Rcpp#include#Rcpp#RObject.h.gcov | 66 + ...cpp#include#Rcpp#api#meat#Rcpp_eval.h.gcov | 96 + ....6#Rcpp#include#Rcpp#api#meat#proxy.h.gcov | 209 + ...nu-library#4.6#Rcpp#include#Rcpp#as.h.gcov | 171 + ...ry#4.6#Rcpp#include#Rcpp#exceptions.h.gcov | 487 ++ ...6#Rcpp#include#Rcpp#exceptions_impl.h.gcov | 106 + ...nclude#Rcpp#internal#Proxy_Iterator.h.gcov | 153 + ...6#Rcpp#include#Rcpp#internal#caster.h.gcov | 71 + ...Rcpp#include#Rcpp#internal#r_vector.h.gcov | 158 + ...4.6#Rcpp#include#Rcpp#internal#wrap.h.gcov | 1032 +++ ...Rcpp#include#Rcpp#internal#wrap_end.h.gcov | 48 + ...pp#include#Rcpp#iostream#Rstreambuf.h.gcov | 112 + ...cpp#include#Rcpp#protection#Shelter.h.gcov | 51 + ...Rcpp#include#Rcpp#protection#Shield.h.gcov | 58 + ...p#include#Rcpp#proxy#AttributeProxy.h.gcov | 112 + ...ibrary#4.6#Rcpp#include#Rcpp#r_cast.h.gcov | 181 + ...rary#4.6#Rcpp#include#Rcpp#routines.h.gcov | 319 + ...nclude#Rcpp#storage#PreserveStorage.h.gcov | 181 + ...pp#include#Rcpp#traits#named_object.h.gcov | 98 + ...4.6#Rcpp#include#Rcpp#unwindProtect.h.gcov | 83 + ...de#Rcpp#utils#tinyformat#tinyformat.h.gcov | 1238 ++++ ...4.6#Rcpp#include#Rcpp#vector#Vector.h.gcov | 1349 ++++ ...#Rcpp#include#Rcpp#vector#converter.h.gcov | 124 + ...p#include#Rcpp#vector#generic_proxy.h.gcov | 109 + ...pp#include#Rcpp#vector#string_proxy.h.gcov | 270 + ...4.6#Rcpp#include#Rcpp#vector#traits.h.gcov | 161 + ...library#4.6#Rcpp#include#RcppCommon.h.gcov | 196 + ...sr#include#c++#14#bits#alloc_traits.h.gcov | 955 +++ .../#usr#include#c++#14#bits#allocator.h.gcov | 299 + ...sr#include#c++#14#bits#basic_string.h.gcov | 4750 +++++++++++++ ...#include#c++#14#bits#basic_string.tcc.gcov | 1107 ++++ ...usr#include#c++#14#bits#char_traits.h.gcov | 1021 +++ ...include#c++#14#bits#cpp_type_traits.h.gcov | 618 ++ .../#usr#include#c++#14#bits#exception.h.gcov | 87 + .../#usr#include#c++#14#bits#ios_base.h.gcov | 1146 ++++ .../#usr#include#c++#14#bits#move.h.gcov | 283 + ...r#include#c++#14#bits#new_allocator.h.gcov | 254 + ...#usr#include#c++#14#bits#ptr_traits.h.gcov | 266 + .../#usr#include#c++#14#bits#stl_algo.h.gcov | 5858 +++++++++++++++++ ...sr#include#c++#14#bits#stl_algobase.h.gcov | 2388 +++++++ ...r#include#c++#14#bits#stl_construct.h.gcov | 271 + ...sr#include#c++#14#bits#stl_iterator.h.gcov | 3045 +++++++++ ...c++#14#bits#stl_iterator_base_funcs.h.gcov | 263 + ...c++#14#bits#stl_iterator_base_types.h.gcov | 276 + ...clude#c++#14#bits#stl_uninitialized.h.gcov | 1162 ++++ ...#usr#include#c++#14#bits#stl_vector.h.gcov | 2149 ++++++ .../#usr#include#c++#14#bits#vector.tcc.gcov | 1266 ++++ .../#usr#include#c++#14#new.gcov | 242 + .../#usr#include#c++#14#typeinfo.gcov | 258 + ..._64-linux-gnu#c++#14#bits#c++config.h.gcov | 1842 ++++++ covr/RcppExports.gcno/RcppExports.cpp.gcov | 38 + ...library#4.6#Rcpp#include#Rcpp#Named.h.gcov | 72 + ...cpp#include#Rcpp#api#meat#Rcpp_eval.h.gcov | 96 + ...pp#include#Rcpp#api#meat#protection.h.gcov | 42 + ....6#Rcpp#include#Rcpp#api#meat#proxy.h.gcov | 209 + ...nu-library#4.6#Rcpp#include#Rcpp#as.h.gcov | 188 + ...ry#4.6#Rcpp#include#Rcpp#exceptions.h.gcov | 454 ++ ...6#Rcpp#include#Rcpp#exceptions_impl.h.gcov | 106 + ...Rcpp#include#Rcpp#internal#Exporter.h.gcov | 134 + ...nclude#Rcpp#internal#Proxy_Iterator.h.gcov | 126 + ...Rcpp#include#Rcpp#internal#r_vector.h.gcov | 158 + ...4.6#Rcpp#include#Rcpp#internal#wrap.h.gcov | 1058 +++ ...Rcpp#include#Rcpp#internal#wrap_end.h.gcov | 48 + ...pp#include#Rcpp#iostream#Rstreambuf.h.gcov | 112 + ...#Rcpp#include#Rcpp#protection#Armor.h.gcov | 62 + ...Rcpp#include#Rcpp#protection#Shield.h.gcov | 58 + ...p#include#Rcpp#proxy#AttributeProxy.h.gcov | 112 + ...ibrary#4.6#Rcpp#include#Rcpp#r_cast.h.gcov | 181 + ...rary#4.6#Rcpp#include#Rcpp#routines.h.gcov | 319 + ...nclude#Rcpp#storage#PreserveStorage.h.gcov | 172 + ...4.6#Rcpp#include#Rcpp#unwindProtect.h.gcov | 83 + ...de#Rcpp#utils#tinyformat#tinyformat.h.gcov | 1400 ++++ ...4.6#Rcpp#include#Rcpp#vector#Vector.h.gcov | 1289 ++++ ...#Rcpp#include#Rcpp#vector#converter.h.gcov | 113 + ...p#include#Rcpp#vector#generic_proxy.h.gcov | 109 + ...#4.6#Rcpp#include#Rcpp#vector#proxy.h.gcov | 280 + ...4.6#Rcpp#include#Rcpp#vector#traits.h.gcov | 129 + ...library#4.6#Rcpp#include#RcppCommon.h.gcov | 196 + ...sr#include#c++#14#bits#alloc_traits.h.gcov | 955 +++ .../#usr#include#c++#14#bits#allocator.h.gcov | 299 + ...sr#include#c++#14#bits#basic_string.h.gcov | 4750 +++++++++++++ ...#include#c++#14#bits#basic_string.tcc.gcov | 1107 ++++ ...usr#include#c++#14#bits#char_traits.h.gcov | 1021 +++ .../#usr#include#c++#14#bits#exception.h.gcov | 87 + .../#usr#include#c++#14#bits#ios_base.h.gcov | 1146 ++++ .../#usr#include#c++#14#bits#move.h.gcov | 295 + ...r#include#c++#14#bits#new_allocator.h.gcov | 254 + ...#usr#include#c++#14#bits#ptr_traits.h.gcov | 266 + .../#usr#include#c++#14#bits#stl_algo.h.gcov | 5858 +++++++++++++++++ ...sr#include#c++#14#bits#stl_algobase.h.gcov | 2377 +++++++ ...r#include#c++#14#bits#stl_construct.h.gcov | 271 + ...sr#include#c++#14#bits#stl_iterator.h.gcov | 3027 +++++++++ ...c++#14#bits#stl_iterator_base_funcs.h.gcov | 263 + ...c++#14#bits#stl_iterator_base_types.h.gcov | 276 + ...clude#c++#14#bits#stl_uninitialized.h.gcov | 1162 ++++ ...#usr#include#c++#14#bits#stl_vector.h.gcov | 2149 ++++++ .../#usr#include#c++#14#bits#vector.tcc.gcov | 1266 ++++ .../#usr#include#c++#14#new.gcov | 242 + ..._64-linux-gnu#c++#14#bits#c++config.h.gcov | 1842 ++++++ covr/nlmixr2fix.gcno/nlmixr2fix.cpp.gcov | 64 + src/RcppExports.gcda | Bin 0 -> 12104 bytes src/RcppExports.gcno | Bin 0 -> 333317 bytes src/nlmixr2fix.gcda | Bin 0 -> 11988 bytes src/nlmixr2fix.gcno | Bin 0 -> 300848 bytes 108 files changed, 73635 insertions(+) create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#InputParameter.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#Named.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#RNGScope.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#RObject.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#Rcpp_eval.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#proxy.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#as.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#exceptions.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#exceptions_impl.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#Proxy_Iterator.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#caster.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#r_vector.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#wrap.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#wrap_end.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#iostream#Rstreambuf.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#protection#Shelter.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#protection#Shield.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#proxy#AttributeProxy.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#r_cast.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#routines.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#storage#PreserveStorage.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#traits#named_object.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#unwindProtect.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#utils#tinyformat#tinyformat.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#Vector.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#converter.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#generic_proxy.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#string_proxy.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#traits.h.gcov create mode 100644 covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#RcppCommon.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#alloc_traits.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#allocator.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#basic_string.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#basic_string.tcc.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#char_traits.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#cpp_type_traits.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#exception.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#ios_base.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#move.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#new_allocator.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#ptr_traits.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#stl_algo.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#stl_algobase.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#stl_construct.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#stl_iterator.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#stl_iterator_base_funcs.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#stl_iterator_base_types.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#stl_uninitialized.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#stl_vector.h.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#bits#vector.tcc.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#new.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#c++#14#typeinfo.gcov create mode 100644 covr/RcppExports.gcno/#usr#include#x86_64-linux-gnu#c++#14#bits#c++config.h.gcov create mode 100644 covr/RcppExports.gcno/RcppExports.cpp.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#Named.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#Rcpp_eval.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#protection.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#proxy.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#as.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#exceptions.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#exceptions_impl.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#Exporter.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#Proxy_Iterator.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#r_vector.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#wrap.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#wrap_end.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#iostream#Rstreambuf.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#protection#Armor.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#protection#Shield.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#proxy#AttributeProxy.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#r_cast.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#routines.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#storage#PreserveStorage.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#unwindProtect.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#utils#tinyformat#tinyformat.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#Vector.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#converter.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#generic_proxy.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#proxy.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#traits.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#RcppCommon.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#alloc_traits.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#allocator.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#basic_string.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#basic_string.tcc.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#char_traits.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#exception.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#ios_base.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#move.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#new_allocator.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#ptr_traits.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#stl_algo.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#stl_algobase.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#stl_construct.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#stl_iterator.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#stl_iterator_base_funcs.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#stl_iterator_base_types.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#stl_uninitialized.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#stl_vector.h.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#bits#vector.tcc.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#c++#14#new.gcov create mode 100644 covr/nlmixr2fix.gcno/#usr#include#x86_64-linux-gnu#c++#14#bits#c++config.h.gcov create mode 100644 covr/nlmixr2fix.gcno/nlmixr2fix.cpp.gcov create mode 100644 src/RcppExports.gcda create mode 100644 src/RcppExports.gcno create mode 100644 src/nlmixr2fix.gcda create mode 100644 src/nlmixr2fix.gcno diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 717ed10..1e30954 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -35,6 +35,11 @@ jobs: needs: coverage - name: Test coverage + # Without this the job has died at ~21-25 min with exit 143 and no + # output at all: the runner is torn down, so none of the `always()` + # diagnostic steps below ever run and there is nothing to look at. A + # step-level timeout fails just this step, which leaves them to run. + timeout-minutes: 20 run: | cov <- covr::package_coverage( quiet = FALSE, @@ -45,6 +50,18 @@ jobs: covr::to_cobertura(cov) shell: Rscript {0} + - name: Runner resources + if: always() + run: | + ## -------------------------------------------------------------------- + echo "::group::memory"; free -m || true; echo "::endgroup::" + echo "::group::disk"; df -h || true; echo "::endgroup::" + echo "::group::cpu"; nproc || true; echo "::endgroup::" + echo "::group::kernel oom/kill messages" + dmesg 2>/dev/null | tail -40 || echo "dmesg unavailable" + echo "::endgroup::" + shell: bash + - uses: codecov/codecov-action@v5 with: # Fail if error if not on PR, or if on PR and token is given diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#InputParameter.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#InputParameter.h.gcov new file mode 100644 index 0000000..9c9a6e4 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#InputParameter.h.gcov @@ -0,0 +1,119 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/InputParameter.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- + -: 2:// + -: 3:// InputParameter.h: Rcpp R/C++ interface class library -- + -: 4:// + -: 5:// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21: + -: 22:#ifndef Rcpp__InputParameter__h + -: 23:#define Rcpp__InputParameter__h + -: 24: + -: 25:namespace Rcpp { + -: 26: + -: 27: // default implementation used for pass by value and modules objects + -: 28: // as<> is called on the conversion operator + -: 29: template + -: 30: class InputParameter { + -: 31: public: + 270: 32: InputParameter(SEXP x_) : x(x_){} +------------------ +_ZN4Rcpp14InputParameterIbEC2EP7SEXPREC: + 135: 32: InputParameter(SEXP x_) : x(x_){} +------------------ +_ZN4Rcpp14InputParameterIP7SEXPRECEC2ES2_: + 135: 32: InputParameter(SEXP x_) : x(x_){} +------------------ + -: 33: + 270: 34: inline operator T() { return as(x) ; } +------------------ +_ZN4Rcpp14InputParameterIbEcvbEv: + 135: 34: inline operator T() { return as(x) ; } +------------------ +_ZN4Rcpp14InputParameterIP7SEXPRECEcvS2_Ev: + 135: 34: inline operator T() { return as(x) ; } +------------------ + -: 35: + -: 36: private: + -: 37: SEXP x ; + -: 38: } ; + -: 39: + -: 40: // impl for references. It holds an object at the constructor and then + -: 41: // returns a reference in the reference operator + -: 42: template + -: 43: class ReferenceInputParameter { + -: 44: public: + -: 45: typedef T& reference ; + -: 46: ReferenceInputParameter(SEXP x_) : obj( as(x_) ){} + -: 47: + -: 48: inline operator reference() { return obj ; } + -: 49: + -: 50: private: + -: 51: T obj ; + -: 52: } ; + -: 53: + -: 54: // same for const + -: 55: template + -: 56: class ConstInputParameter { + -: 57: public: + -: 58: typedef const T const_nonref ; + -: 59: ConstInputParameter(SEXP x_) : obj( as(x_) ){} + -: 60: + -: 61: inline operator const_nonref() { return obj ; } + -: 62: + -: 63: private: + -: 64: T obj ; + -: 65: } ; + -: 66: + -: 67: // same for const references + -: 68: template + -: 69: class ConstReferenceInputParameter { + -: 70: public: + -: 71: typedef const T& const_reference ; + -: 72: ConstReferenceInputParameter(SEXP x_) : obj( as(x_) ){} + -: 73: + -: 74: inline operator const_reference() { return obj ; } + -: 75: + -: 76: private: + -: 77: T obj ; + -: 78: } ; + -: 79: + -: 80: namespace traits{ + -: 81: template + -: 82: struct input_parameter { + -: 83: typedef typename Rcpp::InputParameter type ; + -: 84: } ; + -: 85: template + -: 86: struct input_parameter { + -: 87: typedef typename Rcpp::ReferenceInputParameter type ; + -: 88: } ; + -: 89: template + -: 90: struct input_parameter { + -: 91: typedef typename Rcpp::ConstInputParameter type ; + -: 92: } ; + -: 93: template + -: 94: struct input_parameter { + -: 95: typedef typename Rcpp::ConstReferenceInputParameter type ; + -: 96: } ; + -: 97: } + -: 98: + -: 99:} + -: 100: + -: 101:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#Named.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#Named.h.gcov new file mode 100644 index 0000000..d9acf68 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#Named.h.gcov @@ -0,0 +1,88 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/Named.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- + -: 2:// + -: 3:// Named.h: Rcpp R/C++ interface class library -- named object + -: 4:// + -: 5:// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21: + -: 22:#ifndef Rcpp_Named_h + -: 23:#define Rcpp_Named_h + -: 24: + -: 25:namespace Rcpp{ + -: 26: + -: 27:class Argument { + -: 28:public: + -: 29: Argument() : name(){} ; + #####: 30: Argument( const std::string& name_) : name(name_){} + -: 31: + -: 32: template + #####: 33: inline traits::named_object operator=( const T& t){ + #####: 34: return traits::named_object( name, t ) ; + -: 35: } +------------------ +_ZN4Rcpp8ArgumentaSINS_6VectorILi16ENS_15PreserveStorageEEEEENS_6traits12named_objectIT_EERKS7_: + #####: 33: inline traits::named_object operator=( const T& t){ + #####: 34: return traits::named_object( name, t ) ; + -: 35: } +------------------ +_ZN4Rcpp8ArgumentaSIiEENS_6traits12named_objectIT_EERKS4_: + #####: 33: inline traits::named_object operator=( const T& t){ + #####: 34: return traits::named_object( name, t ) ; + -: 35: } +------------------ +_ZN4Rcpp8ArgumentaSIA1_cEENS_6traits12named_objectIT_EERKS5_: + #####: 33: inline traits::named_object operator=( const T& t){ + #####: 34: return traits::named_object( name, t ) ; + -: 35: } +------------------ + -: 36: + -: 37: std::string name ; + -: 38:} ; + -: 39: + -: 40:inline Argument Named( const std::string& name){ + -: 41: return Argument( name ); + -: 42:} + -: 43:template + -: 44:inline traits::named_object Named( const std::string& name, const T& o){ + -: 45: return traits::named_object( name, o ); + -: 46:} + -: 47: + -: 48:namespace internal{ + -: 49: + -: 50:class NamedPlaceHolder { + -: 51:public: + 30: 52: NamedPlaceHolder(){} + 30: 53: ~NamedPlaceHolder(){} + #####: 54: Argument operator[]( const std::string& arg) const { + #####: 55: return Argument( arg ) ; + -: 56: } + -: 57: Argument operator()(const std::string& arg) const { + -: 58: return Argument( arg ) ; + -: 59: } + -: 60: operator SEXP() const { return R_MissingArg ; } + -: 61:} ; + -: 62:} // internal + -: 63: + -: 64:static internal::NamedPlaceHolder _ ; + -: 65: + -: 66:} // namespace Rcpp + -: 67: + -: 68:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#RNGScope.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#RNGScope.h.gcov new file mode 100644 index 0000000..f0644cf --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#RNGScope.h.gcov @@ -0,0 +1,45 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/RNGScope.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- + -: 2:// + -: 3:// RNGScope.h: Rcpp R/C++ interface class library -- + -: 4:// + -: 5:// Copyright (C) 2010 - 2016 Douglas Bates, Dirk Eddelbuettel and Romain Francois + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21: + -: 22:#ifndef Rcpp__RNGScope_h + -: 23:#define Rcpp__RNGScope_h + -: 24: + -: 25:namespace Rcpp { + -: 26: + -: 27:class RNGScope{ + -: 28:public: + 135: 29: RNGScope(){ internal::enterRNGScope(); } + 135: 30: ~RNGScope(){ internal::exitRNGScope(); } + -: 31:}; + -: 32: + -: 33:class SuspendRNGSynchronizationScope { + -: 34:public: + -: 35: SuspendRNGSynchronizationScope() { internal::beginSuspendRNGSynchronization(); } + -: 36: ~SuspendRNGSynchronizationScope() { internal::endSuspendRNGSynchronization(); } + -: 37:}; + -: 38: + -: 39:} // namespace Rcpp + -: 40: + -: 41:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#RObject.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#RObject.h.gcov new file mode 100644 index 0000000..fde02fc --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#RObject.h.gcov @@ -0,0 +1,66 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/RObject.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- + -: 2:// + -: 3:// RObject.h: Rcpp R/C++ interface class library -- general R object wrapper + -: 4:// + -: 5:// Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21: + -: 22:#ifndef Rcpp_RObject_h + -: 23:#define Rcpp_RObject_h + -: 24: + -: 25:namespace Rcpp{ + -: 26: + -: 27: RCPP_API_CLASS(RObject_Impl) { + -: 28: public: + -: 29: + -: 30: /** + -: 31: * default constructor. uses R_NilValue + -: 32: */ + 135: 33: RObject_Impl() {}; + -: 34: + -: 35: RCPP_GENERATE_CTOR_ASSIGN(RObject_Impl) + -: 36: + -: 37: /** + -: 38: * wraps a SEXP. The SEXP is automatically protected from garbage + -: 39: * collection by this object and the protection vanishes when this + -: 40: * object is destroyed + -: 41: */ + -: 42: RObject_Impl(SEXP x){ + -: 43: Storage::set__(x) ; + -: 44: } + -: 45: + -: 46: /** + -: 47: * Assignement operator. Set this SEXP to the given SEXP + -: 48: */ + -: 49: template + 135: 50: RObject_Impl& operator=(const T& other) { + 135: 51: Storage::set__(Shield(wrap(other))); + 135: 52: return *this; + -: 53: } + -: 54: + 135: 55: void update(SEXP){} + -: 56: }; + -: 57: + -: 58: typedef RObject_Impl RObject ; + -: 59: + -: 60:} // namespace Rcpp + -: 61: + -: 62:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#Rcpp_eval.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#Rcpp_eval.h.gcov new file mode 100644 index 0000000..eab5877 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#Rcpp_eval.h.gcov @@ -0,0 +1,96 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/api/meat/Rcpp_eval.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// Copyright (C) 2013 - 2025 Romain Francois + -: 2:// Copyright (C) 2026 Romain Francois and Dirk Eddelbuettel + -: 3:// + -: 4:// This file is part of Rcpp. + -: 5:// + -: 6:// Rcpp is free software: you can redistribute it and/or modify it + -: 7:// under the terms of the GNU General Public License as published by + -: 8:// the Free Software Foundation, either version 2 of the License, or + -: 9:// (at your option) any later version. + -: 10:// + -: 11:// Rcpp is distributed in the hope that it will be useful, but + -: 12:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 13:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 14:// GNU General Public License for more details. + -: 15:// + -: 16:// You should have received a copy of the GNU General Public License + -: 17:// along with Rcpp. If not, see . + -: 18: + -: 19:#ifndef Rcpp_api_meat_Rcpp_eval_h + -: 20:#define Rcpp_api_meat_Rcpp_eval_h + -: 21: + -: 22:#include + -: 23:#include + -: 24: + -: 25: + -: 26:namespace Rcpp { namespace internal { + -: 27: + -: 28:struct EvalData { + -: 29: SEXP expr; + -: 30: SEXP env; + #####: 31: EvalData(SEXP expr_, SEXP env_) : expr(expr_), env(env_) { } + -: 32:}; + -: 33: + #####: 34:inline SEXP Rcpp_protected_eval(void* eval_data) { + #####: 35: EvalData* data = static_cast(eval_data); + #####: 36: return ::Rf_eval(data->expr, data->env); + -: 37:} + -: 38: + -: 39:// This is used internally instead of Rf_eval() to make evaluation safer + -: 40:inline SEXP Rcpp_eval_impl(SEXP expr, SEXP env) { // #nocov + -: 41: return Rcpp_fast_eval(expr, env); // #nocov + -: 42:} + -: 43: + -: 44:}} // namespace Rcpp::internal + -: 45: + -: 46: + -: 47:namespace Rcpp { + -: 48: + #####: 49:inline SEXP Rcpp_fast_eval(SEXP expr, SEXP env) { + #####: 50: internal::EvalData data(expr, env); + #####: 51: return unwindProtect(&internal::Rcpp_protected_eval, &data); + -: 52:} + -: 53: + -: 54:inline SEXP Rcpp_eval(SEXP expr, SEXP env) { + -: 55: + -: 56: // 'identity' function used to capture errors, interrupts + -: 57: Shield identity(Rf_findFun(::Rf_install("identity"), R_BaseNamespace)); + -: 58: + -: 59: // define the evalq call -- the actual R evaluation we want to execute + -: 60: Shield evalqCall(Rf_lang3(::Rf_install("evalq"), expr, env)); + -: 61: + -: 62: // define the call -- enclose with `tryCatch` so we can record and forward error messages + -: 63: Shield call(Rf_lang4(::Rf_install("tryCatch"), evalqCall, identity, identity)); + -: 64: SET_TAG(CDDR(call), ::Rf_install("error")); + -: 65: SET_TAG(CDDR(CDR(call)), ::Rf_install("interrupt")); + -: 66: + -: 67: Shield res(internal::Rcpp_eval_impl(call, R_BaseEnv)); + -: 68: + -: 69: // check for condition results (errors, interrupts) + -: 70: if (Rf_inherits(res, "condition")) { + -: 71: + -: 72: if (Rf_inherits(res, "error")) { + -: 73: + -: 74: Shield conditionMessageCall(::Rf_lang2(::Rf_install("conditionMessage"), res)); + -: 75: + -: 76: Shield conditionMessage(internal::Rcpp_eval_impl(conditionMessageCall, R_BaseEnv)); + -: 77: throw eval_error(CHAR(STRING_ELT(conditionMessage, 0))); + -: 78: } + -: 79: + -: 80: // check for interrupt + -: 81: if (Rf_inherits(res, "interrupt")) { + -: 82: throw internal::InterruptedException(); + -: 83: } + -: 84: + -: 85: } + -: 86: + -: 87: return res; + -: 88:} + -: 89: + -: 90:} // namespace Rcpp + -: 91: + -: 92:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#proxy.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#proxy.h.gcov new file mode 100644 index 0000000..c84a85d --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#api#meat#proxy.h.gcov @@ -0,0 +1,209 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/api/meat/proxy.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- + -: 2:// + -: 3:// proxy.h: Rcpp R/C++ interface class library -- proxy meat + -: 4:// + -: 5:// Copyright (C) 2014 Dirk Eddelbuettel, Romain Francois, and Kevin Ushey + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21:#ifndef RCPP_API_MEAT_PROXY_H + -: 22:#define RCPP_API_MEAT_PROXY_H + -: 23: + -: 24:// NOTE: Implementing this as 'meat' is necessary as it allows user-defined + -: 25:// classes writing their own overloads of 'wrap', 'as' to function correctly! + -: 26:namespace Rcpp { + -: 27: + -: 28:// AttributeProxy + -: 29:template + -: 30:template + -: 31:typename AttributeProxyPolicy::AttributeProxy& + #####: 32:AttributeProxyPolicy::AttributeProxy::operator=(const T& rhs) { + #####: 33: set(wrap(rhs)); + #####: 34: return *this; + -: 35:} + -: 36: + -: 37:template + -: 38:template + -: 39:AttributeProxyPolicy::AttributeProxy::operator T() const { + -: 40: return as(get()); + -: 41:} + -: 42: + -: 43:template + -: 44:AttributeProxyPolicy::AttributeProxy::operator SEXP() const { + -: 45: return get(); + -: 46:} + -: 47: + -: 48:template + -: 49:template + -: 50:AttributeProxyPolicy::const_AttributeProxy::operator T() const { + -: 51: return as(get()); + -: 52:} + -: 53: + -: 54:template + -: 55:AttributeProxyPolicy::const_AttributeProxy::operator SEXP() const { + -: 56: return get(); + -: 57:} + -: 58: + -: 59:// NamesProxy + -: 60:template + -: 61:template + -: 62:typename NamesProxyPolicy::NamesProxy& + -: 63:NamesProxyPolicy::NamesProxy::operator=(const T& rhs) { + -: 64: set(Shield(wrap(rhs))); + -: 65: return *this; + -: 66:} + -: 67: + -: 68:template + -: 69:template + -: 70:NamesProxyPolicy::NamesProxy::operator T() const { + -: 71: return as( get() ); + -: 72:} + -: 73: + -: 74:template + -: 75:template + -: 76:NamesProxyPolicy::const_NamesProxy::operator T() const { + -: 77: return as( get() ); + -: 78:} + -: 79: + -: 80:// SlotProxy + -: 81:template + -: 82:template + -: 83:typename SlotProxyPolicy::SlotProxy& + -: 84:SlotProxyPolicy::SlotProxy::operator=(const T& rhs) { + -: 85: set(Shield(wrap(rhs))); + -: 86: return *this; + -: 87:} + -: 88: + -: 89:template + -: 90:template + -: 91:SlotProxyPolicy::SlotProxy::operator T() const { + -: 92: return as(get()); + -: 93:} + -: 94: + -: 95:// TagProxy + -: 96:template + -: 97:template + -: 98:typename TagProxyPolicy::TagProxy& + -: 99:TagProxyPolicy::TagProxy::operator=(const T& rhs) { + -: 100: set(Shield(wrap(rhs))); + -: 101: return *this; + -: 102:} + -: 103: + -: 104:template + -: 105:template + -: 106:TagProxyPolicy::TagProxy::operator T() const { + -: 107: return as(get()); + -: 108:} + -: 109: + -: 110:template + -: 111:TagProxyPolicy::TagProxy::operator SEXP() const { + -: 112: return get(); + -: 113:} + -: 114: + -: 115:template + -: 116:template + -: 117:TagProxyPolicy::const_TagProxy::operator T() const { + -: 118: return as(get()); + -: 119:} + -: 120: + -: 121:template + -: 122:TagProxyPolicy::const_TagProxy::operator SEXP() const { + -: 123: return get(); + -: 124:} + -: 125: + -: 126:// Binding + -: 127:template + -: 128:template + -: 129:typename BindingPolicy::Binding& + -: 130:BindingPolicy::Binding::operator=(const T& rhs) { + -: 131: set(Shield(wrap(rhs))); + -: 132: return *this; + -: 133:} + -: 134: + -: 135:template + -: 136:template + -: 137:BindingPolicy::Binding::operator T() const { + -: 138: return as(get()); + -: 139:} + -: 140: + -: 141:template + -: 142:template + -: 143:BindingPolicy::const_Binding::operator T() const { + -: 144: return as(get()); + -: 145:} + -: 146: + -: 147:// DottedPairProxy + -: 148:template + -: 149:template + -: 150:typename DottedPairProxyPolicy::DottedPairProxy& + -: 151:DottedPairProxyPolicy::DottedPairProxy::operator=(const T& rhs) { + -: 152: set(Shield(wrap(rhs))); + -: 153: return *this; + -: 154:} + -: 155: + -: 156:template + -: 157:template + -: 158:typename DottedPairProxyPolicy::DottedPairProxy& + -: 159:DottedPairProxyPolicy::DottedPairProxy::operator=(const traits::named_object& rhs) { + -: 160: return set(Shield(wrap(rhs.object)), rhs.name); + -: 161:} + -: 162: + -: 163:template + -: 164:template + -: 165:DottedPairProxyPolicy::DottedPairProxy::operator T() const { + -: 166: return as(get()); + -: 167:} + -: 168: + -: 169:template + -: 170:template + -: 171:DottedPairProxyPolicy::const_DottedPairProxy::operator T() const { + -: 172: return as(get()); + -: 173:} + -: 174: + -: 175:// FieldProxy + -: 176:template + -: 177:typename FieldProxyPolicy::FieldProxy& + -: 178:FieldProxyPolicy::FieldProxy::operator=(const FieldProxyPolicy::FieldProxy& rhs) { + -: 179: if (this != &rhs) set(rhs.get()); + -: 180: return *this; + -: 181:} + -: 182: + -: 183:template + -: 184:template + -: 185:typename FieldProxyPolicy::FieldProxy& + -: 186:FieldProxyPolicy::FieldProxy::operator=(const T& rhs) { + -: 187: set(Shield(wrap(rhs))); + -: 188: return *this; + -: 189:} + -: 190: + -: 191:template + -: 192:template + -: 193:FieldProxyPolicy::FieldProxy::operator T() const { + -: 194: return as(get()); + -: 195:} + -: 196: + -: 197:template + -: 198:template + -: 199:FieldProxyPolicy::const_FieldProxy::operator T() const { + -: 200: return as(get()); + -: 201:} + -: 202: + -: 203:} + -: 204: + -: 205:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#as.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#as.h.gcov new file mode 100644 index 0000000..e549496 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#as.h.gcov @@ -0,0 +1,171 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/as.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1: + -: 2:// as.h: Rcpp R/C++ interface class library -- convert SEXP to C++ objects + -: 3:// + -: 4:// Copyright (C) 2009 - 2026 Dirk Eddelbuettel and Romain Francois + -: 5:// + -: 6:// This file is part of Rcpp. + -: 7:// + -: 8:// Rcpp is free software: you can redistribute it and/or modify it + -: 9:// under the terms of the GNU General Public License as published by + -: 10:// the Free Software Foundation, either version 2 of the License, or + -: 11:// (at your option) any later version. + -: 12:// + -: 13:// Rcpp is distributed in the hope that it will be useful, but + -: 14:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 15:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 16:// GNU General Public License for more details. + -: 17:// + -: 18:// You should have received a copy of the GNU General Public License + -: 19:// along with Rcpp. If not, see . + -: 20: + -: 21:#ifndef Rcpp__as__h + -: 22:#define Rcpp__as__h + -: 23: + -: 24:#include + -: 25: + -: 26:namespace Rcpp { + -: 27: + -: 28: namespace internal { + -: 29: + 135: 30: template T primitive_as(SEXP x) { + 135: 31: if (::Rf_length(x) != 1) { + #####: 32: const char* fmt = "Expecting a single value: [extent=%i]."; // #nocov + #####: 33: throw ::Rcpp::not_compatible(fmt, ::Rf_length(x)); // #nocov + -: 34: } + 135: 35: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + 135: 36: Shield y(r_cast(x)); + -: 37: typedef typename ::Rcpp::traits::storage_type::type STORAGE; + 135: 38: T res = caster(*r_vector_start(y)); + 135: 39: return res; + 135: 40: } + -: 41: + 135: 42: template T as(SEXP x, ::Rcpp::traits::r_type_primitive_tag) { + 135: 43: return primitive_as(x); + -: 44: } + -: 45: + -: 46: inline const char* check_single_string(SEXP x) { + -: 47: if (TYPEOF(x) == CHARSXP) return CHAR(x); // #nocov start + -: 48: if (! ::Rf_isString(x) || Rf_length(x) != 1) { + -: 49: const char* fmt = "Expecting a single string value: " + -: 50: "[type=%s; extent=%i]."; + -: 51: throw ::Rcpp::not_compatible(fmt, + -: 52: Rf_type2char(TYPEOF(x)), + -: 53: Rf_length(x)); + -: 54: } // #nocov end + -: 55: + -: 56: return CHAR(STRING_ELT(::Rcpp::r_cast(x), 0)); + -: 57: } + -: 58: + -: 59: + -: 60: template T as_string(SEXP x, Rcpp::traits::true_type) { + -: 61: const char* y = check_single_string(x); + -: 62: return std::wstring(y, y+strlen(y)); + -: 63: } + -: 64: + -: 65: template T as_string(SEXP x, Rcpp::traits::false_type) { + -: 66: return check_single_string(x); + -: 67: } + -: 68: + -: 69: template T as(SEXP x, ::Rcpp::traits::r_type_string_tag) { + -: 70: return as_string(x, typename Rcpp::traits::is_wide_string::type()); + -: 71: } + -: 72: + -: 73: template T as(SEXP x, ::Rcpp::traits::r_type_RcppString_tag) { + -: 74: if (! ::Rf_isString(x)) { + -: 75: const char* fmt = "Expecting a single string value: " + -: 76: "[type=%s; extent=%i]."; + -: 77: throw ::Rcpp::not_compatible(fmt, + -: 78: Rf_type2char(TYPEOF(x)), + -: 79: Rf_length(x)); + -: 80: } + -: 81: return STRING_ELT(::Rcpp::r_cast(x), 0); + -: 82: } + -: 83: + -: 84: template T as(SEXP x, ::Rcpp::traits::r_type_generic_tag) { + -: 85: RCPP_DEBUG_1("as(SEXP = <%p>, r_type_generic_tag )", x); + -: 86: ::Rcpp::traits::Exporter exporter(x); + -: 87: RCPP_DEBUG_1("exporter type = %s", DEMANGLE(exporter)); + -: 88: return exporter.get(); + -: 89: } + -: 90: + -: 91: void* as_module_object_internal(SEXP obj); + -: 92: + -: 93: template object as_module_object(SEXP x) { + -: 94: return (T*) as_module_object_internal(x); + -: 95: } + -: 96: + -: 97: /** handling object */ + -: 98: template T as(SEXP x, ::Rcpp::traits::r_type_module_object_const_pointer_tag) { + -: 99: typedef typename Rcpp::traits::remove_const::type T_NON_CONST; + -: 100: return const_cast((T_NON_CONST)as_module_object_internal(x)); + -: 101: } + -: 102: + -: 103: template T as(SEXP x, ::Rcpp::traits::r_type_module_object_pointer_tag) { + -: 104: return as_module_object::type>(x); + -: 105: } + -: 106: + -: 107: /** handling T such that T is exposed by a module */ + -: 108: template T as(SEXP x, ::Rcpp::traits::r_type_module_object_tag) { + -: 109: T* obj = as_module_object(x); + -: 110: return *obj; + -: 111: } + -: 112: + -: 113: /** handling T such that T is a reference of a class handled by a module */ + -: 114: template T as(SEXP x, ::Rcpp::traits::r_type_module_object_reference_tag) { + -: 115: typedef typename traits::remove_reference::type KLASS; + -: 116: KLASS* obj = as_module_object(x); + -: 117: return *obj; + -: 118: } + -: 119: + -: 120: /** handling T such that T is a reference of a class handled by a module */ + -: 121: template T as(SEXP x, ::Rcpp::traits::r_type_module_object_const_reference_tag) { + -: 122: typedef typename traits::remove_const_and_reference::type KLASS; + -: 123: KLASS* obj = as_module_object(x); + -: 124: return const_cast(*obj); + -: 125: } + -: 126: + -: 127: /** handling enums by converting to int first */ + -: 128: template T as(SEXP x, ::Rcpp::traits::r_type_enum_tag) { + -: 129: return T(primitive_as(x)); + -: 130: } + -: 131: + -: 132: } + -: 133: + -: 134: + -: 135: /** + -: 136: * Generic converted from SEXP to the typename. T can be any type that + -: 137: * has a constructor taking a SEXP, which is the case for all our + -: 138: * RObject and derived classes. + -: 139: * + -: 140: * If it is not possible to add the SEXP constructor, e.g you don't control + -: 141: * the type, you can specialize the as template to perform the + -: 142: * requested conversion + -: 143: * + -: 144: * This is used for example in Environment, so that for example the code + -: 145: * below will work as long as there is a way to as<> the Foo type + -: 146: * + -: 147: * Environment x = ... ; // some environment + -: 148: * Foo y = x["bla"] ; // if as makes sense then this works !! + -: 149: */ + 135: 150: template T as(SEXP x) { + 135: 151: return internal::as(x, typename traits::r_type_traits::r_category()); + -: 152: } + -: 153: + -: 154: template <> inline char as(SEXP x) { + -: 155: return internal::check_single_string(x)[0]; + -: 156: } + -: 157: + -: 158: template + -: 159: inline typename traits::remove_const_and_reference::type bare_as(SEXP x) { + -: 160: return as< typename traits::remove_const_and_reference::type >(x); + -: 161: } + -: 162: + 135: 163: template<> inline SEXP as(SEXP x) { return x; } + -: 164: + -: 165:} // Rcpp + -: 166: + -: 167:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#exceptions.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#exceptions.h.gcov new file mode 100644 index 0000000..0fcbbab --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#exceptions.h.gcov @@ -0,0 +1,487 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/exceptions.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1: + -: 2:// exceptions.h: Rcpp R/C++ interface class library -- exceptions + -: 3:// + -: 4:// Copyright (C) 2010 - 2020 Dirk Eddelbuettel and Romain Francois + -: 5:// Copyright (C) 2021 - 2024 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar + -: 6:// Copyright (C) 2025 - 2026 Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and James J Balamuta + -: 7:// + -: 8:// This file is part of Rcpp. + -: 9:// + -: 10:// Rcpp is free software: you can redistribute it and/or modify it + -: 11:// under the terms of the GNU General Public License as published by + -: 12:// the Free Software Foundation, either version 2 of the License, or + -: 13:// (at your option) any later version. + -: 14:// + -: 15:// Rcpp is distributed in the hope that it will be useful, but + -: 16:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 17:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 18:// GNU General Public License for more details. + -: 19:// + -: 20:// You should have received a copy of the GNU General Public License + -: 21:// along with Rcpp. If not, see . + -: 22: + -: 23:#ifndef Rcpp__exceptions__h + -: 24:#define Rcpp__exceptions__h + -: 25: + -: 26:#include + -: 27: + -: 28:#ifndef RCPP_DEFAULT_INCLUDE_CALL + -: 29:#define RCPP_DEFAULT_INCLUDE_CALL true + -: 30:#endif + -: 31: + -: 32:#define GET_STACKTRACE() R_NilValue + -: 33: + -: 34:namespace Rcpp { + -: 35: + -: 36: // Throwing an exception must be thread-safe to avoid surprises w/ OpenMP. + -: 37: class exception : public std::exception { + -: 38: public: + #####: 39: explicit exception(const char* message_, bool include_call = RCPP_DEFAULT_INCLUDE_CALL) : // #nocov start + #####: 40: message(message_), + #####: 41: include_call_(include_call) { + #####: 42: record_stack_trace(); + #####: 43: } + -: 44: exception(const char* message_, const char*, int, bool include_call = RCPP_DEFAULT_INCLUDE_CALL) : + -: 45: message(message_), + -: 46: include_call_(include_call) { + -: 47: record_stack_trace(); + -: 48: } + #####: 49: bool include_call() const { + #####: 50: return include_call_; + -: 51: } + #####: 52: virtual ~exception() throw() {} +------------------ +_ZN4Rcpp9exceptionD0Ev: + #####: 52: virtual ~exception() throw() {} +------------------ +_ZN4Rcpp9exceptionD2Ev: + #####: 52: virtual ~exception() throw() {} +------------------ + #####: 53: virtual const char* what() const throw() { + #####: 54: return message.c_str(); // #nocov end + -: 55: } + -: 56: inline void copy_stack_trace_to_r() const; + -: 57: private: + -: 58: std::string message; + -: 59: bool include_call_; + -: 60: std::vector stack; + -: 61: inline void record_stack_trace(); + -: 62: }; + -: 63: + -: 64: // simple helper + #####: 65: static std::string toString(const int i) { // #nocov start + #####: 66: std::ostringstream ostr; + #####: 67: ostr << i; + #####: 68: return ostr.str(); // #nocov end + #####: 69: } + -: 70: + -: 71: class no_such_env : public std::exception { + -: 72: public: + -: 73: no_such_env(const std::string& name) throw() : + -: 74: message(std::string("no such environment: '") + name + "'") {}; + -: 75: no_such_env(int pos) throw() : + -: 76: message("no environment in given position '" + toString(pos) + "'") {}; + -: 77: virtual ~no_such_env() throw() {}; + -: 78: virtual const char* what() const throw() { return message.c_str(); }; + -: 79: private: + -: 80: std::string message; + -: 81: }; + -: 82: + -: 83: class file_io_error : public std::exception { + -: 84: public: + -: 85: file_io_error(const std::string& file) throw() : // #nocov start + -: 86: message(std::string("file io error: '") + file + "'"), file(file) {}; + -: 87: file_io_error(int code, const std::string& file) throw() : + -: 88: message("file io error " + toString(code) + ": '" + file + "'"), file(file) {}; + -: 89: file_io_error(const std::string& msg, const std::string& file) throw() : + -: 90: message(msg + ": '" + file + "'"), file(file) {}; + -: 91: virtual ~file_io_error() throw() {}; + -: 92: virtual const char* what() const throw() { return message.c_str(); }; + -: 93: std::string filePath() const throw() { return file; }; // #nocov end + -: 94: private: + -: 95: std::string message; + -: 96: std::string file; + -: 97: } ; + -: 98: + -: 99: class file_not_found : public file_io_error { // #nocov start + -: 100: public: + -: 101: file_not_found(const std::string& file) throw() : + -: 102: file_io_error("file not found", file) {} // #nocov end + -: 103: }; + -: 104: + -: 105: class file_exists : public file_io_error { // #nocov start + -: 106: public: + -: 107: file_exists(const std::string& file) throw() : + -: 108: file_io_error("file already exists", file) {} // #nocov end + -: 109: }; + -: 110: + -: 111: // Variadic / code generated version of the warning and stop functions + -: 112: // can be found within the respective C++11 or C++98 exceptions.h + -: 113: // included below. + -: 114: inline void warning(const std::string& message) { // #nocov start + -: 115: ::Rf_warning("%s", message.c_str()); + -: 116: } // #nocov end + -: 117: + #####: 118: inline void NORET stop(const std::string& message) { // #nocov start + #####: 119: throw Rcpp::exception(message.c_str()); + -: 120: } // #nocov end + -: 121: + -: 122:} // namespace Rcpp + -: 123: + -: 124: + -: 125:namespace Rcpp { namespace internal { + -: 126: + -: 127:inline SEXP longjumpSentinel(SEXP token) { + -: 128: SEXP sentinel = PROTECT(Rf_allocVector(VECSXP, 1)); + -: 129: SET_VECTOR_ELT(sentinel, 0, token); + -: 130: + -: 131: SEXP sentinelClass = PROTECT(Rf_mkString("Rcpp:longjumpSentinel")); + -: 132: Rf_setAttrib(sentinel, R_ClassSymbol, sentinelClass) ; + -: 133: + -: 134: UNPROTECT(2); + -: 135: return sentinel; + -: 136:} + -: 137: + #####: 138:inline bool isLongjumpSentinel(SEXP x) { // #nocov start + -: 139: return + #####: 140: Rf_inherits(x, "Rcpp:longjumpSentinel") && + #####: 141: TYPEOF(x) == VECSXP && + #####: 142: Rf_length(x) == 1; + -: 143:} + -: 144: + #####: 145:inline SEXP getLongjumpToken(SEXP sentinel) { + #####: 146: return VECTOR_ELT(sentinel, 0); + -: 147:} + -: 148: + #####: 149:inline void resumeJump(SEXP token) { + #####: 150: if (isLongjumpSentinel(token)) { + #####: 151: token = getLongjumpToken(token); + -: 152: } + #####: 153: ::R_ReleaseObject(token); + #####: 154: ::R_ContinueUnwind(token); + -: 155: Rf_error("Internal error: Rcpp longjump failed to resume"); + -: 156:} + -: 157: + -: 158:}} // namespace Rcpp::internal + -: 159: + -: 160: + -: 161:namespace Rcpp { + -: 162: + -: 163:struct LongjumpException { + -: 164: SEXP token; + #####: 165: LongjumpException(SEXP token_) : token(token_) { + #####: 166: if (internal::isLongjumpSentinel(token)) { + #####: 167: token = internal::getLongjumpToken(token); + -: 168: } + #####: 169: } + -: 170:}; + -: 171: + -: 172: #define RCPP_ADVANCED_EXCEPTION_CLASS(__CLASS__, __WHAT__) \ + -: 173: class __CLASS__ : public std::exception { \ + -: 174: public: \ + -: 175: __CLASS__( ) throw() : message( std::string(__WHAT__) + "." ){} \ + -: 176: __CLASS__( const std::string& message ) throw() : \ + -: 177: message( std::string(__WHAT__) + ": " + message + "."){} \ + -: 178: template \ + -: 179: __CLASS__( const char* fmt, Args&&... args ) throw() : \ + -: 180: message( tfm::format(fmt, std::forward(args)... ) ){} \ + -: 181: virtual ~__CLASS__() throw(){} \ + -: 182: virtual const char* what() const throw() { return message.c_str(); } \ + -: 183: private: \ + -: 184: std::string message; \ + -: 185: }; + -: 186: + -: 187: template + -: 188: inline void warning(const char* fmt, Args&&... args ) { + -: 189: Rf_warning("%s", tfm::format(fmt, std::forward(args)... ).c_str()); + -: 190: } // #nocov end + -: 191: + -: 192: template + -: 193: inline void NORET stop(const char* fmt, Args&&... args) { + -: 194: throw Rcpp::exception( tfm::format(fmt, std::forward(args)... ).c_str() ); + -: 195: } + -: 196: + -: 197: #define RCPP_EXCEPTION_CLASS(__CLASS__,__WHAT__) \ + -: 198: class __CLASS__ : public std::exception{ \ + -: 199: public: \ + -: 200: __CLASS__( ) throw() : message( std::string(__WHAT__) + "." ){} ; \ + -: 201: __CLASS__( const std::string& message ) throw() : \ + -: 202: message( std::string(__WHAT__) + ": " + message + "." ){} ; \ + -: 203: virtual ~__CLASS__() throw(){} ; \ + -: 204: virtual const char* what() const throw() { return message.c_str() ; } \ + -: 205: private: \ + -: 206: std::string message ; \ + -: 207: } ; + -: 208: + -: 209: #define RCPP_SIMPLE_EXCEPTION_CLASS(__CLASS__,__MESSAGE__) \ + -: 210: class __CLASS__ : public std::exception{ \ + -: 211: public: \ + -: 212: __CLASS__() throw() {} ; \ + -: 213: virtual ~__CLASS__() throw(){} ; \ + -: 214: virtual const char* what() const throw() { return __MESSAGE__ ; } \ + -: 215: } ; + -: 216: + -: 217: RCPP_SIMPLE_EXCEPTION_CLASS(not_a_matrix, "Not a matrix.") // #nocov start + -: 218: RCPP_SIMPLE_EXCEPTION_CLASS(parse_error, "Parse error.") + -: 219: RCPP_SIMPLE_EXCEPTION_CLASS(not_s4, "Not an S4 object.") + -: 220: RCPP_SIMPLE_EXCEPTION_CLASS(not_reference, "Not an S4 object of a reference class.") + -: 221: RCPP_SIMPLE_EXCEPTION_CLASS(not_initialized, "C++ object not initialized. (Missing default constructor?)") + -: 222: RCPP_SIMPLE_EXCEPTION_CLASS(no_such_field, "No such field.") // not used internally + -: 223: RCPP_SIMPLE_EXCEPTION_CLASS(no_such_function, "No such function.") + -: 224: RCPP_SIMPLE_EXCEPTION_CLASS(unevaluated_promise, "Promise not yet evaluated.") + -: 225: RCPP_SIMPLE_EXCEPTION_CLASS(embedded_nul_in_string, "Embedded NUL in string.") + -: 226: + -: 227: // Promoted + -: 228: RCPP_EXCEPTION_CLASS(no_such_slot, "No such slot") + -: 229: RCPP_EXCEPTION_CLASS(not_a_closure, "Not a closure") + -: 230: + -: 231: RCPP_EXCEPTION_CLASS(S4_creation_error, "Error creating object of S4 class") + -: 232: RCPP_EXCEPTION_CLASS(reference_creation_error, "Error creating object of reference class") // not used internally + -: 233: RCPP_EXCEPTION_CLASS(no_such_binding, "No such binding") + -: 234: RCPP_EXCEPTION_CLASS(binding_not_found, "Binding not found") + -: 235: RCPP_EXCEPTION_CLASS(binding_is_locked, "Binding is locked") + -: 236: RCPP_EXCEPTION_CLASS(no_such_namespace, "No such namespace") + -: 237: RCPP_EXCEPTION_CLASS(function_not_exported, "Function not exported") + -: 238: RCPP_EXCEPTION_CLASS(eval_error, "Evaluation error") + -: 239: + -: 240: // Promoted + #####: 241: RCPP_ADVANCED_EXCEPTION_CLASS(not_compatible, "Not compatible" ) // #nocov end +------------------ +_ZN4Rcpp14not_compatibleC2IJiEEEPKcDpOT_: + #####: 241: RCPP_ADVANCED_EXCEPTION_CLASS(not_compatible, "Not compatible" ) // #nocov end +------------------ +_ZN4Rcpp14not_compatibleC2IJPKcS3_EEES3_DpOT_: + #####: 241: RCPP_ADVANCED_EXCEPTION_CLASS(not_compatible, "Not compatible" ) // #nocov end +------------------ +_ZNK4Rcpp14not_compatible4whatEv: + #####: 241: RCPP_ADVANCED_EXCEPTION_CLASS(not_compatible, "Not compatible" ) // #nocov end +------------------ +_ZN4Rcpp14not_compatibleD0Ev: + #####: 241: RCPP_ADVANCED_EXCEPTION_CLASS(not_compatible, "Not compatible" ) // #nocov end +------------------ +_ZN4Rcpp14not_compatibleD2Ev: + #####: 241: RCPP_ADVANCED_EXCEPTION_CLASS(not_compatible, "Not compatible" ) // #nocov end +------------------ + -: 242: RCPP_ADVANCED_EXCEPTION_CLASS(index_out_of_bounds, "Index is out of bounds") + -: 243: + -: 244: #undef RCPP_SIMPLE_EXCEPTION_CLASS + -: 245: #undef RCPP_EXCEPTION_CLASS + -: 246: #undef RCPP_ADVANCED_EXCEPTION_CLASS + -: 247: + -: 248: + -: 249:namespace internal { + -: 250: + #####: 251: inline SEXP nth(SEXP s, int n) { // #nocov start + #####: 252: return Rf_length(s) > n ? (n == 0 ? CAR(s) : CAR(Rf_nthcdr(s, n))) : R_NilValue; + -: 253: } + -: 254: + -: 255: // We want the call just prior to the call from Rcpp_eval + -: 256: // This conditional matches + -: 257: // tryCatch(evalq(sys.calls(), .GlobalEnv), error = identity, interrupt = identity) + #####: 258: inline bool is_Rcpp_eval_call(SEXP expr) { + #####: 259: SEXP sys_calls_symbol = Rf_install("sys.calls"); + #####: 260: SEXP identity_symbol = Rf_install("identity"); + #####: 261: Shield identity_fun(Rf_findFun(identity_symbol, R_BaseEnv)); + #####: 262: SEXP tryCatch_symbol = Rf_install("tryCatch"); + #####: 263: SEXP evalq_symbol = Rf_install("evalq"); + -: 264: + #####: 265: return TYPEOF(expr) == LANGSXP && + #####: 266: Rf_length(expr) == 4 && + #####: 267: nth(expr, 0) == tryCatch_symbol && + #####: 268: CAR(nth(expr, 1)) == evalq_symbol && + #####: 269: CAR(nth(nth(expr, 1), 1)) == sys_calls_symbol && + #####: 270: nth(nth(expr, 1), 2) == R_GlobalEnv && + #####: 271: nth(expr, 2) == identity_fun && + #####: 272: nth(expr, 3) == identity_fun; + #####: 273: } + -: 274:} // namespace internal + -: 275: + -: 276:} // namespace Rcpp + -: 277: + #####: 278:inline SEXP get_last_call(){ + #####: 279: SEXP sys_calls_symbol = Rf_install("sys.calls"); + -: 280: + #####: 281: Rcpp::Shield sys_calls_expr(Rf_lang1(sys_calls_symbol)); + #####: 282: Rcpp::Shield calls(Rcpp_fast_eval(sys_calls_expr, R_GlobalEnv)); + -: 283: + -: 284: SEXP cur, prev; + #####: 285: prev = cur = calls; + #####: 286: while(CDR(cur) != R_NilValue) { + #####: 287: SEXP expr = CAR(cur); + -: 288: + #####: 289: if (Rcpp::internal::is_Rcpp_eval_call(expr)) { + #####: 290: break; + -: 291: } + #####: 292: prev = cur; + #####: 293: cur = CDR(cur); + -: 294: } + #####: 295: return CAR(prev); + #####: 296:} + -: 297: + #####: 298:inline SEXP get_exception_classes( const std::string& ex_class) { + #####: 299: Rcpp::Shield res( Rf_allocVector( STRSXP, 4 ) ); + -: 300: + -: 301: #ifndef RCPP_USING_UTF8_ERROR_STRING + #####: 302: SET_STRING_ELT( res, 0, Rf_mkChar( ex_class.c_str() ) ) ; + -: 303: #else + -: 304: SET_STRING_ELT( res, 0, Rf_mkCharLenCE( ex_class.c_str(), ex_class.size(), CE_UTF8 ) ); + -: 305: #endif + #####: 306: SET_STRING_ELT( res, 1, Rf_mkChar( "C++Error" ) ) ; + #####: 307: SET_STRING_ELT( res, 2, Rf_mkChar( "error" ) ) ; + #####: 308: SET_STRING_ELT( res, 3, Rf_mkChar( "condition" ) ) ; + #####: 309: return res; + #####: 310:} + -: 311: + #####: 312:inline SEXP make_condition(const std::string& ex_msg, SEXP call, SEXP cppstack, SEXP classes){ + #####: 313: Rcpp::Shield res( Rf_allocVector( VECSXP, 3 ) ) ; + -: 314: #ifndef RCPP_USING_UTF8_ERROR_STRING + #####: 315: SET_VECTOR_ELT( res, 0, Rf_mkString( ex_msg.c_str() ) ) ; + -: 316: #else + -: 317: Rcpp::Shield ex_msg_rstring( Rf_allocVector( STRSXP, 1 ) ) ; + -: 318: SET_STRING_ELT( ex_msg_rstring, 0, Rf_mkCharLenCE( ex_msg.c_str(), ex_msg.size(), CE_UTF8 ) ); + -: 319: SET_VECTOR_ELT( res, 0, ex_msg_rstring ) ; + -: 320: #endif + #####: 321: SET_VECTOR_ELT( res, 1, call ) ; + #####: 322: SET_VECTOR_ELT( res, 2, cppstack ) ; + -: 323: + #####: 324: Rcpp::Shield names( Rf_allocVector( STRSXP, 3 ) ); + #####: 325: SET_STRING_ELT( names, 0, Rf_mkChar( "message" ) ) ; + #####: 326: SET_STRING_ELT( names, 1, Rf_mkChar( "call" ) ) ; + #####: 327: SET_STRING_ELT( names, 2, Rf_mkChar( "cppstack" ) ) ; + #####: 328: Rf_setAttrib( res, R_NamesSymbol, names ) ; + #####: 329: Rf_setAttrib( res, R_ClassSymbol, classes ) ; + #####: 330: return res ; + #####: 331:} + -: 332: + -: 333:template + #####: 334:inline SEXP exception_to_condition_template( const Exception& ex, bool include_call) { + -: 335:#ifndef RCPP_NO_RTTI + #####: 336: std::string ex_class = demangle( typeid(ex).name() ) ; + -: 337:#else + -: 338: std::string ex_class = ""; + -: 339:#endif + #####: 340: std::string ex_msg = ex.what() ; + -: 341: + #####: 342: Rcpp::Shelter shelter; + -: 343: SEXP call, cppstack; + #####: 344: if (include_call) { + #####: 345: call = shelter(get_last_call()); + #####: 346: cppstack = shelter(rcpp_get_stack_trace()); + -: 347: } else { + #####: 348: call = R_NilValue; + #####: 349: cppstack = R_NilValue; + -: 350: } + #####: 351: SEXP classes = shelter( get_exception_classes(ex_class) ); + #####: 352: SEXP condition = shelter( make_condition( ex_msg, call, cppstack, classes) ); + #####: 353: rcpp_set_stack_trace( R_NilValue ) ; + #####: 354: return condition ; + #####: 355:} +------------------ +_Z31exception_to_condition_templateISt9exceptionEP7SEXPRECRKT_b: + #####: 334:inline SEXP exception_to_condition_template( const Exception& ex, bool include_call) { + -: 335:#ifndef RCPP_NO_RTTI + #####: 336: std::string ex_class = demangle( typeid(ex).name() ) ; + -: 337:#else + -: 338: std::string ex_class = ""; + -: 339:#endif + #####: 340: std::string ex_msg = ex.what() ; + -: 341: + #####: 342: Rcpp::Shelter shelter; + -: 343: SEXP call, cppstack; + #####: 344: if (include_call) { + #####: 345: call = shelter(get_last_call()); + #####: 346: cppstack = shelter(rcpp_get_stack_trace()); + -: 347: } else { + #####: 348: call = R_NilValue; + #####: 349: cppstack = R_NilValue; + -: 350: } + #####: 351: SEXP classes = shelter( get_exception_classes(ex_class) ); + #####: 352: SEXP condition = shelter( make_condition( ex_msg, call, cppstack, classes) ); + #####: 353: rcpp_set_stack_trace( R_NilValue ) ; + #####: 354: return condition ; + #####: 355:} +------------------ +_Z31exception_to_condition_templateIN4Rcpp9exceptionEEP7SEXPRECRKT_b: + #####: 334:inline SEXP exception_to_condition_template( const Exception& ex, bool include_call) { + -: 335:#ifndef RCPP_NO_RTTI + #####: 336: std::string ex_class = demangle( typeid(ex).name() ) ; + -: 337:#else + -: 338: std::string ex_class = ""; + -: 339:#endif + #####: 340: std::string ex_msg = ex.what() ; + -: 341: + #####: 342: Rcpp::Shelter shelter; + -: 343: SEXP call, cppstack; + #####: 344: if (include_call) { + #####: 345: call = shelter(get_last_call()); + #####: 346: cppstack = shelter(rcpp_get_stack_trace()); + -: 347: } else { + #####: 348: call = R_NilValue; + #####: 349: cppstack = R_NilValue; + -: 350: } + #####: 351: SEXP classes = shelter( get_exception_classes(ex_class) ); + #####: 352: SEXP condition = shelter( make_condition( ex_msg, call, cppstack, classes) ); + #####: 353: rcpp_set_stack_trace( R_NilValue ) ; + #####: 354: return condition ; + #####: 355:} +------------------ + -: 356: + #####: 357:inline SEXP rcpp_exception_to_r_condition(const Rcpp::exception& ex) { + #####: 358: ex.copy_stack_trace_to_r(); + #####: 359: return exception_to_condition_template(ex, ex.include_call()); + -: 360:} + -: 361: + #####: 362:inline SEXP exception_to_r_condition( const std::exception& ex){ + #####: 363: return exception_to_condition_template(ex, RCPP_DEFAULT_INCLUDE_CALL); + -: 364:} + -: 365: + #####: 366:inline SEXP string_to_try_error( const std::string& str){ + -: 367: using namespace Rcpp; + -: 368: + -: 369: #ifndef RCPP_USING_UTF8_ERROR_STRING + #####: 370: Rcpp::Shield txt(Rf_mkString(str.c_str())); + #####: 371: Rcpp::Shield simpleErrorExpr(Rf_lang2(::Rf_install("simpleError"), txt)); + #####: 372: Rcpp::Shield tryError( Rf_mkString( str.c_str() ) ); + -: 373: #else + -: 374: Rcpp::Shield tryError( Rf_allocVector( STRSXP, 1 ) ) ; + -: 375: SET_STRING_ELT( tryError, 0, Rf_mkCharLenCE( str.c_str(), str.size(), CE_UTF8 ) ); + -: 376: Rcpp::Shield simpleErrorExpr( Rf_lang2(::Rf_install("simpleError"), tryError )); + -: 377: #endif + -: 378: + #####: 379: Rcpp::Shield simpleError( Rf_eval(simpleErrorExpr, R_GlobalEnv) ); + #####: 380: Rf_setAttrib( tryError, R_ClassSymbol, Rf_mkString("try-error") ) ; + #####: 381: Rf_setAttrib( tryError, Rf_install( "condition") , simpleError ) ; + -: 382: + #####: 383: return tryError; // #nocov end + #####: 384:} + -: 385: + -: 386:inline SEXP exception_to_try_error( const std::exception& ex){ + -: 387: return string_to_try_error(ex.what()); + -: 388:} + -: 389: + -: 390:std::string demangle( const std::string& name) ; + -: 391:#ifndef RCPP_NO_RTTI + -: 392:#define DEMANGLE(__TYPE__) demangle( typeid(__TYPE__).name() ).c_str() + -: 393:#endif + -: 394: + -: 395: + -: 396:inline void forward_exception_to_r(const std::exception& ex){ + -: 397: SEXP stop_sym = Rf_install( "stop" ) ; + -: 398: Rcpp::Shield condition( exception_to_r_condition(ex) ); + -: 399: Rcpp::Shield expr( Rf_lang2( stop_sym , condition ) ) ; + -: 400: Rf_eval( expr, R_GlobalEnv ) ; + -: 401:} + -: 402: + -: 403:inline void forward_rcpp_exception_to_r(const Rcpp::exception& ex) { + -: 404: SEXP stop_sym = Rf_install( "stop" ) ; + -: 405: Rcpp::Shield condition( exception_to_r_condition(ex) ); + -: 406: Rcpp::Shield expr( Rf_lang2( stop_sym , condition ) ) ; + -: 407: Rf_eval( expr, R_GlobalEnv ) ; + -: 408:} + -: 409: + -: 410: + -: 411:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#exceptions_impl.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#exceptions_impl.h.gcov new file mode 100644 index 0000000..26be858 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#exceptions_impl.h.gcov @@ -0,0 +1,106 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/exceptions_impl.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// exceptions_impl.h: Rcpp R/C++ interface class library -- exceptions + -: 2:// + -: 3:// Copyright (C) 2012 - 2019 Dirk Eddelbuettel and Romain Francois + -: 4:// Copyright (C) 2020 - 2024 Dirk Eddelbuettel, Romain Francois, and Joshua N. Pritikin + -: 5:// Copyright (C) 2025 Dirk Eddelbuettel, Romain Francois, Joshua N. Pritikin, and Iñaki Ucar + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21: + -: 22:#ifndef Rcpp__exceptions_impl__h + -: 23:#define Rcpp__exceptions_impl__h + -: 24: + -: 25:// enable demangler on platforms where execinfo.h is present + -: 26:#ifndef RCPP_DEMANGLER_ENABLED + -: 27:# define RCPP_DEMANGLER_ENABLED 0 + -: 28:# if defined __has_include + -: 29:# if __has_include () + -: 30:# include + -: 31:# undef RCPP_DEMANGLER_ENABLED + -: 32:# define RCPP_DEMANGLER_ENABLED 1 + -: 33:# endif + -: 34:# endif + -: 35:#endif + -: 36: + -: 37:namespace Rcpp { + -: 38: + -: 39: // Extract mangled name e.g. ./test(baz+0x14)[0x400962] + -: 40:#if RCPP_DEMANGLER_ENABLED + #####: 41: static inline std::string demangler_one(const char* input) { // #nocov start + -: 42: + #####: 43: static std::string buffer; + -: 44: + #####: 45: buffer = input; + #####: 46: size_t last_open = buffer.find_last_of('('); + #####: 47: size_t last_close = buffer.find_last_of(')'); + #####: 48: if (last_open == std::string::npos || + -: 49: last_close == std::string::npos) { + #####: 50: return input; // #nocov + -: 51: } + #####: 52: std::string function_name = buffer.substr(last_open + 1, last_close - last_open - 1); + -: 53: // Strip the +0x14 (if it exists, which it does not in earlier versions of gcc) + #####: 54: size_t function_plus = function_name.find_last_of('+'); + #####: 55: if (function_plus != std::string::npos) { + #####: 56: function_name.resize(function_plus); + -: 57: } + #####: 58: buffer.replace(last_open + 1, function_name.size(), demangle(function_name)); + -: 59: + #####: 60: return buffer; + -: 61: + #####: 62: } + -: 63:#endif + -: 64: + -: 65: // thread-safe; invoked prior to throwing the exception + #####: 66: inline void exception::record_stack_trace() + -: 67: { + -: 68:#if RCPP_DEMANGLER_ENABLED + -: 69: /* inspired from http://tombarta.wordpress.com/2008/08/01/c-stack-traces-with-gcc/ */ + #####: 70: const size_t max_depth = 100; + -: 71: int stack_depth; + -: 72: void *stack_addrs[max_depth]; + -: 73: + #####: 74: stack_depth = backtrace(stack_addrs, max_depth); + #####: 75: char **stack_strings = backtrace_symbols(stack_addrs, stack_depth); + -: 76: + #####: 77: std::transform(stack_strings + 1, stack_strings + stack_depth, + #####: 78: std::back_inserter(stack), demangler_one); + #####: 79: free(stack_strings); // malloc()ed by backtrace_symbols + -: 80:#endif + #####: 81: } + -: 82: + -: 83: // not thread-safe; invoked after catching the exception + #####: 84: inline void exception::copy_stack_trace_to_r() const + -: 85: { + #####: 86: if (!stack.size()) { + #####: 87: rcpp_set_stack_trace(R_NilValue); + #####: 88: return; + -: 89: } + -: 90: + #####: 91: CharacterVector res(stack.size()); + #####: 92: std::copy(stack.begin(), stack.end(), res.begin()); + #####: 93: List trace = List::create(_["file" ] = "", + #####: 94: _["line" ] = -1, + #####: 95: _["stack"] = res); + #####: 96: trace.attr("class") = "Rcpp_stack_trace"; + #####: 97: rcpp_set_stack_trace(trace); // #nocov end + #####: 98: } + -: 99: + -: 100:} + -: 101: + -: 102:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#Proxy_Iterator.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#Proxy_Iterator.h.gcov new file mode 100644 index 0000000..e84c869 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#Proxy_Iterator.h.gcov @@ -0,0 +1,153 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/internal/Proxy_Iterator.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1: + -: 2:// Proxy_Iterator.h: Rcpp R/C++ interface class library -- + -: 3:// + -: 4:// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois + -: 5:// + -: 6:// This file is part of Rcpp. + -: 7:// + -: 8:// Rcpp is free software: you can redistribute it and/or modify it + -: 9:// under the terms of the GNU General Public License as published by + -: 10:// the Free Software Foundation, either version 2 of the License, or + -: 11:// (at your option) any later version. + -: 12:// + -: 13:// Rcpp is distributed in the hope that it will be useful, but + -: 14:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 15:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 16:// GNU General Public License for more details. + -: 17:// + -: 18:// You should have received a copy of the GNU General Public License + -: 19:// along with Rcpp. If not, see . + -: 20: + -: 21:#ifndef Rcpp__internal__Proxy_Iterator__h + -: 22:#define Rcpp__internal__Proxy_Iterator__h + -: 23: + -: 24:namespace Rcpp{ + -: 25:namespace internal{ + -: 26: + -: 27:template + -: 28:class Proxy_Iterator { + -: 29:public: + -: 30: typedef PROXY& reference ; + -: 31: typedef PROXY* pointer ; + -: 32: typedef R_xlen_t difference_type ; + -: 33: typedef PROXY value_type; + -: 34: typedef std::random_access_iterator_tag iterator_category ; + -: 35: + -: 36: Proxy_Iterator( ): proxy(){} ; + #####: 37: Proxy_Iterator( const Proxy_Iterator& other) : proxy( other.proxy){} +------------------ +_ZN4Rcpp8internal14Proxy_IteratorINS0_13generic_proxyILi19ENS_15PreserveStorageEEEEC2ERKS5_: + #####: 37: Proxy_Iterator( const Proxy_Iterator& other) : proxy( other.proxy){} +------------------ +_ZN4Rcpp8internal14Proxy_IteratorINS0_12string_proxyILi16ENS_15PreserveStorageEEEEC2ERKS5_: + #####: 37: Proxy_Iterator( const Proxy_Iterator& other) : proxy( other.proxy){} +------------------ + #####: 38: Proxy_Iterator( const PROXY& proxy_ ) : proxy( proxy_ ){} ; +------------------ +_ZN4Rcpp8internal14Proxy_IteratorINS0_13generic_proxyILi19ENS_15PreserveStorageEEEEC2ERKS4_: + #####: 38: Proxy_Iterator( const PROXY& proxy_ ) : proxy( proxy_ ){} ; +------------------ +_ZN4Rcpp8internal14Proxy_IteratorINS0_12string_proxyILi16ENS_15PreserveStorageEEEEC2ERKS4_: + #####: 38: Proxy_Iterator( const PROXY& proxy_ ) : proxy( proxy_ ){} ; +------------------ + -: 39: + -: 40: Proxy_Iterator& operator=( const Proxy_Iterator& other ){ + -: 41: proxy.import( other.proxy ) ; + -: 42: return *this ; + -: 43: } + -: 44: + #####: 45: inline Proxy_Iterator& operator++(){ + #####: 46: proxy.move(1) ; + #####: 47: return *this ; + -: 48: } +------------------ +_ZN4Rcpp8internal14Proxy_IteratorINS0_12string_proxyILi16ENS_15PreserveStorageEEEEppEv: + #####: 45: inline Proxy_Iterator& operator++(){ + #####: 46: proxy.move(1) ; + #####: 47: return *this ; + -: 48: } +------------------ +_ZN4Rcpp8internal14Proxy_IteratorINS0_13generic_proxyILi19ENS_15PreserveStorageEEEEppEv: + #####: 45: inline Proxy_Iterator& operator++(){ + #####: 46: proxy.move(1) ; + #####: 47: return *this ; + -: 48: } +------------------ + -: 49: inline Proxy_Iterator operator++(int){ + -: 50: Proxy_Iterator orig(*this) ; + -: 51: ++(*this) ; + -: 52: return orig ; + -: 53: } + -: 54: + -: 55: inline Proxy_Iterator& operator--(){ + -: 56: proxy.move(-1) ; + -: 57: return *this ; + -: 58: } + -: 59: inline Proxy_Iterator operator--(int){ + -: 60: Proxy_Iterator orig(*this) ; + -: 61: --(*this) ; + -: 62: return orig ; + -: 63: } + -: 64: + -: 65: inline Proxy_Iterator operator+(difference_type n) const { + -: 66: return Proxy_Iterator( PROXY(*proxy.parent, proxy.index + n) ) ; + -: 67: } + -: 68: inline Proxy_Iterator operator-(difference_type n) const { + -: 69: return Proxy_Iterator( PROXY(*proxy.parent, proxy.index - n) ) ; + -: 70: } + -: 71: + -: 72: inline Proxy_Iterator& operator+=(difference_type n) { + -: 73: proxy.move( n ) ; + -: 74: return *this ; + -: 75: } + -: 76: inline Proxy_Iterator& operator-=(difference_type n) { + -: 77: proxy.move( -n ) ; + -: 78: return *this ; + -: 79: } + -: 80: + #####: 81: inline reference operator*() { + #####: 82: return proxy ; + -: 83: } + -: 84: inline pointer operator->(){ + -: 85: return &proxy ; + -: 86: } + -: 87: + -: 88: inline bool operator==( const Proxy_Iterator& y) const { + -: 89: return ( this->proxy.index == y.proxy.index ) && ( this->proxy.parent == y.proxy.parent ); + -: 90: } + -: 91: inline bool operator!=( const Proxy_Iterator& y) const { + -: 92: return ( this->proxy.index != y.proxy.index ) || ( this->proxy.parent != y.proxy.parent ); + -: 93: } + -: 94: inline bool operator<( const Proxy_Iterator& other ) const { + -: 95: return proxy.index < other.proxy.index ; + -: 96: } + -: 97: inline bool operator>( const Proxy_Iterator& other ) const { + -: 98: return proxy.index > other.proxy.index ; + -: 99: } + -: 100: inline bool operator<=( const Proxy_Iterator& other ) const { + -: 101: return proxy.index <= other.proxy.index ; + -: 102: } + -: 103: inline bool operator>=( const Proxy_Iterator& other ) const { + -: 104: return proxy.index >= other.proxy.index ; + -: 105: } + -: 106: + -: 107: inline difference_type operator-(const Proxy_Iterator& other) const { + -: 108: return proxy.index - other.proxy.index ; + -: 109: } + -: 110: + -: 111: inline int index() const { return proxy.index ; } + -: 112: + -: 113: inline PROXY operator[](R_xlen_t i) const { return PROXY(*proxy.parent, proxy.index + i) ; } + -: 114: + -: 115:private: + -: 116: PROXY proxy ; + -: 117:} ; + -: 118: + -: 119:} + -: 120:} + -: 121: + -: 122:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#caster.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#caster.h.gcov new file mode 100644 index 0000000..e1ab687 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#caster.h.gcov @@ -0,0 +1,71 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/internal/caster.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1: + -: 2:// caster.h: Rcpp R/C++ interface class library -- + -: 3:// + -: 4:// Copyright (C) 2010 - 2026 Dirk Eddelbuettel and Romain Francois + -: 5:// + -: 6:// This file is part of Rcpp. + -: 7:// + -: 8:// Rcpp is free software: you can redistribute it and/or modify it + -: 9:// under the terms of the GNU General Public License as published by + -: 10:// the Free Software Foundation, either version 2 of the License, or + -: 11:// (at your option) any later version. + -: 12:// + -: 13:// Rcpp is distributed in the hope that it will be useful, but + -: 14:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 15:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 16:// GNU General Public License for more details. + -: 17:// + -: 18:// You should have received a copy of the GNU General Public License + -: 19:// along with Rcpp. If not, see . + -: 20: + -: 21:#ifndef Rcpp__internal__caster__h + -: 22:#define Rcpp__internal__caster__h + -: 23: + -: 24:namespace Rcpp{ + -: 25:namespace internal{ + -: 26: + 135: 27:template TO caster(FROM from){ // #nocov start + 135: 28: return static_cast(from) ; + -: 29:} // #nocov end + -: 30: + -: 31:template + -: 32:inline Rcomplex Rcomplex_caster( std::complex from ){ + -: 33: Rcomplex cx ; + -: 34: cx.r = (double)from.real() ; + -: 35: cx.i = (double)from.imag() ; + -: 36: return cx ; + -: 37:} + -: 38: + -: 39:template <> + -: 40:inline Rcomplex caster, Rcomplex>( std::complex from){ + -: 41: return Rcomplex_caster(from) ; + -: 42:} + -: 43:template<> + -: 44:inline Rcomplex caster, Rcomplex>( std::complex from){ + -: 45: return Rcomplex_caster(from) ; + -: 46:} + -: 47: + -: 48:template + -: 49:inline std::complex std_complex_caster( Rcomplex from ){ + -: 50: return std::complex( static_cast(from.r), static_cast(from.i) ) ; + -: 51:} + -: 52: + -: 53:template <> + -: 54:inline std::complex caster >( Rcomplex from){ + -: 55: return std_complex_caster(from); + -: 56:} + -: 57: + -: 58:template<> + -: 59:inline std::complex caster >( Rcomplex from){ + -: 60: return std_complex_caster(from) ; + -: 61:} + -: 62: + -: 63: + -: 64:} + -: 65:} + -: 66: + -: 67:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#r_vector.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#r_vector.h.gcov new file mode 100644 index 0000000..567b6f3 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#r_vector.h.gcov @@ -0,0 +1,158 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/internal/r_vector.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- + -: 2:/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */ + -: 3:// + -: 4:// r_vector.h: Rcpp R/C++ interface class library -- information about R vectors + -: 5:// + -: 6:// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois + -: 7:// + -: 8:// This file is part of Rcpp. + -: 9:// + -: 10:// Rcpp is free software: you can redistribute it and/or modify it + -: 11:// under the terms of the GNU General Public License as published by + -: 12:// the Free Software Foundation, either version 2 of the License, or + -: 13:// (at your option) any later version. + -: 14:// + -: 15:// Rcpp is distributed in the hope that it will be useful, but + -: 16:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 17:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 18:// GNU General Public License for more details. + -: 19:// + -: 20:// You should have received a copy of the GNU General Public License + -: 21:// along with Rcpp. If not, see . + -: 22: + -: 23:#ifndef Rcpp__internal__r_vector_h + -: 24:#define Rcpp__internal__r_vector_h + -: 25: + -: 26:namespace Rcpp{ + -: 27:namespace internal{ + -: 28: + -: 29:template + -: 30:typename Rcpp::traits::storage_type::type* r_vector_start(SEXP x) { + -: 31: typedef typename Rcpp::traits::storage_type::type* pointer; + -: 32: return reinterpret_cast(dataptr(x)); + -: 33:} + -: 34: + -: 35:// add specializations to avoid use of dataptr + -: 36:#define RCPP_VECTOR_START_IMPL(__RTYPE__, __ACCESSOR__) \ + -: 37: template <> \ + -: 38: inline typename Rcpp::traits::storage_type<__RTYPE__>::type* r_vector_start<__RTYPE__>(SEXP x) { \ + -: 39: return __ACCESSOR__(x); \ + -: 40: } + -: 41: + 135: 42:RCPP_VECTOR_START_IMPL(LGLSXP, LOGICAL); + #####: 43:RCPP_VECTOR_START_IMPL(INTSXP, INTEGER); + -: 44:RCPP_VECTOR_START_IMPL(RAWSXP, RAW); + -: 45:RCPP_VECTOR_START_IMPL(CPLXSXP, COMPLEX); + -: 46:RCPP_VECTOR_START_IMPL(REALSXP, REAL); + -: 47: + -: 48:#undef RCPP_VECTOR_START_IMPL + -: 49: + -: 50:/** + -: 51: * The value 0 statically casted to the appropriate type for + -: 52: * the given SEXP type + -: 53: */ + -: 54:template // #nocov start + -: 55:inline CTYPE get_zero() { + -: 56: return static_cast(0); + -: 57:} // #nocov end + -: 58: + -: 59: + -: 60:/** + -: 61: * Specialization for Rcomplex + -: 62: */ + -: 63:template<> + -: 64:inline Rcomplex get_zero(){ + -: 65: Rcomplex x; + -: 66: x.r = 0.0; + -: 67: x.i = 0.0; + -: 68: return x; + -: 69:} + -: 70: + -: 71:/** + -: 72: * Initializes a vector of the given SEXP type. The template fills the + -: 73: * vector with the value 0 of the appropriate type, for example + -: 74: * an INTSXP vector is initialized with (int)0, etc... + -: 75: */ + -: 76:template void r_init_vector(SEXP x) { // #nocov start + -: 77: typedef typename ::Rcpp::traits::storage_type::type CTYPE; + -: 78: CTYPE* start=r_vector_start(x); + -: 79: std::fill(start, start + Rf_xlength(x), get_zero()); + -: 80:} // #nocov end + -: 81:/** + -: 82: * Initializes a generic vector (VECSXP). Does nothing since + -: 83: * R already initializes all elements to NULL + -: 84: */ + -: 85:template<> + #####: 86:inline void r_init_vector(SEXP /*x*/) {} + -: 87: + -: 88:/** + -: 89: * Initializes an expression vector (EXPRSXP). Does nothing since + -: 90: * R already initializes all elements to NULL + -: 91: */ + -: 92:template<> + -: 93:inline void r_init_vector(SEXP /*x*/) {} + -: 94: + -: 95:/** + -: 96: * Initializes a character vector (STRSXP). Does nothing since + -: 97: * R already initializes all elements to "" + -: 98: */ + -: 99:template<> + #####: 100:inline void r_init_vector(SEXP /*x*/) {} + -: 101: + -: 102: + -: 103:/** + -: 104: * We do not allow List(RTYPE=VECSXP), RawVector(RTYPE=RAWSXP) + -: 105: * or ExpressionVector(RTYPE=EXPRSXP) to be sorted, so it is + -: 106: * desirable to issue a compiler error if user attempts to sort + -: 107: * these types of Vectors. + -: 108: * + -: 109: * We declare a template class without defining the generic + -: 110: * class body, but complete the definition in specialization + -: 111: * of qualified Vector types. Hence when using this class + -: 112: * on unqualified Vectors, the compiler will emit errors. + -: 113: */ + -: 114:template + -: 115:class Sort_is_not_allowed_for_this_type; + -: 116: + -: 117:/** + -: 118: * Specialization for CPLXSXP, INTSXP, LGLSXP, REALSXP, and STRSXP + -: 119: */ + -: 120:template<> + -: 121:class Sort_is_not_allowed_for_this_type { + -: 122:public: + -: 123: static void do_nothing() {} + -: 124:}; + -: 125: + -: 126:template<> + -: 127:class Sort_is_not_allowed_for_this_type { + -: 128:public: + -: 129: static void do_nothing() {} + -: 130:}; + -: 131: + -: 132:template<> + -: 133:class Sort_is_not_allowed_for_this_type { + -: 134:public: + -: 135: static void do_nothing() {} + -: 136:}; + -: 137: + -: 138:template<> + -: 139:class Sort_is_not_allowed_for_this_type { + -: 140:public: + -: 141: static void do_nothing() {} + -: 142:}; + -: 143: + -: 144:template<> + -: 145:class Sort_is_not_allowed_for_this_type { + -: 146:public: + -: 147: static void do_nothing() {} + -: 148:}; + -: 149: + -: 150: + -: 151:} // internal + -: 152:} // Rcpp + -: 153: + -: 154:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#wrap.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#wrap.h.gcov new file mode 100644 index 0000000..288d56b --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#wrap.h.gcov @@ -0,0 +1,1032 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/internal/wrap.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- + -: 2:/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */ + -: 3:// + -: 4:// wrap.h: Rcpp R/C++ interface class library -- wrap implementations + -: 5:// + -: 6:// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois + -: 7:// + -: 8:// This file is part of Rcpp. + -: 9:// + -: 10:// Rcpp is free software: you can redistribute it and/or modify it + -: 11:// under the terms of the GNU General Public License as published by + -: 12:// the Free Software Foundation, either version 2 of the License, or + -: 13:// (at your option) any later version. + -: 14:// + -: 15:// Rcpp is distributed in the hope that it will be useful, but + -: 16:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 17:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 18:// GNU General Public License for more details. + -: 19:// + -: 20:// You should have received a copy of the GNU General Public License + -: 21:// along with Rcpp. If not, see . + -: 22: + -: 23:#ifndef Rcpp_internal_wrap_h + -: 24:#define Rcpp_internal_wrap_h + -: 25: + -: 26:#include + -: 27: + -: 28:// this is a private header, included in RcppCommon.h + -: 29:// don't include it directly + -: 30: + -: 31:namespace Rcpp { + -: 32: + -: 33: namespace RcppEigen { + -: 34: template SEXP eigen_wrap(const T& object); + -: 35: } + -: 36: + -: 37: template SEXP wrap(const T& object); + -: 38: + -: 39: template class CustomImporter; + -: 40: + -: 41: namespace internal { + -: 42: + -: 43: inline SEXP make_charsexp__impl__wstring(const wchar_t* data) { + -: 44: char* buffer = get_string_buffer(); + -: 45: wcstombs(buffer, data, MAXELTSIZE); + -: 46: return Rf_mkChar(buffer); + -: 47: } + -: 48: inline SEXP make_charsexp__impl__wstring(wchar_t data) { + -: 49: wchar_t x[2]; x[0] = data; x[1] = '\0'; + -: 50: char* buffer = get_string_buffer(); + -: 51: wcstombs(buffer, x, MAXELTSIZE); + -: 52: return Rf_mkChar(buffer); + -: 53: } + -: 54: inline SEXP make_charsexp__impl__wstring(const std::wstring& st) { + -: 55: return make_charsexp__impl__wstring(st.data()); + -: 56: } + #####: 57: inline SEXP make_charsexp__impl__cstring(const char* data) { + #####: 58: return Rf_mkChar(data); + -: 59: } + -: 60: inline SEXP make_charsexp__impl__cstring(char data) { + -: 61: char x[2]; x[0] = data; x[1] = '\0'; + -: 62: return Rf_mkChar(x); + -: 63: } + -: 64: + #####: 65: inline SEXP make_charsexp__impl__cstring(const std::string& st) { + #####: 66: return make_charsexp__impl__cstring(st.c_str()); + -: 67: } + -: 68: + -: 69:#if __cplusplus >= 201703L + -: 70: inline SEXP make_charsexp__impl__cstring(std::string_view st) { + -: 71: return Rf_mkCharLen(st.data(), static_cast(st.size())); + -: 72: } + -: 73:#endif + -: 74: + -: 75: template + -: 76: inline SEXP make_charsexp__impl(const T& s, Rcpp::traits::true_type) { + -: 77: return make_charsexp__impl__wstring(s); + -: 78: } + -: 79: + -: 80: template + #####: 81: inline SEXP make_charsexp__impl(const T& s, Rcpp::traits::false_type) { + #####: 82: return make_charsexp__impl__cstring(s); + -: 83: } + -: 84: + -: 85: template + #####: 86: inline SEXP make_charsexp(const T& s) { + #####: 87: return make_charsexp__impl(s, typename Rcpp::traits::is_wide_string::type()); + -: 88: } + -: 89: template <> + -: 90: inline SEXP make_charsexp(const Rcpp::String&); + -: 91: + -: 92: template SEXP range_wrap(InputIterator first, InputIterator last); + -: 93: template SEXP rowmajor_wrap(InputIterator first, int nrow, int ncol); + -: 94: + -: 95: // {{{ range wrap + -: 96: // {{{ unnamed range wrap + -: 97: + -: 98: /** + -: 99: * Range based primitive wrap implementation. used when + -: 100: * - T is a primitive type, indicated by the r_type_traits + -: 101: * - T needs a static_cast to be of the type suitable to fit in the R vector + -: 102: * + -: 103: * This produces an unnamed vector of the appropriate type using the + -: 104: * std::transform algorithm + -: 105: */ + -: 106: template + -: 107: inline SEXP primitive_range_wrap__impl(InputIterator first, InputIterator last, + -: 108: ::Rcpp::traits::true_type) { + -: 109: size_t size = std::distance(first, last); + -: 110: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 111: Shield x(Rf_allocVector(RTYPE, size)); + -: 112: std::transform(first, last, r_vector_start(x), caster< T, + -: 113: typename ::Rcpp::traits::storage_type::type >); + -: 114: return wrap_extra_steps(x); + -: 115: } + -: 116: + -: 117: template + -: 118: inline SEXP primitive_range_wrap__impl__nocast(InputIterator first, InputIterator last, + -: 119: std::random_access_iterator_tag) { + -: 120: size_t size = std::distance(first, last); + -: 121: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 122: Shield x(Rf_allocVector(RTYPE, size)); + -: 123: + -: 124: typedef typename ::Rcpp::traits::storage_type::type STORAGE; + -: 125: R_xlen_t __trip_count = size >> 2; + -: 126: STORAGE* start = r_vector_start(x); + -: 127: R_xlen_t i = 0; + -: 128: for (; __trip_count > 0; --__trip_count) { + -: 129: start[i] = first[i]; i++; + -: 130: start[i] = first[i]; i++; + -: 131: start[i] = first[i]; i++; + -: 132: start[i] = first[i]; i++; + -: 133: } + -: 134: switch (size - i) { + -: 135: case 3: + -: 136: start[i] = first[i]; i++; + -: 137: // fallthrough + -: 138: case 2: + -: 139: start[i] = first[i]; i++; + -: 140: // fallthrough + -: 141: case 1: + -: 142: start[i] = first[i]; i++; + -: 143: // fallthrough + -: 144: case 0: + -: 145: default: + -: 146: {} + -: 147: } + -: 148: + -: 149: return wrap_extra_steps(x); + -: 150: } + -: 151: + -: 152: template + -: 153: inline SEXP primitive_range_wrap__impl__nocast(InputIterator first, InputIterator last, + -: 154: std::input_iterator_tag) { + -: 155: size_t size = std::distance(first, last); + -: 156: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 157: Shield x(Rf_allocVector(RTYPE, size)); + -: 158: std::copy(first, last, r_vector_start(x)); + -: 159: return wrap_extra_steps(x); + -: 160: } + -: 161: + -: 162: /** + -: 163: * Range based primitive wrap implementation. used when : + -: 164: * - T is a primitive type + -: 165: * - T does not need a cast + -: 166: * + -: 167: * This produces an unnamed vector of the appropriate type using + -: 168: * the std::copy algorithm + -: 169: */ + -: 170: template + -: 171: inline SEXP primitive_range_wrap__impl(InputIterator first, InputIterator last, + -: 172: ::Rcpp::traits::false_type) { + -: 173: return primitive_range_wrap__impl__nocast(first, last, typename std::iterator_traits::iterator_category()); + -: 174: } + -: 175: + -: 176: + -: 177: /** + -: 178: * Range based wrap implementation that deals with iterator over + -: 179: * primitive types (int, double, etc ...) + -: 180: * + -: 181: * This produces an unnamed vector of the appropriate type + -: 182: */ + -: 183: template + -: 184: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_primitive_tag) { + -: 185: return primitive_range_wrap__impl(first, last, typename ::Rcpp::traits::r_sexptype_needscast()); + -: 186: } + -: 187: + -: 188: /** + -: 189: * range based wrap implementation that deals with iterators over + -: 190: * some type U. each U object is itself wrapped + -: 191: * + -: 192: * This produces an unnamed generic vector (list) + -: 193: */ + -: 194: template + -: 195: inline SEXP range_wrap_dispatch___generic(InputIterator first, InputIterator last) { + -: 196: size_t size = std::distance(first, last); + -: 197: Shield x(Rf_allocVector(VECSXP, size)); + -: 198: size_t i =0; + -: 199: while(i < size) { + -: 200: SET_VECTOR_ELT(x, i, ::Rcpp::wrap(*first)); + -: 201: i++; + -: 202: ++first; + -: 203: } + -: 204: return x; + -: 205: } + -: 206: + -: 207: template + -: 208: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_generic_tag) { + -: 209: return range_wrap_dispatch___generic(first, last); + -: 210: } + -: 211: + -: 212: // modules + -: 213: template + -: 214: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_module_object_pointer_tag) { + -: 215: return range_wrap_dispatch___generic(first, last); + -: 216: } + -: 217: template + -: 218: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_module_object_const_pointer_tag) { + -: 219: return range_wrap_dispatch___generic(first, last); + -: 220: } + -: 221: template + -: 222: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_module_object_tag) { + -: 223: return range_wrap_dispatch___generic(first, last); + -: 224: } + -: 225: template + -: 226: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_module_object_reference_tag) { + -: 227: return range_wrap_dispatch___generic(first, last); + -: 228: } + -: 229: template + -: 230: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_module_object_const_reference_tag) { + -: 231: return range_wrap_dispatch___generic(first, last); + -: 232: } + -: 233: + -: 234: + -: 235: + -: 236: /** + -: 237: * Range based wrap implementation for iterators over std::string + -: 238: * + -: 239: * This produces an unnamed character vector + -: 240: */ + -: 241: template + -: 242: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_string_tag) { + -: 243: size_t size = std::distance(first, last); + -: 244: Shield x(Rf_allocVector(STRSXP, size)); + -: 245: size_t i = 0; + -: 246: while(i < size) { + -: 247: SET_STRING_ELT(x, i, make_charsexp(*first)); + -: 248: i++; + -: 249: ++first; + -: 250: } + -: 251: return x; + -: 252: } + -: 253: + -: 254: // }}} + -: 255: + -: 256: // {{{ named range wrap + -: 257: + -: 258: /** + -: 259: * range based wrap implementation that deals with iterators over + -: 260: * pair where T is a primitive type : int, double ... + -: 261: * + -: 262: * This version is used when there is no need to cast T + -: 263: * + -: 264: * This produces a named R vector of the appropriate type + -: 265: */ + -: 266: template // #nocov start + -: 267: inline SEXP range_wrap_dispatch___impl__cast(InputIterator first, InputIterator last, ::Rcpp::traits::false_type) { + -: 268: size_t size = std::distance(first, last); + -: 269: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 270: Shield x(Rf_allocVector(RTYPE, size)); + -: 271: Shield names(Rf_allocVector(STRSXP, size)); + -: 272: typedef typename ::Rcpp::traits::storage_type::type CTYPE; + -: 273: CTYPE* start = r_vector_start(x); + -: 274: size_t i =0; + -: 275: std::string buf; + -: 276: for (; i(x); // #nocov end + -: 283: } + -: 284: + -: 285: /** + -: 286: * range based wrap implementation that deals with iterators over + -: 287: * pair where T is a primitive type : int, double ... + -: 288: * + -: 289: * This version is used when T needs to be cast to the associated R + -: 290: * type + -: 291: * + -: 292: * This produces a named R vector of the appropriate type + -: 293: */ + -: 294: template + -: 295: inline SEXP range_wrap_dispatch___impl__cast(InputIterator first, InputIterator last, ::Rcpp::traits::true_type) { + -: 296: size_t size = std::distance(first, last); + -: 297: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 298: Shield x(Rf_allocVector(RTYPE, size)); + -: 299: Shield names(Rf_allocVector(STRSXP, size)); + -: 300: typedef typename ::Rcpp::traits::storage_type::type CTYPE; + -: 301: CTYPE* start = r_vector_start(x); + -: 302: size_t i =0; + -: 303: std::string buf; + -: 304: for (; i(first->second); + -: 306: buf = first->first; + -: 307: SET_STRING_ELT(names, i, Rf_mkChar(buf.c_str())); + -: 308: } + -: 309: ::Rf_setAttrib(x, R_NamesSymbol, names); + -: 310: return wrap_extra_steps(x); + -: 311: } + -: 312: + -: 313: + -: 314: /** + -: 315: * range based wrap implementation that deals with iterators over + -: 316: * pair where T is a primitive type : int, double ... + -: 317: * + -: 318: * This dispatches further depending on whether the type needs + -: 319: * a cast to fit into the associated R type + -: 320: * + -: 321: * This produces a named R vector of the appropriate type + -: 322: */ + -: 323: template // #nocov start + -: 324: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_pairstring_primitive_tag) { + -: 325: return range_wrap_dispatch___impl__cast(first, last, + -: 326: typename ::Rcpp::traits::r_sexptype_needscast()); + -: 327: } // #nocov end + -: 328: + -: 329: /** + -: 330: * Range based wrap implementation that deals with iterators over + -: 331: * pair where U is wrappable. This is the kind of + -: 332: * iterators that are produced by map + -: 333: * + -: 334: * This produces a named generic vector (named list). The first + -: 335: * element of the list contains the result of a call to wrap on the + -: 336: * object of type U, etc ... + -: 337: * + -: 338: * The names are taken from the keys + -: 339: */ + -: 340: template + -: 341: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_pairstring_generic_tag) { + -: 342: size_t size = std::distance(first, last); + -: 343: Shield x(Rf_allocVector(VECSXP, size)); + -: 344: Shield names(Rf_allocVector(STRSXP, size)); + -: 345: size_t i =0; + -: 346: std::string buf; + -: 347: SEXP element = R_NilValue; + -: 348: while(i < size) { // #nocov start + -: 349: element = ::Rcpp::wrap(first->second); + -: 350: buf = first->first; + -: 351: SET_VECTOR_ELT(x, i, element); + -: 352: SET_STRING_ELT(names, i, Rf_mkChar(buf.c_str())); + -: 353: i++; + -: 354: ++first; + -: 355: } // #nocov end + -: 356: ::Rf_setAttrib(x, R_NamesSymbol, names); + -: 357: return x; + -: 358: } + -: 359: + -: 360: + -: 361: /** + -: 362: * Range based wrap for iterators over std::pair + -: 363: * + -: 364: * This is mainly used for wrapping map and friends + -: 365: * which happens to produce iterators over pair + -: 366: * + -: 367: * This produces a character vector containing copies of the + -: 368: * string iterated over. The names of the vector is set to the keys + -: 369: * of the pair + -: 370: */ + -: 371: template + -: 372: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_pairstring_string_tag) { + -: 373: size_t size = std::distance(first, last); + -: 374: Shield x(Rf_allocVector(STRSXP, size)); + -: 375: Shield names(Rf_allocVector(STRSXP, size)); + -: 376: for (size_t i = 0; i < size; i++, ++first) { + -: 377: SET_STRING_ELT(x, i, make_charsexp(first->second)); + -: 378: SET_STRING_ELT(names, i, make_charsexp(first->first)); + -: 379: } + -: 380: ::Rf_setAttrib(x, R_NamesSymbol, names); + -: 381: return x; + -: 382: } + -: 383: + -: 384: /** + -: 385: * iterating over pair + -: 386: * where VALUE is some primitive type + -: 387: */ + -: 388: template + -: 389: inline SEXP range_wrap_dispatch___impl__pair(InputIterator first, InputIterator last, Rcpp::traits::true_type); + -: 390: + -: 391: /** + -: 392: * iterating over pair + -: 393: * where VALUE is a type that needs wrapping + -: 394: */ + -: 395: template + -: 396: inline SEXP range_wrap_dispatch___impl__pair(InputIterator first, InputIterator last, Rcpp::traits::false_type); + -: 397: + -: 398: + -: 399: /** + -: 400: * Range wrap dispatch for iterators over std::pair + -: 401: */ + -: 402: template + -: 403: inline SEXP range_wrap_dispatch___impl(InputIterator first, InputIterator last, ::Rcpp::traits::r_type_pair_tag) { + -: 404: typedef typename T::second_type VALUE; + -: 405: typedef typename T::first_type KEY; + -: 406: + -: 407: return range_wrap_dispatch___impl__pair::rtype >(first, last, + -: 409: typename Rcpp::traits::is_primitive::type()); + -: 410: } + -: 411: + -: 412: // }}} + -: 413: + -: 414: /** + -: 415: * Dispatcher for all range based wrap implementations + -: 416: * + -: 417: * This uses the Rcpp::traits::r_type_traits to perform further dispatch + -: 418: */ + -: 419: template + -: 420: inline SEXP range_wrap_dispatch(InputIterator first, InputIterator last) { + -: 421: #if RCPP_DEBUG_LEVEL > 0 + -: 422: typedef typename ::Rcpp::traits::r_type_traits::r_category categ; + -: 423: #endif + -: 424: RCPP_DEBUG_3("range_wrap_dispatch< InputIterator = \n%s , T = %s, categ = %s>\n", DEMANGLE(InputIterator), DEMANGLE(T), DEMANGLE(categ)); + -: 425: return range_wrap_dispatch___impl(first, last, typename ::Rcpp::traits::r_type_traits::r_category()); + -: 426: } + -: 427: + -: 428: // we use the iterator trait to make the dispatch + -: 429: /** + -: 430: * range based wrap. This uses the std::iterator_traits class + -: 431: * to perform further dispatch + -: 432: */ + -: 433: template + -: 434: inline SEXP range_wrap(InputIterator first, InputIterator last) { + -: 435: return range_wrap_dispatch::value_type>::type >(first, last); + -: 436: } + -: 437: // }}} + -: 438: + -: 439: // {{{ primitive wrap (wrapping a single primitive value) + -: 440: + -: 441: /** + -: 442: * wraps a single primitive value when there is no need for a cast + -: 443: */ + -: 444: template + #####: 445: inline SEXP primitive_wrap__impl__cast(const T& object, ::Rcpp::traits::false_type) { + #####: 446: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + #####: 447: Shield x(Rf_allocVector(RTYPE, 1)); + #####: 448: r_vector_start(x)[0] = object; + #####: 449: return x; + #####: 450: } + -: 451: + -: 452: /** + -: 453: * wraps a single primitive value when a cast is needed + -: 454: */ + -: 455: template + -: 456: inline SEXP primitive_wrap__impl__cast(const T& object, ::Rcpp::traits::true_type) { + -: 457: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 458: typedef typename ::Rcpp::traits::storage_type::type STORAGE_TYPE; + -: 459: Shield x(Rf_allocVector(RTYPE, 1)); + -: 460: r_vector_start(x)[0] = caster(object); + -: 461: return x; + -: 462: } + -: 463: + -: 464: /** + -: 465: * primitive wrap for 'easy' primitive types: int, double, Rbyte, Rcomplex + -: 466: * + -: 467: * This produces a vector of length 1 of the appropriate type + -: 468: */ + -: 469: template + #####: 470: inline SEXP primitive_wrap__impl(const T& object, ::Rcpp::traits::r_type_primitive_tag) { + #####: 471: return primitive_wrap__impl__cast(object, typename ::Rcpp::traits::r_sexptype_needscast()); + -: 472: } + -: 473: + -: 474: /** + -: 475: * primitive wrap for types that can be converted implicitely to std::string or std::wstring + -: 476: * + -: 477: * This produces a character vector of length 1 containing the std::string or wstring + -: 478: */ + -: 479: template + -: 480: inline SEXP primitive_wrap__impl(const T& object, ::Rcpp::traits::r_type_string_tag) { + -: 481: Shield x(::Rf_allocVector(STRSXP, 1)); + -: 482: SET_STRING_ELT(x, 0, make_charsexp(object)); + -: 483: return x; + -: 484: } + -: 485: + -: 486: + -: 487: /** + -: 488: * called when T is a primitive type : int, bool, double, std::string, etc ... + -: 489: * This uses the Rcpp::traits::r_type_traits on the type T to perform + -: 490: * further dispatching and wrap the object into an vector of length 1 + -: 491: * of the appropriate SEXP type + -: 492: */ + -: 493: template + #####: 494: inline SEXP primitive_wrap(const T& object) { + #####: 495: return primitive_wrap__impl(object, typename ::Rcpp::traits::r_type_traits::r_category()); + -: 496: } + -: 497: // }}} + -: 498: + -: 499: // {{{ unknown + -: 500: /** + -: 501: * Called when the type T is known to be implicitely convertible to + -: 502: * SEXP. It uses the implicit conversion to SEXP to wrap the object + -: 503: * into a SEXP + -: 504: */ + -: 505: template + 270*: 506: inline SEXP wrap_dispatch_unknown(const T& object, ::Rcpp::traits::true_type) { + -: 507: RCPP_DEBUG_1("wrap_dispatch_unknown<%s>(., false )", DEMANGLE(T)) + -: 508: // here we know (or assume) that T is convertible to SEXP + 270*: 509: SEXP x = object; + 270*: 510: return x; + -: 511: } +------------------ +_ZN4Rcpp8internal21wrap_dispatch_unknownINS_6ShieldIP7SEXPRECEEEES4_RKT_NS_6traits17integral_constantIbLb1EEE: + #####: 506: inline SEXP wrap_dispatch_unknown(const T& object, ::Rcpp::traits::true_type) { + -: 507: RCPP_DEBUG_1("wrap_dispatch_unknown<%s>(., false )", DEMANGLE(T)) + -: 508: // here we know (or assume) that T is convertible to SEXP + #####: 509: SEXP x = object; + #####: 510: return x; + -: 511: } +------------------ +_ZN4Rcpp8internal21wrap_dispatch_unknownINS_6VectorILi16ENS_15PreserveStorageEEEEEP7SEXPRECRKT_NS_6traits17integral_constantIbLb1EEE: + #####: 506: inline SEXP wrap_dispatch_unknown(const T& object, ::Rcpp::traits::true_type) { + -: 507: RCPP_DEBUG_1("wrap_dispatch_unknown<%s>(., false )", DEMANGLE(T)) + -: 508: // here we know (or assume) that T is convertible to SEXP + #####: 509: SEXP x = object; + #####: 510: return x; + -: 511: } +------------------ +_ZN4Rcpp8internal21wrap_dispatch_unknownIP7SEXPRECEES3_RKT_NS_6traits17integral_constantIbLb1EEE: + 270: 506: inline SEXP wrap_dispatch_unknown(const T& object, ::Rcpp::traits::true_type) { + -: 507: RCPP_DEBUG_1("wrap_dispatch_unknown<%s>(., false )", DEMANGLE(T)) + -: 508: // here we know (or assume) that T is convertible to SEXP + 270: 509: SEXP x = object; + 270: 510: return x; + -: 511: } +------------------ + -: 512: + -: 513: /** + -: 514: * This is the worst case : + -: 515: * - not a primitive + -: 516: * - not implicitely convertible tp SEXP + -: 517: * - not iterable + -: 518: * + -: 519: * so we just give up and attempt to use static_assert to generate + -: 520: * a compile time message if it is available, otherwise we use + -: 521: * implicit conversion to SEXP to bomb the compiler, which will give + -: 522: * quite a cryptic message + -: 523: */ + -: 524: template + -: 525: inline SEXP wrap_dispatch_unknown_iterable(const T& object, ::Rcpp::traits::false_type) { + -: 526: RCPP_DEBUG_1("wrap_dispatch_unknown_iterable<%s>(., false )", DEMANGLE(T)) + -: 527: // here we know that T is not convertible to SEXP + -: 528: static_assert(!sizeof(T), "cannot convert type to SEXP"); + -: 529: return R_NilValue; // -Wall + -: 530: } + -: 531: + -: 532: template + -: 533: inline SEXP wrap_dispatch_unknown_iterable__logical(const T& object, ::Rcpp::traits::true_type) { + -: 534: RCPP_DEBUG_1("wrap_dispatch_unknown_iterable__logical<%s>(., true )", DEMANGLE(T)) + -: 535: size_t size = object.size(); + -: 536: Shield x(Rf_allocVector(LGLSXP, size)); + -: 537: std::copy(object.begin(), object.end(), LOGICAL(x)); + -: 538: return x; + -: 539: } + -: 540: + -: 541: template + -: 542: inline SEXP wrap_range_sugar_expression(const T& object, Rcpp::traits::false_type) { + -: 543: RCPP_DEBUG_1("wrap_range_sugar_expression<%s>(., false )", DEMANGLE(T)) + -: 544: return range_wrap(object.begin(), object.end()); + -: 545: } + -: 546: template + -: 547: inline SEXP wrap_range_sugar_expression(const T& object, Rcpp::traits::true_type); + -: 548: + -: 549: template + -: 550: inline SEXP wrap_dispatch_unknown_iterable__logical(const T& object, ::Rcpp::traits::false_type) { + -: 551: RCPP_DEBUG_1("wrap_dispatch_unknown_iterable__logical<%s>(., false )", DEMANGLE(T)) + -: 552: return wrap_range_sugar_expression(object, typename Rcpp::traits::is_sugar_expression::type()); + -: 553: } + -: 554: + -: 555: + -: 556: template + -: 557: inline SEXP wrap_dispatch_unknown_iterable__matrix_interface(const T& object, ::Rcpp::traits::false_type) { + -: 558: RCPP_DEBUG_1("wrap_dispatch_unknown_iterable__matrix_interface<%s>(., false )", DEMANGLE(T)) + -: 559: return wrap_dispatch_unknown_iterable__logical(object, + -: 560: typename ::Rcpp::traits::expands_to_logical::type()); + -: 561: } + -: 562: + -: 563: template + -: 564: inline SEXP wrap_dispatch_matrix_logical(const T& object, ::Rcpp::traits::true_type) { + -: 565: int nr = object.nrow(), nc = object.ncol(); + -: 566: Shield res(Rf_allocVector(LGLSXP, nr * nc)); + -: 567: int k=0; + -: 568: int* p = LOGICAL(res); + -: 569: for (int j=0; j dim(Rf_allocVector(INTSXP, 2)); + -: 573: INTEGER(dim)[0] = nr; + -: 574: INTEGER(dim)[1] = nc; + -: 575: Rf_setAttrib(res, R_DimSymbol , dim); + -: 576: return res; + -: 577: } + -: 578: + -: 579: template + -: 580: inline SEXP wrap_dispatch_matrix_primitive(const T& object) { + -: 581: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 582: int nr = object.nrow(), nc = object.ncol(); + -: 583: Shield res(Rf_allocVector(RTYPE, nr*nc)); + -: 584: + -: 585: int k=0; + -: 586: STORAGE* p = r_vector_start< RTYPE>(res); + -: 587: for (int j=0; j dim(Rf_allocVector(INTSXP, 2)); + -: 591: INTEGER(dim)[0] = nr; + -: 592: INTEGER(dim)[1] = nc; + -: 593: Rf_setAttrib(res, R_DimSymbol , dim); + -: 594: return res; + -: 595: } + -: 596: + -: 597: template + -: 598: inline SEXP wrap_dispatch_matrix_not_logical(const T& object, ::Rcpp::traits::r_type_primitive_tag) { + -: 599: return wrap_dispatch_matrix_primitive(object); + -: 600: } + -: 601: + -: 602: template + -: 603: inline SEXP wrap_dispatch_matrix_not_logical(const T& object, ::Rcpp::traits::r_type_string_tag) { + -: 604: int nr = object.nrow(), nc = object.ncol(); + -: 605: Shield res(Rf_allocVector(STRSXP, nr*nc)); + -: 606: + -: 607: int k=0; + -: 608: for (int j=0; j dim(Rf_allocVector(INTSXP, 2)); + -: 612: INTEGER(dim)[0] = nr; + -: 613: INTEGER(dim)[1] = nc; + -: 614: Rf_setAttrib(res, R_DimSymbol , dim); + -: 615: return res; + -: 616: } + -: 617: + -: 618: template + -: 619: inline SEXP wrap_dispatch_matrix_not_logical(const T& object, ::Rcpp::traits::r_type_generic_tag) { + -: 620: int nr = object.nrow(), nc = object.ncol(); + -: 621: Shield res(Rf_allocVector(VECSXP, nr*nc)); + -: 622: + -: 623: int k=0; + -: 624: for (int j=0; j dim(Rf_allocVector(INTSXP, 2)); + -: 628: INTEGER(dim)[0] = nr; + -: 629: INTEGER(dim)[1] = nc; + -: 630: Rf_setAttrib(res, R_DimSymbol , dim); + -: 631: return res; + -: 632: } + -: 633: + -: 634: template + -: 635: inline SEXP wrap_dispatch_matrix_logical(const T& object, ::Rcpp::traits::false_type) { + -: 636: return wrap_dispatch_matrix_not_logical(object, typename ::Rcpp::traits::r_type_traits::r_category()); + -: 637: } + -: 638: + -: 639: template + -: 640: inline SEXP wrap_dispatch_unknown_iterable__matrix_interface(const T& object, ::Rcpp::traits::true_type) { + -: 641: RCPP_DEBUG_1("wrap_dispatch_unknown_iterable__matrix_interface<%s>(., true )", DEMANGLE(T)) + -: 642: return wrap_dispatch_matrix_logical(object, typename ::Rcpp::traits::expands_to_logical::type()); + -: 643: } + -: 644: + -: 645: + -: 646: /** + -: 647: * Here we know for sure that type T has a T::iterator typedef + -: 648: * so we hope for the best and call the range based wrap with begin + -: 649: * and end + -: 650: * + -: 651: * This works fine for all stl containers and classes T that have : + -: 652: * - T::iterator + -: 653: * - T::iterator begin() + -: 654: * - T::iterator end() + -: 655: * + -: 656: * If someone knows a better way, please advise + -: 657: */ + -: 658: template + -: 659: inline SEXP wrap_dispatch_unknown_iterable(const T& object, ::Rcpp::traits::true_type) { + -: 660: RCPP_DEBUG_1("wrap_dispatch_unknown_iterable<%s>(., true )", DEMANGLE(T)) + -: 661: return wrap_dispatch_unknown_iterable__matrix_interface(object, + -: 662: typename ::Rcpp::traits::matrix_interface::type()); + -: 663: } + -: 664: + -: 665: template + -: 666: inline SEXP wrap_dispatch_importer__impl__prim(const T& object, ::Rcpp::traits::false_type) { + -: 667: int size = object.size(); + -: 668: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 669: Shield x(Rf_allocVector(RTYPE, size)); + -: 670: typedef typename ::Rcpp::traits::storage_type::type CTYPE; + -: 671: CTYPE* start = r_vector_start(x); + -: 672: for (int i=0; i + -: 680: inline SEXP wrap_dispatch_importer__impl__prim(const T& object, ::Rcpp::traits::true_type) { + -: 681: int size = object.size(); + -: 682: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 683: Shield x(Rf_allocVector(RTYPE, size)); + -: 684: typedef typename ::Rcpp::traits::storage_type::type CTYPE; + -: 685: CTYPE* start = r_vector_start(x); + -: 686: for (int i=0; i(object.get(i)); + -: 688: } + -: 689: return x; + -: 690: } + -: 691: + -: 692: template + -: 693: inline SEXP wrap_dispatch_importer__impl(const T& object, ::Rcpp::traits::r_type_primitive_tag) { + -: 694: return wrap_dispatch_importer__impl__prim(object, + -: 695: typename ::Rcpp::traits::r_sexptype_needscast()); + -: 696: } + -: 697: + -: 698: template + -: 699: inline SEXP wrap_dispatch_importer__impl(const T& object, ::Rcpp::traits::r_type_string_tag) { + -: 700: int size = object.size(); + -: 701: Shield x(Rf_allocVector(STRSXP, size)); + -: 702: for (int i=0; i + -: 709: inline SEXP wrap_dispatch_importer__impl(const T& object, ::Rcpp::traits::r_type_generic_tag) { + -: 710: int size = object.size(); + -: 711: Shield x(Rf_allocVector(VECSXP, size)); + -: 712: for (int i=0; i + -: 719: inline SEXP wrap_dispatch_importer(const T& object) { + -: 720: return wrap_dispatch_importer__impl(object, + -: 721: typename ::Rcpp::traits::r_type_traits::r_category()); + -: 722: } + -: 723: + -: 724: /** + -: 725: * Called when no implicit conversion to SEXP is possible and this is + -: 726: * not tagged as a primitive type, checks whether the type is + -: 727: * iterable + -: 728: */ + -: 729: template + -: 730: inline SEXP wrap_dispatch_unknown(const T& object, ::Rcpp::traits::false_type) { + -: 731: RCPP_DEBUG_1("wrap_dispatch_unknown<%s>(., false )", DEMANGLE(T)) + -: 732: return wrap_dispatch_unknown_iterable(object, typename ::Rcpp::traits::has_iterator::type()); + -: 733: } + -: 734: // }}} + -: 735: + -: 736: // {{{ wrap dispatch + -: 737: /** + -: 738: * wrapping a __single__ primitive type : int, double, std::string, size_t, + -: 739: * Rbyte, Rcomplex + -: 740: */ + -: 741: + -: 742: template + #####: 743: inline SEXP wrap_dispatch(const T& object, ::Rcpp::traits::wrap_type_primitive_tag) { + #####: 744: return primitive_wrap(object); + -: 745: } + -: 746: + -: 747: template + -: 748: inline SEXP wrap_dispatch(const T& object, ::Rcpp::traits::wrap_type_char_array) { + -: 749: return Rf_mkString(object); + -: 750: } + -: 751: + -: 752: template + -: 753: inline SEXP wrap_dispatch(const T& object, ::Rcpp::traits::wrap_type_module_object_pointer_tag) { + -: 754: return Rcpp::internal::make_new_object< typename T::object_type >(object.ptr); + -: 755: } + -: 756: + -: 757: template + -: 758: inline SEXP wrap_dispatch(const T& object, ::Rcpp::traits::wrap_type_module_object_tag) { + -: 759: return Rcpp::internal::make_new_object(new T(object)); + -: 760: } + -: 761: + -: 762: template + -: 763: inline SEXP wrap_dispatch(const T& object, ::Rcpp::traits::wrap_type_enum_tag) { + -: 764: return wrap((int)object); + -: 765: } + -: 766: + -: 767: template + 270*: 768: inline SEXP wrap_dispatch_eigen(const T& object, ::Rcpp::traits::false_type) { + -: 769: RCPP_DEBUG_1("wrap_dispatch_eigen<%s>(., false )", DEMANGLE(T)) + 270*: 770: return wrap_dispatch_unknown(object, typename ::Rcpp::traits::is_convertible::type()); + -: 771: } +------------------ +_ZN4Rcpp8internal19wrap_dispatch_eigenINS_6ShieldIP7SEXPRECEEEES4_RKT_NS_6traits17integral_constantIbLb0EEE: + #####: 768: inline SEXP wrap_dispatch_eigen(const T& object, ::Rcpp::traits::false_type) { + -: 769: RCPP_DEBUG_1("wrap_dispatch_eigen<%s>(., false )", DEMANGLE(T)) + #####: 770: return wrap_dispatch_unknown(object, typename ::Rcpp::traits::is_convertible::type()); + -: 771: } +------------------ +_ZN4Rcpp8internal19wrap_dispatch_eigenINS_6VectorILi16ENS_15PreserveStorageEEEEEP7SEXPRECRKT_NS_6traits17integral_constantIbLb0EEE: + #####: 768: inline SEXP wrap_dispatch_eigen(const T& object, ::Rcpp::traits::false_type) { + -: 769: RCPP_DEBUG_1("wrap_dispatch_eigen<%s>(., false )", DEMANGLE(T)) + #####: 770: return wrap_dispatch_unknown(object, typename ::Rcpp::traits::is_convertible::type()); + -: 771: } +------------------ +_ZN4Rcpp8internal19wrap_dispatch_eigenIP7SEXPRECEES3_RKT_NS_6traits17integral_constantIbLb0EEE: + 270: 768: inline SEXP wrap_dispatch_eigen(const T& object, ::Rcpp::traits::false_type) { + -: 769: RCPP_DEBUG_1("wrap_dispatch_eigen<%s>(., false )", DEMANGLE(T)) + 270: 770: return wrap_dispatch_unknown(object, typename ::Rcpp::traits::is_convertible::type()); + -: 771: } +------------------ + -: 772: + -: 773: template + -: 774: inline SEXP wrap_dispatch_eigen(const T& object, ::Rcpp::traits::true_type) { + -: 775: RCPP_DEBUG_1("wrap_dispatch_eigen<%s>(., true )", DEMANGLE(T)) + -: 776: return ::Rcpp::RcppEigen::eigen_wrap(object); + -: 777: } + -: 778: + -: 779: + -: 780: /** + -: 781: * called when T is wrap_type_unknown_tag and is not an Importer class + -: 782: * The next step is to try implicit conversion to SEXP + -: 783: */ + -: 784: template + 270*: 785: inline SEXP wrap_dispatch_unknown_importable(const T& object, ::Rcpp::traits::false_type) { + -: 786: RCPP_DEBUG_1("wrap_dispatch_unknown_importable<%s>(., false )", DEMANGLE(T)) + 270*: 787: return wrap_dispatch_eigen(object, typename traits::is_eigen_base::type()); + -: 788: } +------------------ +_ZN4Rcpp8internal32wrap_dispatch_unknown_importableINS_6ShieldIP7SEXPRECEEEES4_RKT_NS_6traits17integral_constantIbLb0EEE: + #####: 785: inline SEXP wrap_dispatch_unknown_importable(const T& object, ::Rcpp::traits::false_type) { + -: 786: RCPP_DEBUG_1("wrap_dispatch_unknown_importable<%s>(., false )", DEMANGLE(T)) + #####: 787: return wrap_dispatch_eigen(object, typename traits::is_eigen_base::type()); + -: 788: } +------------------ +_ZN4Rcpp8internal32wrap_dispatch_unknown_importableINS_6VectorILi16ENS_15PreserveStorageEEEEEP7SEXPRECRKT_NS_6traits17integral_constantIbLb0EEE: + #####: 785: inline SEXP wrap_dispatch_unknown_importable(const T& object, ::Rcpp::traits::false_type) { + -: 786: RCPP_DEBUG_1("wrap_dispatch_unknown_importable<%s>(., false )", DEMANGLE(T)) + #####: 787: return wrap_dispatch_eigen(object, typename traits::is_eigen_base::type()); + -: 788: } +------------------ +_ZN4Rcpp8internal32wrap_dispatch_unknown_importableIP7SEXPRECEES3_RKT_NS_6traits17integral_constantIbLb0EEE: + 270: 785: inline SEXP wrap_dispatch_unknown_importable(const T& object, ::Rcpp::traits::false_type) { + -: 786: RCPP_DEBUG_1("wrap_dispatch_unknown_importable<%s>(., false )", DEMANGLE(T)) + 270: 787: return wrap_dispatch_eigen(object, typename traits::is_eigen_base::type()); + -: 788: } +------------------ + -: 789: + -: 790: /** + -: 791: * called when T is an Importer + -: 792: */ + -: 793: template + -: 794: inline SEXP wrap_dispatch_unknown_importable(const T& object, ::Rcpp::traits::true_type) { + -: 795: RCPP_DEBUG_1("wrap_dispatch_unknown_importable<%s>(., true )", DEMANGLE(T)) + -: 796: return wrap_dispatch_importer(object); + -: 797: } + -: 798: + -: 799: /** + -: 800: * This is called by wrap when the wrap_type_traits is wrap_type_unknown_tag + -: 801: * + -: 802: * This tries to identify if the object conforms to the Importer class + -: 803: */ + -: 804: template + 270*: 805: inline SEXP wrap_dispatch(const T& object, ::Rcpp::traits::wrap_type_unknown_tag) { + -: 806: RCPP_DEBUG_1("wrap_dispatch<%s>(., wrap_type_unknown_tag)", DEMANGLE(T)) + 270*: 807: return wrap_dispatch_unknown_importable(object, typename ::Rcpp::traits::is_importer::type()); + -: 808: } +------------------ +_ZN4Rcpp8internal13wrap_dispatchINS_6ShieldIP7SEXPRECEEEES4_RKT_NS_6traits21wrap_type_unknown_tagE: + #####: 805: inline SEXP wrap_dispatch(const T& object, ::Rcpp::traits::wrap_type_unknown_tag) { + -: 806: RCPP_DEBUG_1("wrap_dispatch<%s>(., wrap_type_unknown_tag)", DEMANGLE(T)) + #####: 807: return wrap_dispatch_unknown_importable(object, typename ::Rcpp::traits::is_importer::type()); + -: 808: } +------------------ +_ZN4Rcpp8internal13wrap_dispatchINS_6VectorILi16ENS_15PreserveStorageEEEEEP7SEXPRECRKT_NS_6traits21wrap_type_unknown_tagE: + #####: 805: inline SEXP wrap_dispatch(const T& object, ::Rcpp::traits::wrap_type_unknown_tag) { + -: 806: RCPP_DEBUG_1("wrap_dispatch<%s>(., wrap_type_unknown_tag)", DEMANGLE(T)) + #####: 807: return wrap_dispatch_unknown_importable(object, typename ::Rcpp::traits::is_importer::type()); + -: 808: } +------------------ +_ZN4Rcpp8internal13wrap_dispatchIP7SEXPRECEES3_RKT_NS_6traits21wrap_type_unknown_tagE: + 270: 805: inline SEXP wrap_dispatch(const T& object, ::Rcpp::traits::wrap_type_unknown_tag) { + -: 806: RCPP_DEBUG_1("wrap_dispatch<%s>(., wrap_type_unknown_tag)", DEMANGLE(T)) + 270: 807: return wrap_dispatch_unknown_importable(object, typename ::Rcpp::traits::is_importer::type()); + -: 808: } +------------------ + -: 809: // }}} + -: 810: + -: 811: // {{{ wrap a container that is structured in row major order + -: 812: template + -: 813: inline SEXP rowmajor_wrap__dispatch(InputIterator first, int nrow, int ncol, ::Rcpp::traits::r_type_generic_tag) { + -: 814: Shield out(::Rf_allocVector(VECSXP, nrow * ncol)); + -: 815: int i=0, j=0; + -: 816: for (j=0; j dims(::Rf_allocVector(INTSXP, 2)); + -: 822: INTEGER(dims)[0] = nrow; + -: 823: INTEGER(dims)[1] = ncol; + -: 824: ::Rf_setAttrib(out, R_DimSymbol, dims); + -: 825: return out; + -: 826: } + -: 827: + -: 828: template + -: 829: inline SEXP rowmajor_wrap__dispatch(InputIterator first, int nrow, int ncol, ::Rcpp::traits::r_type_string_tag) { + -: 830: Shield out(::Rf_allocVector(STRSXP, nrow * ncol)); + -: 831: int i=0, j=0; + -: 832: for (j=0; j dims(::Rf_allocVector(INTSXP, 2)); + -: 838: INTEGER(dims)[0] = nrow; + -: 839: INTEGER(dims)[1] = ncol; + -: 840: ::Rf_setAttrib(out, R_DimSymbol, dims); + -: 841: return out; + -: 842: } + -: 843: + -: 844: template + -: 845: inline SEXP primitive_rowmajor_wrap__dispatch(InputIterator first, int nrow, int ncol, ::Rcpp::traits::false_type) { + -: 846: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 847: Shield out(::Rf_allocVector(RTYPE, nrow * ncol)); + -: 848: value_type* ptr = r_vector_start(out); + -: 849: int i=0, j=0; + -: 850: for (j=0; j dims(::Rf_allocVector(INTSXP, 2)); + -: 856: INTEGER(dims)[0] = nrow; + -: 857: INTEGER(dims)[1] = ncol; + -: 858: ::Rf_setAttrib(out, R_DimSymbol, dims); + -: 859: return out; + -: 860: } + -: 861: template + -: 862: inline SEXP primitive_rowmajor_wrap__dispatch(InputIterator first, int nrow, int ncol, ::Rcpp::traits::true_type) { + -: 863: const int RTYPE = ::Rcpp::traits::r_sexptype_traits::rtype; + -: 864: typedef typename ::Rcpp::traits::storage_type::type STORAGE; + -: 865: Shield out(::Rf_allocVector(RTYPE, nrow * ncol)); + -: 866: STORAGE* ptr = r_vector_start(out); + -: 867: int i=0, j=0; + -: 868: for (j=0; j(*first); + -: 871: } + -: 872: } + -: 873: Shield dims(::Rf_allocVector(INTSXP, 2)); + -: 874: INTEGER(dims)[0] = nrow; + -: 875: INTEGER(dims)[1] = ncol; + -: 876: ::Rf_setAttrib(out, R_DimSymbol, dims); + -: 877: return out; + -: 878: + -: 879: } + -: 880: + -: 881: template + -: 882: inline SEXP rowmajor_wrap__dispatch(InputIterator first, int nrow, int ncol, ::Rcpp::traits::r_type_primitive_tag) { + -: 883: return primitive_rowmajor_wrap__dispatch(first, nrow, ncol, typename ::Rcpp::traits::r_sexptype_needscast()); + -: 884: } + -: 885: + -: 886: template + -: 887: inline SEXP rowmajor_wrap(InputIterator first, int nrow, int ncol) { + -: 888: typedef typename std::iterator_traits::value_type VALUE_TYPE; + -: 889: return rowmajor_wrap__dispatch(first, nrow, ncol, typename ::Rcpp::traits::r_type_traits::r_category()); + -: 890: } + -: 891: // }}} + -: 892: + -: 893: } // internal + -: 894: + -: 895: /** + -: 896: * wraps an object of type T in a SEXP + -: 897: * + -: 898: * This method depends on the Rcpp::traits::wrap_type_traits trait + -: 899: * class to dispatch to the appropriate internal implementation + -: 900: * method + -: 901: * + -: 902: */ + -: 903: template + -: 904: inline SEXP wrap(const T& object); + -: 905: + -: 906: template <> inline SEXP wrap(const Rcpp::String& object); + -: 907: + -: 908: template + -: 909: inline SEXP module_wrap_dispatch(const T& obj, Rcpp::traits::void_wrap_tag) { + -: 910: return R_NilValue; + -: 911: } + -: 912: + -: 913: // these are defined in wrap_end.h + -: 914: template + -: 915: inline SEXP module_wrap_dispatch(const T& obj, Rcpp::traits::pointer_wrap_tag); + -: 916: + -: 917: template + -: 918: inline SEXP module_wrap_dispatch(const T& obj, Rcpp::traits::normal_wrap_tag); + -: 919: + -: 920: template + -: 921: inline SEXP module_wrap(const T& obj) { + -: 922: return module_wrap_dispatch(obj, typename Rcpp::traits::module_wrap_traits::category()); + -: 923: } + -: 924: template <> + -: 925: inline SEXP module_wrap(const SEXP& obj) { + -: 926: return obj; + -: 927: } + -: 928: + 135: 929: inline SEXP wrap(const char* const v) { + 135: 930: if (v != NULL) + 135: 931: return Rf_mkString(v); + -: 932: else + #####: 933: return R_NilValue; // #nocov + -: 934: } + -: 935: + -: 936: /** + -: 937: * Range based version of wrap + -: 938: */ + -: 939: template + -: 940: inline SEXP wrap(InputIterator first, InputIterator last) { + -: 941: return internal::range_wrap(first, last); + -: 942: } + -: 943: + -: 944:} // Rcpp + -: 945: + -: 946:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#wrap_end.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#wrap_end.h.gcov new file mode 100644 index 0000000..15d7900 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#internal#wrap_end.h.gcov @@ -0,0 +1,48 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/internal/wrap_end.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- + -: 2:// + -: 3:// wrap_end.h: R/C++ interface class library + -: 4:// + -: 5:// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21: + -: 22:#ifndef Rcpp_internal_wrap_end_h + -: 23:#define Rcpp_internal_wrap_end_h + -: 24: + -: 25:namespace Rcpp{ + -: 26: + -: 27: template + 270*: 28: inline SEXP wrap(const T& object){ + -: 29: RCPP_DEBUG_1( "inline SEXP wrap<%s>(const T& object)", DEMANGLE(T) ) + 270*: 30: return internal::wrap_dispatch( object, typename ::Rcpp::traits::wrap_type_traits::wrap_category() ) ; + -: 31: } + -: 32: + -: 33: template + -: 34: inline SEXP module_wrap_dispatch( const T& obj, Rcpp::traits::normal_wrap_tag ){ + -: 35: return wrap( obj ) ; + -: 36: } + -: 37: template + -: 38: inline SEXP module_wrap_dispatch( const T& obj, Rcpp::traits::pointer_wrap_tag ) { + -: 39: return wrap( object< typename traits::un_pointer::type >( obj ) ) ; + -: 40: } + -: 41:} + -: 42: + -: 43: + -: 44:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#iostream#Rstreambuf.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#iostream#Rstreambuf.h.gcov new file mode 100644 index 0000000..31d3384 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#iostream#Rstreambuf.h.gcov @@ -0,0 +1,112 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/iostream/Rstreambuf.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// + -: 2:// Rstreambuf.h: Rcpp R/C++ interface class library -- stream buffer + -: 3:// + -: 4:// Copyright (C) 2011 - 2020 Dirk Eddelbuettel, Romain Francois and Jelmer Ypma + -: 5:// Copyright (C) 2021 - 2023 Dirk Eddelbuettel, Romain Francois, Jelmer Ypma and Iñaki Ucar + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21: + -: 22:#ifndef RCPP__IOSTREAM__RSTREAMBUF_H + -: 23:#define RCPP__IOSTREAM__RSTREAMBUF_H + -: 24: + -: 25:#include + -: 26:#include + -: 27: + -: 28:namespace Rcpp { + -: 29: + -: 30: template + -: 31: class Rstreambuf : public std::streambuf { + -: 32: public: + 60: 33: Rstreambuf(){} +------------------ +_ZN4Rcpp10RstreambufILb0EEC2Ev: + 30: 33: Rstreambuf(){} +------------------ +_ZN4Rcpp10RstreambufILb1EEC2Ev: + 30: 33: Rstreambuf(){} +------------------ + -: 34: + -: 35: protected: + -: 36: virtual std::streamsize xsputn(const char *s, std::streamsize n); + -: 37: + -: 38: virtual int overflow(int c = traits_type::eof()); + -: 39: + -: 40: virtual int sync(); + -: 41: }; + -: 42: + -: 43: template + -: 44: class Rostream : public std::ostream { + -: 45: typedef Rstreambuf Buffer; + -: 46: Buffer buf; + -: 47: public: + 60: 48: Rostream() : std::ostream( &buf ) {} +------------------ +_ZN4Rcpp8RostreamILb0EEC1Ev: + 30: 48: Rostream() : std::ostream( &buf ) {} +------------------ +_ZN4Rcpp8RostreamILb1EEC1Ev: + 30: 48: Rostream() : std::ostream( &buf ) {} +------------------ + -: 49: }; + -: 50: // #nocov start + #####: 51: template <> inline std::streamsize Rstreambuf::xsputn(const char *s, std::streamsize num) { + #####: 52: Rprintf("%.*s", static_cast(num), s); + #####: 53: return num; + -: 54: } + #####: 55: template <> inline std::streamsize Rstreambuf::xsputn(const char *s, std::streamsize num) { + #####: 56: REprintf("%.*s", static_cast(num), s); + #####: 57: return num; + -: 58: } + -: 59: + #####: 60: template <> inline int Rstreambuf::overflow(int c) { + #####: 61: if (c != traits_type::eof()) { + #####: 62: char_type ch = traits_type::to_char_type(c); + #####: 63: return xsputn(&ch, 1) == 1 ? c : traits_type::eof(); + -: 64: } + #####: 65: return c; + -: 66: } + #####: 67: template <> inline int Rstreambuf::overflow(int c) { + #####: 68: if (c != traits_type::eof()) { + #####: 69: char_type ch = traits_type::to_char_type(c); + #####: 70: return xsputn(&ch, 1) == 1 ? c : traits_type::eof(); + -: 71: } + #####: 72: return c; + -: 73: } + -: 74: + #####: 75: template <> inline int Rstreambuf::sync() { + #####: 76: ::R_FlushConsole(); + #####: 77: return 0; + -: 78: } + #####: 79: template <> inline int Rstreambuf::sync() { + #####: 80: ::R_FlushConsole(); + #####: 81: return 0; + -: 82: } // #nocov end + -: 83: + -: 84:#ifdef RCPP_USE_GLOBAL_ROSTREAM + -: 85: extern Rostream& Rcout; + -: 86: extern Rostream& Rcerr; + -: 87:#else + -: 88: static Rostream Rcout; + -: 89: static Rostream Rcerr; + -: 90:#endif + -: 91: + -: 92:} + -: 93: + -: 94:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#protection#Shelter.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#protection#Shelter.h.gcov new file mode 100644 index 0000000..df31c41 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#protection#Shelter.h.gcov @@ -0,0 +1,51 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/protection/Shelter.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// Copyright (C) 2013 Romain Francois + -: 2:// + -: 3:// This file is part of Rcpp. + -: 4:// + -: 5:// Rcpp is free software: you can redistribute it and/or modify it + -: 6:// under the terms of the GNU General Public License as published by + -: 7:// the Free Software Foundation, either version 2 of the License, or + -: 8:// (at your option) any later version. + -: 9:// + -: 10:// Rcpp is distributed in the hope that it will be useful, but + -: 11:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 12:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 13:// GNU General Public License for more details. + -: 14:// + -: 15:// You should have received a copy of the GNU General Public License + -: 16:// along with Rcpp. If not, see . + -: 17: + -: 18:#ifndef Rcpp_protection_Shelter_H + -: 19:#define Rcpp_protection_Shelter_H + -: 20: + -: 21:namespace Rcpp { + -: 22: + -: 23: template + -: 24: class Shelter { + -: 25: public: + #####: 26: Shelter() : nprotected(0) {} + -: 27: + #####: 28: inline SEXP operator()(SEXP x) { + #####: 29: if (x != R_NilValue) nprotected++; + #####: 30: return Rcpp_protect(x); + -: 31: } + -: 32: + #####: 33: ~Shelter(){ + #####: 34: Rcpp_unprotect(nprotected); + #####: 35: nprotected = 0; + #####: 36: } + -: 37: + -: 38: private: + -: 39: int nprotected; + -: 40: + -: 41: // not defined on purpose + -: 42: Shelter(const Shelter&) ; + -: 43: Shelter& operator=(const Shelter&) ; + -: 44: }; + -: 45:} + -: 46: + -: 47:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#protection#Shield.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#protection#Shield.h.gcov new file mode 100644 index 0000000..22a1ff6 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#protection#Shield.h.gcov @@ -0,0 +1,58 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/protection/Shield.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// Copyright (C) 2013 Romain Francois and Kevin Ushey + -: 2:// + -: 3:// This file is part of Rcpp. + -: 4:// + -: 5:// Rcpp is free software: you can redistribute it and/or modify it + -: 6:// under the terms of the GNU General Public License as published by + -: 7:// the Free Software Foundation, either version 2 of the License, or + -: 8:// (at your option) any later version. + -: 9:// + -: 10:// Rcpp is distributed in the hope that it will be useful, but + -: 11:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 12:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 13:// GNU General Public License for more details. + -: 14:// + -: 15:// You should have received a copy of the GNU General Public License + -: 16:// along with Rcpp. If not, see . + -: 17: + -: 18:#ifndef Rcpp__protection_Shield_h + -: 19:#define Rcpp__protection_Shield_h + -: 20: + -: 21:namespace Rcpp{ + -: 22: + 2660: 23: inline SEXP Rcpp_protect(SEXP x){ + 2660: 24: if( x != R_NilValue ) PROTECT(x) ; + 2660: 25: return x ; + -: 26: } + -: 27: + 2660: 28: inline void Rcpp_unprotect(int i){ + -: 29: // Prefer this function over UNPROTECT() in Rcpp so that all + -: 30: // balance checks errors by rchk are contained at one location (#892) + 2660: 31: UNPROTECT(i); + 2660: 32: } + -: 33: + -: 34: template + -: 35: class Shield{ + -: 36: public: + 2660: 37: Shield( SEXP t_) : t(Rcpp_protect(t_)){} + 2660: 38: ~Shield(){ + 2660: 39: if( t != R_NilValue ) Rcpp_unprotect(1) ; + 2660: 40: } + -: 41: + 2660: 42: operator SEXP() const { return t; } + -: 43: SEXP t ; + -: 44: + -: 45: private: + -: 46: Shield( const Shield& ) ; + -: 47: Shield& operator=( const Shield& ) ; + -: 48: } ; + -: 49: + -: 50: + -: 51: + -: 52:} + -: 53: + -: 54:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#proxy#AttributeProxy.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#proxy#AttributeProxy.h.gcov new file mode 100644 index 0000000..7f56ef6 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#proxy#AttributeProxy.h.gcov @@ -0,0 +1,112 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/proxy/AttributeProxy.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// Copyright (C) 2013 Romain Francois + -: 2:// + -: 3:// This file is part of Rcpp. + -: 4:// + -: 5:// Rcpp is free software: you can redistribute it and/or modify it + -: 6:// under the terms of the GNU General Public License as published by + -: 7:// the Free Software Foundation, either version 2 of the License, or + -: 8:// (at your option) any later version. + -: 9:// + -: 10:// Rcpp is distributed in the hope that it will be useful, but + -: 11:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 12:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 13:// GNU General Public License for more details. + -: 14:// + -: 15:// You should have received a copy of the GNU General Public License + -: 16:// along with Rcpp. If not, see . + -: 17: + -: 18:#ifndef Rcpp_proxy_AttributeProxy_h + -: 19:#define Rcpp_proxy_AttributeProxy_h + -: 20: + -: 21:namespace Rcpp{ + -: 22: + -: 23:template + -: 24:class AttributeProxyPolicy { + -: 25:public: + -: 26: + -: 27: class AttributeProxy : public GenericProxy { + -: 28: public: + 135: 29: AttributeProxy( CLASS& v, const std::string& name) + 135: 30: : parent(v), attr_name(Rf_install(name.c_str())) + 135: 31: {} + -: 32: + -: 33: AttributeProxy& operator=(const AttributeProxy& rhs){ + -: 34: if( this != &rhs ) set( rhs.get() ) ; + -: 35: return *this ; + -: 36: } + -: 37: + -: 38: template AttributeProxy& operator=(const T& rhs); + -: 39: + -: 40: template operator T() const; + -: 41: + -: 42: inline operator SEXP() const; + -: 43: + -: 44: private: + -: 45: CLASS& parent; + -: 46: SEXP attr_name ; + -: 47: + -: 48: SEXP get() const { + -: 49: return Rf_getAttrib( parent, attr_name ) ; + -: 50: } + 135: 51: void set(SEXP x ){ + 135: 52: Rf_setAttrib( parent, attr_name, Shield(x) ) ; + 135: 53: } + -: 54: } ; + -: 55: + -: 56: class const_AttributeProxy : public GenericProxy { + -: 57: public: + -: 58: const_AttributeProxy( const CLASS& v, const std::string& name) + -: 59: : parent(v), attr_name(Rf_install(name.c_str())){} + -: 60: + -: 61: template operator T() const; + -: 62: inline operator SEXP() const; + -: 63: + -: 64: private: + -: 65: const CLASS& parent; + -: 66: SEXP attr_name ; + -: 67: + -: 68: SEXP get() const { + -: 69: return Rf_getAttrib( parent, attr_name ) ; + -: 70: } + -: 71: } ; + -: 72: + 135: 73: AttributeProxy attr( const std::string& name){ + 135: 74: return AttributeProxy( static_cast( *this ), name ) ; + -: 75: } + -: 76: const_AttributeProxy attr( const std::string& name) const { + -: 77: return const_AttributeProxy( static_cast( *this ), name ) ; + -: 78: } + -: 79: + -: 80: std::vector attributeNames() const { + -: 81: std::vector v; + -: 82:#if R_VERSION >= R_Version(4, 6, 0) + -: 83: auto visitor = [](SEXP name, SEXP attr, void* data) -> SEXP { + -: 84: std::vector* ptr = static_cast*>(data); + -: 85: std::string s{CHAR(Rf_asChar(name))}; + -: 86: ptr->push_back(s); + -: 87: return NULL; + -: 88: }; + -: 89: R_mapAttrib(static_cast(*this).get__(), visitor, static_cast(&v)); + -: 90:#else + -: 91: SEXP attrs = ATTRIB( static_cast(*this).get__()); + -: 92: while( attrs != R_NilValue ){ + -: 93: v.push_back( std::string(CHAR(PRINTNAME(TAG(attrs)))) ) ; + -: 94: attrs = CDR( attrs ) ; + -: 95: } + -: 96:#endif + -: 97: return v; + -: 98: } + -: 99: + -: 100: bool hasAttribute(const std::string& attr) const { + -: 101: return static_cast(*this).attr(attr) != R_NilValue; + -: 102: } + -: 103: + -: 104: + -: 105:} ; + -: 106: + -: 107:} + -: 108:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#r_cast.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#r_cast.h.gcov new file mode 100644 index 0000000..92b8909 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#r_cast.h.gcov @@ -0,0 +1,181 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/r_cast.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1: + -: 2:// rcast.h: Rcpp R/C++ interface class library -- cast from one SEXP type to another + -: 3:// + -: 4:// Copyright (C) 2010 - 2026 Dirk Eddelbuettel and Romain Francois + -: 5:// + -: 6:// This file is part of Rcpp. + -: 7:// + -: 8:// Rcpp is free software: you can redistribute it and/or modify it + -: 9:// under the terms of the GNU General Public License as published by + -: 10:// the Free Software Foundation, either version 2 of the License, or + -: 11:// (at your option) any later version. + -: 12:// + -: 13:// Rcpp is distributed in the hope that it will be useful, but + -: 14:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 15:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 16:// GNU General Public License for more details. + -: 17:// + -: 18:// You should have received a copy of the GNU General Public License + -: 19:// along with Rcpp. If not, see . + -: 20: + -: 21:#ifndef Rcpp_rcast_h + -: 22:#define Rcpp_rcast_h + -: 23: + -: 24:#include + -: 25: + -: 26:namespace Rcpp { + -: 27: namespace internal { + -: 28: + -: 29: inline SEXP convert_using_rfunction(SEXP x, const char* const fun) { // #nocov start + -: 30: Armor res; + -: 31: try{ + -: 32: SEXP funSym = Rf_install(fun); + -: 33: Shield call(Rf_lang2(funSym, x)); + -: 34: res = Rcpp_fast_eval(call, R_GlobalEnv); + -: 35: } catch( eval_error& e) { + -: 36: const char* fmt = "Could not convert using R function: %s."; + -: 37: throw not_compatible(fmt, fun); + -: 38: } + -: 39: return res; // #nocov end + -: 40: } + -: 41: + -: 42: // r_true_cast is only meant to be used when the target SEXP type + -: 43: // is different from the SEXP type of x + -: 44: template + -: 45: SEXP r_true_cast( SEXP x) { + -: 46: + -: 47: const char* fmt = "Not compatible conversion to target: " + -: 48: "[type=%s; target=%s]."; + -: 49: + -: 50: throw not_compatible(fmt, + -: 51: Rf_type2char(TYPEOF(x)), + -: 52: Rf_type2char(TARGET)); + -: 53: + -: 54: return x; // makes solaris happy + -: 55: } + -: 56: + -: 57: template + #####: 58: SEXP basic_cast( SEXP x) { // #nocov start + #####: 59: if( TYPEOF(x) == RTYPE ) return x; + #####: 60: switch( TYPEOF(x) ){ + #####: 61: case REALSXP: + -: 62: case RAWSXP: + -: 63: case LGLSXP: + -: 64: case CPLXSXP: + -: 65: case INTSXP: + #####: 66: return Rf_coerceVector(x, RTYPE); + #####: 67: default: + #####: 68: const char* fmt = "Not compatible with requested type: " + -: 69: "[type=%s; target=%s]."; + -: 70:#ifndef NDEBUG + -: 71: REprintf(fmt, + -: 72: Rf_type2char(TYPEOF(x)), + -: 73: Rf_type2char(RTYPE)); + -: 74: abort(); + -: 75:#else + #####: 76: throw ::Rcpp::not_compatible(fmt, + #####: 77: Rf_type2char(TYPEOF(x)), + #####: 78: Rf_type2char(RTYPE)); + -: 79:#endif + -: 80: } // #nocov end + -: 81: return R_NilValue; /* -Wall */ + -: 82: } + -: 83: + -: 84: template<> + -: 85: inline SEXP r_true_cast(SEXP x){ + -: 86: return basic_cast(x); + -: 87: } + -: 88: template<> + -: 89: inline SEXP r_true_cast(SEXP x){ // #nocov + -: 90: return basic_cast(x); // #nocov + -: 91: } + -: 92: template<> + -: 93: inline SEXP r_true_cast(SEXP x){ + -: 94: return basic_cast(x); + -: 95: } + -: 96: template<> + -: 97: inline SEXP r_true_cast(SEXP x){ + -: 98: return basic_cast(x); + -: 99: } + -: 100: template<> + #####: 101: inline SEXP r_true_cast(SEXP x){ // #nocov + #####: 102: return basic_cast(x); // #nocov + -: 103: } + -: 104: + -: 105: template <> + -: 106: inline SEXP r_true_cast(SEXP x){ // #nocov start + -: 107: switch( TYPEOF(x)) { + -: 108: case CPLXSXP: + -: 109: case RAWSXP: + -: 110: case LGLSXP: + -: 111: case REALSXP: + -: 112: case INTSXP: + -: 113: { + -: 114: // return Rf_coerceVector( x, STRSXP ); + -: 115: // coerceVector does not work for some reason + -: 116: Shield call( Rf_lang2( Rf_install( "as.character" ), x ) ); + -: 117: Shield res( Rcpp_fast_eval( call, R_GlobalEnv ) ); + -: 118: return res; + -: 119: } + -: 120: case CHARSXP: + -: 121: return Rf_ScalarString( x ); + -: 122: case SYMSXP: + -: 123: return Rf_ScalarString( PRINTNAME( x ) ); + -: 124: default: + -: 125: const char* fmt = "Not compatible with STRSXP: [type=%s]."; + -: 126:#ifndef NDEBUG + -: 127: REprintf(fmt, Rf_type2char(TYPEOF(x))); + -: 128: abort(); + -: 129:#else + -: 130: throw ::Rcpp::not_compatible(fmt, Rf_type2char(TYPEOF(x))); + -: 131:#endif + -: 132: } + -: 133: return R_NilValue; /* -Wall */ + -: 134: } + -: 135: template<> + -: 136: inline SEXP r_true_cast(SEXP x) { + -: 137: return convert_using_rfunction(x, "as.list"); // #nocov end + -: 138: } + -: 139: template<> + -: 140: inline SEXP r_true_cast(SEXP x) { + -: 141: return convert_using_rfunction(x, "as.expression" ); + -: 142: } + -: 143: template<> + -: 144: inline SEXP r_true_cast(SEXP x) { + -: 145: if (TYPEOF(x) == LANGSXP) { + -: 146: return Rf_cons(CAR(x), CDR(x)); + -: 147: } else { + -: 148: return convert_using_rfunction(x, "as.pairlist" ); + -: 149: } + -: 150: } + -: 151: template<> + -: 152: inline SEXP r_true_cast(SEXP x) { + -: 153: return convert_using_rfunction(x, "as.call" ); + -: 154: } + -: 155: + -: 156: } // namespace internal + -: 157: + 135: 158: template SEXP r_cast(SEXP x) { // #nocov start + 135: 159: if (TYPEOF(x) == TARGET) { + 135: 160: return x; + -: 161: } else { + -: 162: #ifdef RCPP_WARN_ON_COERCE + -: 163: Shield result( internal::r_true_cast(x) ); + -: 164: ::Rcpp::warning("Coerced object from '%s' to '%s'.", + -: 165: Rf_type2char(TYPEOF(x)), + -: 166: Rf_type2char(TARGET) + -: 167: ); + -: 168: return result; + -: 169: #else + #####: 170: return internal::r_true_cast(x); // #nocov end + -: 171: #endif + -: 172: } + -: 173: } + -: 174: + -: 175:} // namespace Rcpp + -: 176: + -: 177:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#routines.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#routines.h.gcov new file mode 100644 index 0000000..55a02a1 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#routines.h.gcov @@ -0,0 +1,319 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/routines.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1: + -: 2:// routines.h: Rcpp R/C++ interface class library -- callable function setup + -: 3:// + -: 4:// Copyright (C) 2013 - 2014 Romain Francois + -: 5:// Copyright (C) 2015 - 2020 Romain Francois and Dirk Eddelbuettel + -: 6:// Copyright (C) 2021 Romain Francois, Dirk Eddelbuettel and Iñaki Ucar + -: 7:// + -: 8:// This file is part of Rcpp. + -: 9:// + -: 10:// Rcpp is free software: you can redistribute it and/or modify it + -: 11:// under the terms of the GNU General Public License as published by + -: 12:// the Free Software Foundation, either version 2 of the License, or + -: 13:// (at your option) any later version. + -: 14:// + -: 15:// Rcpp is distributed in the hope that it will be useful, but + -: 16:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 17:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 18:// GNU General Public License for more details. + -: 19:// + -: 20:// You should have received a copy of the GNU General Public License + -: 21:// along with Rcpp. If not, see . + -: 22: + -: 23:#ifndef RCPP_ROUTINE_H + -: 24:#define RCPP_ROUTINE_H + -: 25: + -: 26:#include + -: 27: + -: 28:#if defined(COMPILING_RCPP) + -: 29: + -: 30:// the idea is that this file should be generated automatically by Rcpp::register + -: 31: + -: 32:namespace Rcpp{ + -: 33: const char* type2name(SEXP x); + -: 34: + -: 35: namespace internal{ + -: 36: unsigned long enterRNGScope(); + -: 37: unsigned long exitRNGScope(); + -: 38: unsigned long beginSuspendRNGSynchronization(); + -: 39: unsigned long endSuspendRNGSynchronization(); + -: 40: char* get_string_buffer(); + -: 41: SEXP get_Rcpp_namespace(); + -: 42: } + -: 43: double mktime00(struct tm &); + -: 44: struct tm * gmtime_(const time_t * const); + -: 45: + -: 46: void Rcpp_precious_init(); + -: 47: void Rcpp_precious_teardown(); + -: 48: SEXP Rcpp_precious_preserve(SEXP object); + -: 49: void Rcpp_precious_remove(SEXP token); + -: 50: + -: 51: Rostream& Rcpp_cout_get(); + -: 52: Rostream& Rcpp_cerr_get(); + -: 53:} + -: 54: + -: 55:SEXP rcpp_get_stack_trace(); + -: 56:SEXP rcpp_set_stack_trace(SEXP); + -: 57:std::string demangle(const std::string& name); + -: 58:const char* short_file_name(const char* ); + -: 59:int* get_cache(int n); + -: 60:SEXP stack_trace( const char *file = "", int line = -1); + -: 61:SEXP get_string_elt(SEXP s, R_xlen_t i); + -: 62:const char* char_get_string_elt(SEXP s, R_xlen_t i); + -: 63:void set_string_elt(SEXP s, R_xlen_t i, SEXP v); + -: 64:void char_set_string_elt(SEXP s, R_xlen_t i, const char* v); + -: 65:SEXP* get_string_ptr(SEXP s); + -: 66:SEXP get_vector_elt(SEXP v, R_xlen_t i); + -: 67:void set_vector_elt(SEXP v, R_xlen_t i, SEXP x); + -: 68:SEXP* get_vector_ptr(SEXP v); + -: 69:const char* char_nocheck(SEXP x); + -: 70:void* dataptr(SEXP x); + -: 71:Rcpp::Module* getCurrentScope(); + -: 72:void setCurrentScope( Rcpp::Module* mod ); + -: 73:SEXP reset_current_error(); + -: 74:int error_occured(); + -: 75:SEXP rcpp_get_current_error(); + -: 76:// void print(SEXP s); + -: 77: + -: 78:#else + -: 79: + -: 80:namespace Rcpp { + -: 81: + -: 82: #define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ ) + -: 83: + -: 84: inline attribute_hidden const char* type2name(SEXP x){ + -: 85: typedef const char* (*Fun)(SEXP); + -: 86: static Fun fun = GET_CALLABLE("type2name"); + -: 87: return fun(x); + -: 88: } + -: 89: + -: 90: namespace internal{ + 135: 91: inline attribute_hidden unsigned long enterRNGScope(){ + -: 92: typedef unsigned long (*Fun)(void); + 135: 93: static Fun fun = GET_CALLABLE("enterRNGScope"); + 135: 94: return fun(); + -: 95: } + -: 96: + 135: 97: inline attribute_hidden unsigned long exitRNGScope(){ + -: 98: typedef unsigned long (*Fun)(void); + 135: 99: static Fun fun = GET_CALLABLE("exitRNGScope"); + 135: 100: return fun(); + -: 101: } + -: 102: + -: 103: inline attribute_hidden unsigned long beginSuspendRNGSynchronization(){ + -: 104: typedef unsigned long (*Fun)(void); + -: 105: static Fun fun = GET_CALLABLE("beginSuspendRNGSynchronization"); + -: 106: return fun(); + -: 107: } + -: 108: + -: 109: inline attribute_hidden unsigned long endSuspendRNGSynchronization(){ + -: 110: typedef unsigned long (*Fun)(void); + -: 111: static Fun fun = GET_CALLABLE("endSuspendRNGSynchronization"); + -: 112: return fun(); + -: 113: } + -: 114: + -: 115: inline attribute_hidden char* get_string_buffer(){ + -: 116: typedef char* (*Fun)(void); + -: 117: static Fun fun = GET_CALLABLE("get_string_buffer"); + -: 118: return fun(); + -: 119: } + -: 120: + -: 121: inline attribute_hidden SEXP get_Rcpp_namespace() { + -: 122: typedef SEXP (*Fun)(void); + -: 123: static Fun fun = GET_CALLABLE("get_Rcpp_namespace"); + -: 124: return fun(); + -: 125: } + -: 126: + -: 127: } + -: 128: + -: 129: + -: 130: inline attribute_hidden double mktime00(struct tm &tm){ + -: 131: typedef double (*Fun)(struct tm&); + -: 132: static Fun fun = GET_CALLABLE("mktime00"); + -: 133: return fun(tm); + -: 134: } + -: 135: + -: 136: inline attribute_hidden struct tm * gmtime_(const time_t * const x){ + -: 137: typedef struct tm* (*Fun)(const time_t* const); + -: 138: static Fun fun = GET_CALLABLE("gmtime_"); + -: 139: return fun(x); + -: 140: } + -: 141: + -: 142: inline attribute_hidden void Rcpp_precious_init() { + -: 143: typedef void (*Fun)(void); + -: 144: static Fun fun = GET_CALLABLE("Rcpp_precious_init"); + -: 145: fun(); + -: 146: } + -: 147: inline attribute_hidden void Rcpp_precious_teardown() { + -: 148: typedef void (*Fun)(void); + -: 149: static Fun fun = GET_CALLABLE("Rcpp_precious_teardown"); + -: 150: fun(); + -: 151: } + 3720: 152: inline attribute_hidden SEXP Rcpp_precious_preserve(SEXP object) { + -: 153: typedef SEXP (*Fun)(SEXP); + 3720: 154: static Fun fun = GET_CALLABLE("Rcpp_precious_preserve"); + 3720: 155: return fun(object); + -: 156: } + 6380: 157: inline attribute_hidden void Rcpp_precious_remove(SEXP token) { + -: 158: typedef void (*Fun)(SEXP); + 6380: 159: static Fun fun = GET_CALLABLE("Rcpp_precious_remove"); + 6380: 160: fun(token); + 6380: 161: } + -: 162: + -: 163: inline attribute_hidden Rostream& Rcpp_cout_get() { + -: 164: typedef Rostream& (*Fun)(); + -: 165: static Fun fun = GET_CALLABLE("Rcpp_cout_get"); + -: 166: return fun(); + -: 167: } + -: 168: inline attribute_hidden Rostream& Rcpp_cerr_get() { + -: 169: typedef Rostream& (*Fun)(); + -: 170: static Fun fun = GET_CALLABLE("Rcpp_cerr_get"); + -: 171: return fun(); + -: 172: } + -: 173: + -: 174:} + -: 175: + -: 176:// The 'attribute_hidden' used here is a simple precessor defined from + -: 177:// ${R_HOME}/include/R_ext/Visibility.h -- it is empty when not supported + -: 178:// by the compiler and otherwise '__attribute__ ((visibility ("hidden")))' + -: 179: + #####: 180:inline attribute_hidden SEXP rcpp_get_stack_trace(){ + -: 181: typedef SEXP (*Fun)(void); + #####: 182: static Fun fun = GET_CALLABLE("rcpp_get_stack_trace"); + #####: 183: return fun(); + -: 184:} + -: 185: + #####: 186:inline attribute_hidden SEXP rcpp_set_stack_trace(SEXP e){ + -: 187: typedef SEXP (*Fun)(SEXP); + #####: 188: static Fun fun = GET_CALLABLE("rcpp_set_stack_trace"); + #####: 189: return fun(e); + -: 190:} + -: 191: + #####: 192:inline attribute_hidden std::string demangle( const std::string& name){ + -: 193: typedef std::string (*Fun)( const std::string& ); + #####: 194: static Fun fun = GET_CALLABLE("demangle"); + #####: 195: return fun(name); + -: 196:} + -: 197: + -: 198:inline attribute_hidden const char* short_file_name(const char* file) { + -: 199: typedef const char* (*Fun)(const char*); + -: 200: static Fun fun = GET_CALLABLE("short_file_name"); + -: 201: return fun(file); + -: 202:} + -: 203: + -: 204:inline attribute_hidden SEXP stack_trace( const char *file = "", int line = -1){ + -: 205: typedef SEXP (*Fun)(const char*, int); + -: 206: static Fun fun = GET_CALLABLE("stack_trace"); + -: 207: return fun(file, line); + -: 208:} + -: 209: + -: 210:inline attribute_hidden SEXP get_string_elt(SEXP s, R_xlen_t i){ + -: 211: typedef SEXP (*Fun)(SEXP, R_xlen_t); + -: 212: static Fun fun = GET_CALLABLE("get_string_elt"); + -: 213: return fun(s, i); + -: 214:} + -: 215: + -: 216:inline attribute_hidden const char* char_get_string_elt(SEXP s, R_xlen_t i){ + -: 217: typedef const char* (*Fun)(SEXP, R_xlen_t); + -: 218: static Fun fun = GET_CALLABLE("char_get_string_elt"); + -: 219: return fun(s, i); + -: 220:} + -: 221: + -: 222:inline attribute_hidden void set_string_elt(SEXP s, R_xlen_t i, SEXP v){ + -: 223: typedef void (*Fun)(SEXP, R_xlen_t, SEXP); + -: 224: static Fun fun = GET_CALLABLE("set_string_elt"); + -: 225: fun(s, i, v); + -: 226:} + -: 227: + -: 228:inline attribute_hidden void char_set_string_elt(SEXP s, R_xlen_t i, const char* v){ + -: 229: typedef void (*Fun)(SEXP, R_xlen_t, const char*); + -: 230: static Fun fun = GET_CALLABLE("char_set_string_elt"); + -: 231: fun(s, i, v ); + -: 232:} + -: 233: + -: 234:inline attribute_hidden SEXP* get_string_ptr(SEXP s){ + -: 235: typedef SEXP* (*Fun)(SEXP); + -: 236: static Fun fun = GET_CALLABLE("get_string_ptr"); + -: 237: return fun(s); + -: 238:} + -: 239: + -: 240:inline attribute_hidden SEXP get_vector_elt(SEXP v, R_xlen_t i){ + -: 241: typedef SEXP (*Fun)(SEXP, R_xlen_t); + -: 242: static Fun fun = GET_CALLABLE("get_vector_elt"); + -: 243: return fun(v, i); + -: 244:} + -: 245: + -: 246:inline attribute_hidden void set_vector_elt(SEXP v, R_xlen_t i, SEXP x){ + -: 247: typedef void (*Fun)(SEXP, R_xlen_t, SEXP); + -: 248: static Fun fun = GET_CALLABLE("set_vector_elt"); + -: 249: fun(v, i, x); + -: 250:} + -: 251: + -: 252:inline attribute_hidden SEXP* get_vector_ptr(SEXP v){ + -: 253: typedef SEXP* (*Fun)(SEXP); + -: 254: static Fun fun = GET_CALLABLE("get_vector_ptr"); + -: 255: return fun(v); + -: 256:} + -: 257: + -: 258:inline attribute_hidden const char* char_nocheck( SEXP x){ + -: 259: typedef const char* (*Fun)(SEXP); + -: 260: static Fun fun = GET_CALLABLE("char_nocheck"); + -: 261: return fun(x); + -: 262:} + -: 263: + -: 264:inline attribute_hidden void* dataptr(SEXP x){ + -: 265: typedef void* (*Fun)(SEXP); + -: 266: static Fun fun = GET_CALLABLE("dataptr"); + -: 267: return fun(x); + -: 268:} + -: 269: + -: 270:inline attribute_hidden Rcpp::Module* getCurrentScope(){ + -: 271: typedef Rcpp::Module* (*Fun)(void); + -: 272: static Fun fun = GET_CALLABLE("getCurrentScope"); + -: 273: return fun(); + -: 274:} + -: 275: + -: 276:inline attribute_hidden void setCurrentScope( Rcpp::Module* mod ){ + -: 277: typedef void (*Fun)(Rcpp::Module*); + -: 278: static Fun fun = GET_CALLABLE("setCurrentScope"); + -: 279: fun(mod); + -: 280:} + -: 281: + -: 282:inline attribute_hidden int* get_cache( int n ){ + -: 283: typedef int* (*Fun)(int); + -: 284: static Fun fun = GET_CALLABLE("get_cache"); + -: 285: return fun(n); + -: 286:} + -: 287: + -: 288:inline attribute_hidden SEXP reset_current_error(){ + -: 289: typedef SEXP (*Fun)(void); + -: 290: static Fun fun = GET_CALLABLE("reset_current_error"); + -: 291: return fun(); + -: 292:} + -: 293: + -: 294:inline attribute_hidden int error_occured(){ + -: 295: typedef int (*Fun)(void); + -: 296: static Fun fun = GET_CALLABLE("error_occured"); + -: 297: return fun(); + -: 298:} + -: 299: + -: 300:inline attribute_hidden SEXP rcpp_get_current_error(){ + -: 301: typedef SEXP (*Fun)(void); + -: 302: static Fun fun = GET_CALLABLE("rcpp_get_current_error"); + -: 303: return fun(); + -: 304:} + -: 305: + -: 306:// inline attribute_hidden void print(SEXP s) { + -: 307:// typedef void (*Fun)(SEXP); + -: 308:// static Fun fun = GET_CALLABLE("print"); + -: 309:// fun(s); + -: 310:// } + -: 311: + -: 312:#endif + -: 313: + -: 314: + -: 315:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#storage#PreserveStorage.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#storage#PreserveStorage.h.gcov new file mode 100644 index 0000000..a4792bc --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#storage#PreserveStorage.h.gcov @@ -0,0 +1,181 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/storage/PreserveStorage.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1: + -: 2:// PreserveStorage.h: Rcpp R/C++ interface class library -- helper class + -: 3:// + -: 4:// Copyright (C) 2013 - 2020 Romain Francois + -: 5:// Copyright (C) 2021 Romain Francois and Iñaki Ucar + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21: + -: 22:#ifndef Rcpp_PreserveStorage_h + -: 23:#define Rcpp_PreserveStorage_h + -: 24: + -: 25:namespace Rcpp{ + -: 26: + -: 27: template + -: 28: class PreserveStorage { + -: 29: public: + -: 30: + 405*: 31: PreserveStorage() : data(R_NilValue), token(R_NilValue){} +------------------ +_ZN4Rcpp15PreserveStorageINS_12RObject_ImplIS0_EEEC2Ev: + 135: 31: PreserveStorage() : data(R_NilValue), token(R_NilValue){} +------------------ +_ZN4Rcpp15PreserveStorageINS_6VectorILi19ES0_EEEC2Ev: + 270: 31: PreserveStorage() : data(R_NilValue), token(R_NilValue){} +------------------ +_ZN4Rcpp15PreserveStorageINS_6VectorILi16ES0_EEEC2Ev: + #####: 31: PreserveStorage() : data(R_NilValue), token(R_NilValue){} +------------------ + -: 32: + 405*: 33: ~PreserveStorage(){ + 405*: 34: Rcpp_PreciousRelease(token) ; + 405*: 35: data = R_NilValue; + 405*: 36: token = R_NilValue; + 405*: 37: } +------------------ +_ZN4Rcpp15PreserveStorageINS_12RObject_ImplIS0_EEED2Ev: + 135: 33: ~PreserveStorage(){ + 135: 34: Rcpp_PreciousRelease(token) ; + 135: 35: data = R_NilValue; + 135: 36: token = R_NilValue; + 135: 37: } +------------------ +_ZN4Rcpp15PreserveStorageINS_6VectorILi19ES0_EEED2Ev: + 270: 33: ~PreserveStorage(){ + 270: 34: Rcpp_PreciousRelease(token) ; + 270: 35: data = R_NilValue; + 270: 36: token = R_NilValue; + 270: 37: } +------------------ +_ZN4Rcpp15PreserveStorageINS_6VectorILi16ES0_EEED2Ev: + #####: 33: ~PreserveStorage(){ + #####: 34: Rcpp_PreciousRelease(token) ; + #####: 35: data = R_NilValue; + #####: 36: token = R_NilValue; + #####: 37: } +------------------ + -: 38: + 405*: 39: inline void set__(SEXP x){ + 405*: 40: if (data != x) { + 405*: 41: data = x; + 405*: 42: Rcpp_PreciousRelease(token); + 405*: 43: token = Rcpp_PreciousPreserve(data); + -: 44: } + -: 45: + -: 46: // calls the update method of CLASS + -: 47: // this is where to react to changes in the underlying SEXP + 405*: 48: static_cast(*this).update(data) ; + 405*: 49: } +------------------ +_ZN4Rcpp15PreserveStorageINS_12RObject_ImplIS0_EEE5set__EP7SEXPREC: + 135: 39: inline void set__(SEXP x){ + 135: 40: if (data != x) { + 135: 41: data = x; + 135: 42: Rcpp_PreciousRelease(token); + 135: 43: token = Rcpp_PreciousPreserve(data); + -: 44: } + -: 45: + -: 46: // calls the update method of CLASS + -: 47: // this is where to react to changes in the underlying SEXP + 135: 48: static_cast(*this).update(data) ; + 135: 49: } +------------------ +_ZN4Rcpp15PreserveStorageINS_6VectorILi19ES0_EEE5set__EP7SEXPREC: + 270: 39: inline void set__(SEXP x){ + 270: 40: if (data != x) { + 270: 41: data = x; + 270: 42: Rcpp_PreciousRelease(token); + 270: 43: token = Rcpp_PreciousPreserve(data); + -: 44: } + -: 45: + -: 46: // calls the update method of CLASS + -: 47: // this is where to react to changes in the underlying SEXP + 270: 48: static_cast(*this).update(data) ; + 270: 49: } +------------------ +_ZN4Rcpp15PreserveStorageINS_6VectorILi16ES0_EEE5set__EP7SEXPREC: + #####: 39: inline void set__(SEXP x){ + #####: 40: if (data != x) { + #####: 41: data = x; + #####: 42: Rcpp_PreciousRelease(token); + #####: 43: token = Rcpp_PreciousPreserve(data); + -: 44: } + -: 45: + -: 46: // calls the update method of CLASS + -: 47: // this is where to react to changes in the underlying SEXP + #####: 48: static_cast(*this).update(data) ; + #####: 49: } +------------------ + -: 50: + 7845*: 51: inline SEXP get__() const { + 7845*: 52: return data ; + -: 53: } +------------------ +_ZNK4Rcpp15PreserveStorageINS_6VectorILi19ES0_EEE5get__Ev: + 7845: 51: inline SEXP get__() const { + 7845: 52: return data ; + -: 53: } +------------------ +_ZNK4Rcpp15PreserveStorageINS_6VectorILi16ES0_EEE5get__Ev: + #####: 51: inline SEXP get__() const { + #####: 52: return data ; + -: 53: } +------------------ + -: 54: + -: 55: inline SEXP invalidate__(){ + -: 56: SEXP out = data ; + -: 57: Rcpp_PreciousRelease(token); + -: 58: data = R_NilValue ; + -: 59: token = R_NilValue ; + -: 60: return out ; + -: 61: } + -: 62: + -: 63: template + -: 64: inline T& copy__(const T& other){ + -: 65: if( this != &other){ + -: 66: set__(other.get__()); + -: 67: } + -: 68: return static_cast(*this) ; + -: 69: } + -: 70: + -: 71: inline bool inherits(const char* clazz) const { + -: 72: return ::Rf_inherits( data, clazz) ; + -: 73: } + -: 74: + 2660*: 75: inline operator SEXP() const { return data; } +------------------ +_ZNK4Rcpp15PreserveStorageINS_12RObject_ImplIS0_EEEcvP7SEXPRECEv: + 135: 75: inline operator SEXP() const { return data; } +------------------ +_ZNK4Rcpp15PreserveStorageINS_6VectorILi16ES0_EEEcvP7SEXPRECEv: + #####: 75: inline operator SEXP() const { return data; } +------------------ +_ZNK4Rcpp15PreserveStorageINS_6VectorILi19ES0_EEEcvP7SEXPRECEv: + 2525: 75: inline operator SEXP() const { return data; } +------------------ + -: 76: + -: 77: private: + -: 78: SEXP data ; + -: 79: SEXP token ; + -: 80: } ; + -: 81: + -: 82:} + -: 83: + -: 84:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#traits#named_object.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#traits#named_object.h.gcov new file mode 100644 index 0000000..b1e21bb --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#traits#named_object.h.gcov @@ -0,0 +1,98 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/traits/named_object.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1: + -: 2:// named_object.h: Rcpp R/C++ interface class library -- named SEXP + -: 3:// + -: 4:// Copyright (C) 2010 - 2020 Dirk Eddelbuettel and Romain Francois + -: 5:// Copyright (C) 2021 - 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21: + -: 22:#ifndef Rcpp__traits__named_object__h + -: 23:#define Rcpp__traits__named_object__h + -: 24: + -: 25:#include + -: 26: + -: 27:namespace Rcpp{ + -: 28:class Argument ; + -: 29: + -: 30:namespace traits{ + -: 31: + -: 32:template struct needs_protection : false_type{} ; + -: 33:template <> struct needs_protection : true_type{} ; + -: 34: + -: 35:template class named_object { + -: 36:public: + #####: 37: named_object( const std::string& name_, const T& o_) : + #####: 38: name(name_), object(o_){} +------------------ +_ZN4Rcpp6traits12named_objectINS_6VectorILi16ENS_15PreserveStorageEEEEC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS4_: + #####: 37: named_object( const std::string& name_, const T& o_) : + #####: 38: name(name_), object(o_){} +------------------ +_ZN4Rcpp6traits12named_objectIiEC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKi: + #####: 37: named_object( const std::string& name_, const T& o_) : + #####: 38: name(name_), object(o_){} +------------------ +_ZN4Rcpp6traits12named_objectIA1_cEC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERA1_Kc: + #####: 37: named_object( const std::string& name_, const T& o_) : + #####: 38: name(name_), object(o_){} +------------------ + -: 39: const std::string& name; + -: 40: const T& object; + -: 41:}; + -: 42:template <> class named_object { + -: 43:public: // #nocov start + -: 44: named_object( const std::string& name_, const SEXP& o_): + -: 45: name(name_), object(o_), token(R_NilValue) { + -: 46: token = Rcpp_PreciousPreserve(object); + -: 47: } + -: 48: + -: 49: named_object( const named_object& other ) : + -: 50: name(other.name), object(other.object), token(other.token) { + -: 51: token = Rcpp_PreciousPreserve(object); + -: 52: } + -: 53: ~named_object() { + -: 54: Rcpp_PreciousRelease(token); + -: 55: + -: 56: } // #nocov end + -: 57: const std::string& name; + -: 58: SEXP object; + -: 59:private: + -: 60: SEXP token; + -: 61:}; + -: 62: + -: 63: + -: 64:template struct is_named : public false_type{}; + -: 65:template struct is_named< named_object > : public true_type {}; + -: 66:template <> struct is_named< Rcpp::Argument > : public true_type {}; + -: 67: + -: 68:template struct is_any_named : public false_type {}; + -: 69:template struct is_any_named : public is_named::type {}; + -: 70: + -: 71:template + -: 72:struct is_any_named + -: 73: : public std::conditional< + -: 74: is_any_named::value, + -: 75: std::true_type, + -: 76: is_any_named>::type {}; + -: 77: + -: 78:} // namespace traits + -: 79:} // namespace Rcpp + -: 80: + -: 81:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#unwindProtect.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#unwindProtect.h.gcov new file mode 100644 index 0000000..401bf88 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#unwindProtect.h.gcov @@ -0,0 +1,83 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/unwindProtect.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1: + -: 2:// unwind.h: Rcpp R/C++ interface class library -- Unwind Protect + -: 3:// + -: 4:// Copyright (C) 2018 - 2020 RStudio + -: 5:// Copyright (C) 2021 - 2025 RStudio, Dirk Eddelbuettel and Iñaki Ucar + -: 6:// + -: 7:// This file is part of Rcpp. + -: 8:// + -: 9:// Rcpp is free software: you can redistribute it and/or modify it + -: 10:// under the terms of the GNU General Public License as published by + -: 11:// the Free Software Foundation, either version 2 of the License, or + -: 12:// (at your option) any later version. + -: 13:// + -: 14:// Rcpp is distributed in the hope that it will be useful, but + -: 15:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 16:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 17:// GNU General Public License for more details. + -: 18:// + -: 19:// You should have received a copy of the GNU General Public License + -: 20:// along with Rcpp. If not, see . + -: 21: + -: 22:#ifndef RCPP_UNWINDPROTECT_H + -: 23:#define RCPP_UNWINDPROTECT_H + -: 24: + -: 25:#include + -: 26:#include + -: 27: + -: 28:namespace Rcpp { namespace internal { + -: 29: + -: 30:struct UnwindData { + -: 31: std::jmp_buf jmpbuf; + -: 32:}; + -: 33: + -: 34:// First jump back to the protected context with a C longjmp because + -: 35:// `Rcpp_protected_eval()` is called from C and we can't safely throw + -: 36:// exceptions across C frames. + #####: 37:inline void maybeJump(void* unwind_data, Rboolean jump) { + #####: 38: if (jump) { + #####: 39: UnwindData* data = static_cast(unwind_data); + #####: 40: longjmp(data->jmpbuf, 1); + -: 41: } + #####: 42:} + -: 43: + -: 44:inline SEXP unwindProtectUnwrap(void* data) { + -: 45: std::function* callback = (std::function*) data; + -: 46: return (*callback)(); + -: 47:} + -: 48: + -: 49:}} // namespace Rcpp::internal + -: 50: + -: 51: + -: 52:namespace Rcpp { + -: 53: + #####: 54:inline SEXP unwindProtect(SEXP (*callback)(void* data), void* data) { + -: 55: internal::UnwindData unwind_data; + #####: 56: Shield token(::R_MakeUnwindCont()); + -: 57: + #####: 58: if (setjmp(unwind_data.jmpbuf)) { + -: 59: // Keep the token protected while unwinding because R code might run + -: 60: // in C++ destructors. Can't use PROTECT() for this because + -: 61: // UNPROTECT() might be called in a destructor, for instance if a + -: 62: // Shield is on the stack. + #####: 63: ::R_PreserveObject(token); + -: 64: + #####: 65: throw LongjumpException(token); + -: 66: } + -: 67: + #####: 68: return ::R_UnwindProtect(callback, data, + -: 69: internal::maybeJump, &unwind_data, + #####: 70: token); + #####: 71:} + -: 72: + -: 73:inline SEXP unwindProtect(std::function callback) { + -: 74: return unwindProtect(&internal::unwindProtectUnwrap, &callback); + -: 75:} + -: 76: + -: 77:} // namespace Rcpp + -: 78: + -: 79:#endif diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#utils#tinyformat#tinyformat.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#utils#tinyformat#tinyformat.h.gcov new file mode 100644 index 0000000..8a71e02 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#utils#tinyformat#tinyformat.h.gcov @@ -0,0 +1,1238 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/utils/tinyformat/tinyformat.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// #nocov start + -: 2:// tinyformat.h + -: 3:// Copyright (C) 2011, Chris Foster [chris42f (at) gmail (d0t) com] + -: 4:// + -: 5:// Boost Software License - Version 1.0 + -: 6:// + -: 7:// Permission is hereby granted, free of charge, to any person or organization + -: 8:// obtaining a copy of the software and accompanying documentation covered by + -: 9:// this license (the "Software") to use, reproduce, display, distribute, + -: 10:// execute, and transmit the Software, and to prepare derivative works of the + -: 11:// Software, and to permit third-parties to whom the Software is furnished to + -: 12:// do so, all subject to the following: + -: 13:// + -: 14:// The copyright notices in the Software and this entire statement, including + -: 15:// the above license grant, this restriction and the following disclaimer, + -: 16:// must be included in all copies of the Software, in whole or in part, and + -: 17:// all derivative works of the Software, unless such copies or derivative + -: 18:// works are solely in the form of machine-executable object code generated by + -: 19:// a source language processor. + -: 20:// + -: 21:// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + -: 22:// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + -: 23:// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + -: 24:// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + -: 25:// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + -: 26:// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + -: 27:// DEALINGS IN THE SOFTWARE. + -: 28: + -: 29://------------------------------------------------------------------------------ + -: 30:// Tinyformat: A minimal type safe printf replacement + -: 31:// + -: 32:// tinyformat.h is a type safe printf replacement library in a single C++ + -: 33:// header file. Design goals include: + -: 34:// + -: 35:// * Type safety and extensibility for user defined types. + -: 36:// * C99 printf() compatibility, to the extent possible using std::ostream + -: 37:// * Simplicity and minimalism. A single header file to include and distribute + -: 38:// with your projects. + -: 39:// * Augment rather than replace the standard stream formatting mechanism + -: 40:// * C++98 support, with optional C++11 niceties + -: 41:// + -: 42:// + -: 43:// Main interface example usage + -: 44:// ---------------------------- + -: 45:// + -: 46:// To print a date to std::cout: + -: 47:// + -: 48:// std::string weekday = "Wednesday"; + -: 49:// const char* month = "July"; + -: 50:// size_t day = 27; + -: 51:// long hour = 14; + -: 52:// int min = 44; + -: 53:// + -: 54:// tfm::printf("%s, %s %d, %.2d:%.2d\n", weekday, month, day, hour, min); + -: 55:// + -: 56:// The strange types here emphasize the type safety of the interface; it is + -: 57:// possible to print a std::string using the "%s" conversion, and a + -: 58:// size_t using the "%d" conversion. A similar result could be achieved + -: 59:// using either of the tfm::format() functions. One prints on a user provided + -: 60:// stream: + -: 61:// + -: 62:// tfm::format(std::cerr, "%s, %s %d, %.2d:%.2d\n", + -: 63:// weekday, month, day, hour, min); + -: 64:// + -: 65:// The other returns a std::string: + -: 66:// + -: 67:// std::string date = tfm::format("%s, %s %d, %.2d:%.2d\n", + -: 68:// weekday, month, day, hour, min); + -: 69:// std::cout << date; + -: 70:// + -: 71:// These are the three primary interface functions. There is also a + -: 72:// convenience function printfln() which appends a newline to the usual result + -: 73:// of printf() for super simple logging. + -: 74:// + -: 75:// + -: 76:// User defined format functions + -: 77:// ----------------------------- + -: 78:// + -: 79:// Simulating variadic templates in C++98 is pretty painful since it requires + -: 80:// writing out the same function for each desired number of arguments. To make + -: 81:// this bearable tinyformat comes with a set of macros which are used + -: 82:// internally to generate the API, but which may also be used in user code. + -: 83:// + -: 84:// The three macros TINYFORMAT_ARGTYPES(n), TINYFORMAT_VARARGS(n) and + -: 85:// TINYFORMAT_PASSARGS(n) will generate a list of n argument types, + -: 86:// type/name pairs and argument names respectively when called with an integer + -: 87:// n between 1 and 16. We can use these to define a macro which generates the + -: 88:// desired user defined function with n arguments. To generate all 16 user + -: 89:// defined function bodies, use the macro TINYFORMAT_FOREACH_ARGNUM. For an + -: 90:// example, see the implementation of printf() at the end of the source file. + -: 91:// + -: 92:// Sometimes it's useful to be able to pass a list of format arguments through + -: 93:// to a non-template function. The FormatList class is provided as a way to do + -: 94:// this by storing the argument list in a type-opaque way. Continuing the + -: 95:// example from above, we construct a FormatList using makeFormatList(): + -: 96:// + -: 97:// FormatListRef formatList = tfm::makeFormatList(weekday, month, day, hour, min); + -: 98:// + -: 99:// The format list can now be passed into any non-template function and used + -: 100:// via a call to the vformat() function: + -: 101:// + -: 102:// tfm::vformat(std::cout, "%s, %s %d, %.2d:%.2d\n", formatList); + -: 103:// + -: 104:// + -: 105:// Additional API information + -: 106:// -------------------------- + -: 107:// + -: 108:// Error handling: Define TINYFORMAT_ERROR to customize the error handling for + -: 109:// format strings which are unsupported or have the wrong number of format + -: 110:// specifiers (calls assert() by default). + -: 111:// + -: 112:// User defined types: Uses operator<< for user defined types by default. + -: 113:// Overload formatValue() for more control. + -: 114: + -: 115: + -: 116:#ifndef TINYFORMAT_H_INCLUDED + -: 117:#define TINYFORMAT_H_INCLUDED + -: 118: + -: 119:namespace tinyformat {} + -: 120://------------------------------------------------------------------------------ + -: 121:// Config section. Customize to your liking! + -: 122: + -: 123:// Namespace alias to encourage brevity + -: 124:namespace tfm = tinyformat; + -: 125: + -: 126:// Error handling; calls assert() by default. + -: 127:// #define TINYFORMAT_ERROR(reasonString) your_error_handler(reasonString) + -: 128: + -: 129:// Define for C++11 variadic templates which make the code shorter & more + -: 130:// general. If you don't define this, C++11 support is autodetected below. + -: 131:// #define TINYFORMAT_USE_VARIADIC_TEMPLATES + -: 132: + -: 133: + -: 134://------------------------------------------------------------------------------ + -: 135:// Implementation details. + -: 136:#include + -: 137:#include + -: 138:#include + -: 139:#include + -: 140: + -: 141:#ifndef TINYFORMAT_ASSERT + -: 142:# define TINYFORMAT_ASSERT(cond) assert(cond) + -: 143:#endif + -: 144: + -: 145:#ifndef TINYFORMAT_ERROR + -: 146:# define TINYFORMAT_ERROR(reason) assert(0 && reason) + -: 147:#endif + -: 148: + -: 149:#if !defined(TINYFORMAT_USE_VARIADIC_TEMPLATES) && !defined(TINYFORMAT_NO_VARIADIC_TEMPLATES) + -: 150:# ifdef __GXX_EXPERIMENTAL_CXX0X__ + -: 151:# define TINYFORMAT_USE_VARIADIC_TEMPLATES + -: 152:# endif + -: 153:#endif + -: 154: + -: 155:#if defined(__GLIBCXX__) && __GLIBCXX__ < 20080201 + -: 156:// std::showpos is broken on old libstdc++ as provided with OSX. See + -: 157:// http://gcc.gnu.org/ml/libstdc++/2007-11/msg00075.html + -: 158:# define TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND + -: 159:#endif + -: 160: + -: 161:#ifdef __APPLE__ + -: 162:// Workaround OSX linker warning: xcode uses different default symbol + -: 163:// visibilities for static libs vs executables (see issue #25) + -: 164:# define TINYFORMAT_HIDDEN __attribute__((visibility("hidden"))) + -: 165:#else + -: 166:# define TINYFORMAT_HIDDEN + -: 167:#endif + -: 168: + -: 169:namespace tinyformat { + -: 170: + -: 171://------------------------------------------------------------------------------ + -: 172:namespace detail { + -: 173: + -: 174:// Test whether type T1 is convertible to type T2 + -: 175:template + -: 176:struct is_convertible + -: 177:{ + -: 178: private: + -: 179: // two types of different size + -: 180: struct fail { char dummy[2]; }; + -: 181: struct succeed { char dummy; }; + -: 182: // Try to convert a T1 to a T2 by plugging into tryConvert + -: 183: static fail tryConvert(...); + -: 184: static succeed tryConvert(const T2&); + -: 185: static const T1& makeT1(); + -: 186: public: + -: 187:# ifdef _MSC_VER + -: 188: // Disable spurious loss of precision warnings in tryConvert(makeT1()) + -: 189:# pragma warning(push) + -: 190:# pragma warning(disable:4244) + -: 191:# pragma warning(disable:4267) + -: 192:# endif + -: 193: // Standard trick: the (...) version of tryConvert will be chosen from + -: 194: // the overload set only if the version taking a T2 doesn't match. + -: 195: // Then we compare the sizes of the return types to check which + -: 196: // function matched. Very neat, in a disgusting kind of way :) + -: 197: static const bool value = + -: 198: sizeof(tryConvert(makeT1())) == sizeof(succeed); + -: 199:# ifdef _MSC_VER + -: 200:# pragma warning(pop) + -: 201:# endif + -: 202:}; + -: 203: + -: 204: + -: 205:// Detect when a type is not a wchar_t string + -: 206:template struct is_wchar { typedef int tinyformat_wchar_is_not_supported; }; + -: 207:template<> struct is_wchar {}; + -: 208:template<> struct is_wchar {}; + -: 209:template struct is_wchar {}; + -: 210:template struct is_wchar {}; + -: 211: + -: 212: + -: 213:// Format the value by casting to type fmtT. This default implementation + -: 214:// should never be called. + -: 215:template::value> + -: 216:struct formatValueAsType + -: 217:{ + -: 218: static void invoke(std::ostream& /*out*/, const T& /*value*/) { TINYFORMAT_ASSERT(0); } + -: 219:}; + -: 220:// Specialized version for types that can actually be converted to fmtT, as + -: 221:// indicated by the "convertible" template parameter. + -: 222:template + -: 223:struct formatValueAsType + -: 224:{ + #####: 225: static void invoke(std::ostream& out, const T& value) + #####: 226: { out << static_cast(value); } +------------------ +_ZN10tinyformat6detail17formatValueAsTypeIicLb1EE6invokeERSoRKi: + #####: 225: static void invoke(std::ostream& out, const T& value) + #####: 226: { out << static_cast(value); } +------------------ +_ZN10tinyformat6detail17formatValueAsTypeIPKcPKvLb1EE6invokeERSoRKS3_: + #####: 225: static void invoke(std::ostream& out, const T& value) + #####: 226: { out << static_cast(value); } +------------------ + -: 227:}; + -: 228: + -: 229:#ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND + -: 230:template::value> + -: 231:struct formatZeroIntegerWorkaround + -: 232:{ + -: 233: static bool invoke(std::ostream& /**/, const T& /**/) { return false; } + -: 234:}; + -: 235:template + -: 236:struct formatZeroIntegerWorkaround + -: 237:{ + -: 238: static bool invoke(std::ostream& out, const T& value) + -: 239: { + -: 240: if (static_cast(value) == 0 && out.flags() & std::ios::showpos) + -: 241: { + -: 242: out << "+0"; + -: 243: return true; + -: 244: } + -: 245: return false; + -: 246: } + -: 247:}; + -: 248:#endif // TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND + -: 249: + -: 250:// Convert an arbitrary type to integer. The version with convertible=false + -: 251:// throws an error. + -: 252:template::value> + -: 253:struct convertToInt + -: 254:{ + #####: 255: static int invoke(const T& /*value*/) + -: 256: { + #####: 257: TINYFORMAT_ERROR("tinyformat: Cannot convert from argument type to " + -: 258: "integer for use as variable width or precision"); + -: 259: return 0; + -: 260: } + -: 261:}; + -: 262:// Specialization for convertToInt when conversion is possible + -: 263:template + -: 264:struct convertToInt + -: 265:{ + #####: 266: static int invoke(const T& value) { return static_cast(value); } + -: 267:}; + -: 268: + -: 269:// Format at most ntrunc characters to the given stream. + -: 270:template + #####: 271:inline void formatTruncated(std::ostream& out, const T& value, int ntrunc) + -: 272:{ + #####: 273: std::ostringstream tmp; + #####: 274: tmp << value; + #####: 275: std::string result = tmp.str(); + #####: 276: out.write(result.c_str(), (std::min)(ntrunc, static_cast(result.size()))); + #####: 277:} + -: 278:#define TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR(type) \ + -: 279:inline void formatTruncated(std::ostream& out, type* value, int ntrunc) \ + -: 280:{ \ + -: 281: std::streamsize len = 0; \ + -: 282: while(len < ntrunc && value[len] != 0) \ + -: 283: ++len; \ + -: 284: out.write(value, len); \ + -: 285:} + -: 286:// Overload for const char* and char*. Could overload for signed & unsigned + -: 287:// char too, but these are technically unneeded for printf compatibility. + #####: 288:TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR(const char) + -: 289:TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR(char) + -: 290:#undef TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR + -: 291: + -: 292:} // namespace detail + -: 293: + -: 294: + -: 295://------------------------------------------------------------------------------ + -: 296:// Variable formatting functions. May be overridden for user-defined types if + -: 297:// desired. + -: 298: + -: 299: + -: 300:/// Format a value into a stream, delegating to operator<< by default. + -: 301:/// + -: 302:/// Users may override this for their own types. When this function is called, + -: 303:/// the stream flags will have been modified according to the format string. + -: 304:/// The format specification is provided in the range [fmtBegin, fmtEnd). For + -: 305:/// truncating conversions, ntrunc is set to the desired maximum number of + -: 306:/// characters, for example "%.7s" calls formatValue with ntrunc = 7. + -: 307:/// + -: 308:/// By default, formatValue() uses the usual stream insertion operator + -: 309:/// operator<< to format the type T, with special cases for the %c and %p + -: 310:/// conversions. + -: 311:template + #####: 312:inline void formatValue(std::ostream& out, const char* /*fmtBegin*/, + -: 313: const char* fmtEnd, int ntrunc, const T& value) + -: 314:{ + -: 315:#ifndef TINYFORMAT_ALLOW_WCHAR_STRINGS + -: 316: // Since we don't support printing of wchar_t using "%ls", make it fail at + -: 317: // compile time in preference to printing as a void* at runtime. + -: 318: typedef typename detail::is_wchar::tinyformat_wchar_is_not_supported DummyType; + -: 319: (void) DummyType(); // avoid unused type warning with gcc-4.8 + -: 320:#endif + -: 321: // The mess here is to support the %c and %p conversions: if these + -: 322: // conversions are active we try to convert the type to a char or const + -: 323: // void* respectively and format that instead of the value itself. For the + -: 324: // %p conversion it's important to avoid dereferencing the pointer, which + -: 325: // could otherwise lead to a crash when printing a dangling (const char*). + #####: 326: const bool canConvertToChar = detail::is_convertible::value; + #####: 327: const bool canConvertToVoidPtr = detail::is_convertible::value; + #####: 328: if(canConvertToChar && *(fmtEnd-1) == 'c') + #####: 329: detail::formatValueAsType::invoke(out, value); + #####: 330: else if(canConvertToVoidPtr && *(fmtEnd-1) == 'p') + #####: 331: detail::formatValueAsType::invoke(out, value); + -: 332:#ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND + -: 333: else if(detail::formatZeroIntegerWorkaround::invoke(out, value)) /**/; + -: 334:#endif + #####: 335: else if(ntrunc >= 0) + -: 336: { + -: 337: // Take care not to overread C strings in truncating conversions like + -: 338: // "%.4s" where at most 4 characters may be read. + #####: 339: detail::formatTruncated(out, value, ntrunc); + -: 340: } + -: 341: else + #####: 342: out << value; + #####: 343:} +------------------ +_ZN10tinyformat11formatValueIiEEvRSoPKcS3_iRKT_: + #####: 312:inline void formatValue(std::ostream& out, const char* /*fmtBegin*/, + -: 313: const char* fmtEnd, int ntrunc, const T& value) + -: 314:{ + -: 315:#ifndef TINYFORMAT_ALLOW_WCHAR_STRINGS + -: 316: // Since we don't support printing of wchar_t using "%ls", make it fail at + -: 317: // compile time in preference to printing as a void* at runtime. + -: 318: typedef typename detail::is_wchar::tinyformat_wchar_is_not_supported DummyType; + -: 319: (void) DummyType(); // avoid unused type warning with gcc-4.8 + -: 320:#endif + -: 321: // The mess here is to support the %c and %p conversions: if these + -: 322: // conversions are active we try to convert the type to a char or const + -: 323: // void* respectively and format that instead of the value itself. For the + -: 324: // %p conversion it's important to avoid dereferencing the pointer, which + -: 325: // could otherwise lead to a crash when printing a dangling (const char*). + #####: 326: const bool canConvertToChar = detail::is_convertible::value; + #####: 327: const bool canConvertToVoidPtr = detail::is_convertible::value; + #####: 328: if(canConvertToChar && *(fmtEnd-1) == 'c') + #####: 329: detail::formatValueAsType::invoke(out, value); + -: 330: else if(canConvertToVoidPtr && *(fmtEnd-1) == 'p') + -: 331: detail::formatValueAsType::invoke(out, value); + -: 332:#ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND + -: 333: else if(detail::formatZeroIntegerWorkaround::invoke(out, value)) /**/; + -: 334:#endif + #####: 335: else if(ntrunc >= 0) + -: 336: { + -: 337: // Take care not to overread C strings in truncating conversions like + -: 338: // "%.4s" where at most 4 characters may be read. + #####: 339: detail::formatTruncated(out, value, ntrunc); + -: 340: } + -: 341: else + #####: 342: out << value; + #####: 343:} +------------------ +_ZN10tinyformat11formatValueIPKcEEvRSoS2_S2_iRKT_: + #####: 312:inline void formatValue(std::ostream& out, const char* /*fmtBegin*/, + -: 313: const char* fmtEnd, int ntrunc, const T& value) + -: 314:{ + -: 315:#ifndef TINYFORMAT_ALLOW_WCHAR_STRINGS + -: 316: // Since we don't support printing of wchar_t using "%ls", make it fail at + -: 317: // compile time in preference to printing as a void* at runtime. + -: 318: typedef typename detail::is_wchar::tinyformat_wchar_is_not_supported DummyType; + -: 319: (void) DummyType(); // avoid unused type warning with gcc-4.8 + -: 320:#endif + -: 321: // The mess here is to support the %c and %p conversions: if these + -: 322: // conversions are active we try to convert the type to a char or const + -: 323: // void* respectively and format that instead of the value itself. For the + -: 324: // %p conversion it's important to avoid dereferencing the pointer, which + -: 325: // could otherwise lead to a crash when printing a dangling (const char*). + #####: 326: const bool canConvertToChar = detail::is_convertible::value; + #####: 327: const bool canConvertToVoidPtr = detail::is_convertible::value; + -: 328: if(canConvertToChar && *(fmtEnd-1) == 'c') + -: 329: detail::formatValueAsType::invoke(out, value); + #####: 330: else if(canConvertToVoidPtr && *(fmtEnd-1) == 'p') + #####: 331: detail::formatValueAsType::invoke(out, value); + -: 332:#ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND + -: 333: else if(detail::formatZeroIntegerWorkaround::invoke(out, value)) /**/; + -: 334:#endif + #####: 335: else if(ntrunc >= 0) + -: 336: { + -: 337: // Take care not to overread C strings in truncating conversions like + -: 338: // "%.4s" where at most 4 characters may be read. + #####: 339: detail::formatTruncated(out, value, ntrunc); + -: 340: } + -: 341: else + #####: 342: out << value; + #####: 343:} +------------------ + -: 344: + -: 345: + -: 346:// Overloaded version for char types to support printing as an integer + -: 347:#define TINYFORMAT_DEFINE_FORMATVALUE_CHAR(charType) \ + -: 348:inline void formatValue(std::ostream& out, const char* /*fmtBegin*/, \ + -: 349: const char* fmtEnd, int /**/, charType value) \ + -: 350:{ \ + -: 351: switch(*(fmtEnd-1)) \ + -: 352: { \ + -: 353: case 'u': case 'd': case 'i': case 'o': case 'X': case 'x': \ + -: 354: out << static_cast(value); break; \ + -: 355: default: \ + -: 356: out << value; break; \ + -: 357: } \ + -: 358:} + -: 359:// per 3.9.1: char, signed char and unsigned char are all distinct types + -: 360:TINYFORMAT_DEFINE_FORMATVALUE_CHAR(char) + -: 361:TINYFORMAT_DEFINE_FORMATVALUE_CHAR(signed char) + -: 362:TINYFORMAT_DEFINE_FORMATVALUE_CHAR(unsigned char) + -: 363:#undef TINYFORMAT_DEFINE_FORMATVALUE_CHAR + -: 364: + -: 365: + -: 366://------------------------------------------------------------------------------ + -: 367:// Tools for emulating variadic templates in C++98. The basic idea here is + -: 368:// stolen from the boost preprocessor metaprogramming library and cut down to + -: 369:// be just general enough for what we need. + -: 370: + -: 371:#define TINYFORMAT_ARGTYPES(n) TINYFORMAT_ARGTYPES_ ## n + -: 372:#define TINYFORMAT_VARARGS(n) TINYFORMAT_VARARGS_ ## n + -: 373:#define TINYFORMAT_PASSARGS(n) TINYFORMAT_PASSARGS_ ## n + -: 374:#define TINYFORMAT_PASSARGS_TAIL(n) TINYFORMAT_PASSARGS_TAIL_ ## n + -: 375: + -: 376:// To keep it as transparent as possible, the macros below have been generated + -: 377:// using python via the excellent cog.py code generation script. This avoids + -: 378:// the need for a bunch of complex (but more general) preprocessor tricks as + -: 379:// used in boost.preprocessor. + -: 380:// + -: 381:// To rerun the code generation in place, use `cog.py -r tinyformat.h` + -: 382:// (see http://nedbatchelder.com/code/cog). Alternatively you can just create + -: 383:// extra versions by hand. + -: 384: + -: 385:/*[[[cog + -: 386:maxParams = 16 + -: 387: + -: 388:def makeCommaSepLists(lineTemplate, elemTemplate, startInd=1): + -: 389: for j in range(startInd,maxParams+1): + -: 390: list = ', '.join([elemTemplate % {'i':i} for i in range(startInd,j+1)]) + -: 391: cog.outl(lineTemplate % {'j':j, 'list':list}) + -: 392: + -: 393:makeCommaSepLists('#define TINYFORMAT_ARGTYPES_%(j)d %(list)s', + -: 394: 'class T%(i)d') + -: 395: + -: 396:cog.outl() + -: 397:makeCommaSepLists('#define TINYFORMAT_VARARGS_%(j)d %(list)s', + -: 398: 'const T%(i)d& v%(i)d') + -: 399: + -: 400:cog.outl() + -: 401:makeCommaSepLists('#define TINYFORMAT_PASSARGS_%(j)d %(list)s', 'v%(i)d') + -: 402: + -: 403:cog.outl() + -: 404:cog.outl('#define TINYFORMAT_PASSARGS_TAIL_1') + -: 405:makeCommaSepLists('#define TINYFORMAT_PASSARGS_TAIL_%(j)d , %(list)s', + -: 406: 'v%(i)d', startInd = 2) + -: 407: + -: 408:cog.outl() + -: 409:cog.outl('#define TINYFORMAT_FOREACH_ARGNUM(m) \\\n ' + + -: 410: ' '.join(['m(%d)' % (j,) for j in range(1,maxParams+1)])) + -: 411:]]]*/ + -: 412:#define TINYFORMAT_ARGTYPES_1 class T1 + -: 413:#define TINYFORMAT_ARGTYPES_2 class T1, class T2 + -: 414:#define TINYFORMAT_ARGTYPES_3 class T1, class T2, class T3 + -: 415:#define TINYFORMAT_ARGTYPES_4 class T1, class T2, class T3, class T4 + -: 416:#define TINYFORMAT_ARGTYPES_5 class T1, class T2, class T3, class T4, class T5 + -: 417:#define TINYFORMAT_ARGTYPES_6 class T1, class T2, class T3, class T4, class T5, class T6 + -: 418:#define TINYFORMAT_ARGTYPES_7 class T1, class T2, class T3, class T4, class T5, class T6, class T7 + -: 419:#define TINYFORMAT_ARGTYPES_8 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8 + -: 420:#define TINYFORMAT_ARGTYPES_9 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9 + -: 421:#define TINYFORMAT_ARGTYPES_10 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10 + -: 422:#define TINYFORMAT_ARGTYPES_11 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11 + -: 423:#define TINYFORMAT_ARGTYPES_12 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12 + -: 424:#define TINYFORMAT_ARGTYPES_13 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13 + -: 425:#define TINYFORMAT_ARGTYPES_14 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14 + -: 426:#define TINYFORMAT_ARGTYPES_15 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15 + -: 427:#define TINYFORMAT_ARGTYPES_16 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15, class T16 + -: 428: + -: 429:#define TINYFORMAT_VARARGS_1 const T1& v1 + -: 430:#define TINYFORMAT_VARARGS_2 const T1& v1, const T2& v2 + -: 431:#define TINYFORMAT_VARARGS_3 const T1& v1, const T2& v2, const T3& v3 + -: 432:#define TINYFORMAT_VARARGS_4 const T1& v1, const T2& v2, const T3& v3, const T4& v4 + -: 433:#define TINYFORMAT_VARARGS_5 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5 + -: 434:#define TINYFORMAT_VARARGS_6 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6 + -: 435:#define TINYFORMAT_VARARGS_7 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7 + -: 436:#define TINYFORMAT_VARARGS_8 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8 + -: 437:#define TINYFORMAT_VARARGS_9 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9 + -: 438:#define TINYFORMAT_VARARGS_10 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10 + -: 439:#define TINYFORMAT_VARARGS_11 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11 + -: 440:#define TINYFORMAT_VARARGS_12 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12 + -: 441:#define TINYFORMAT_VARARGS_13 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13 + -: 442:#define TINYFORMAT_VARARGS_14 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14 + -: 443:#define TINYFORMAT_VARARGS_15 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14, const T15& v15 + -: 444:#define TINYFORMAT_VARARGS_16 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14, const T15& v15, const T16& v16 + -: 445: + -: 446:#define TINYFORMAT_PASSARGS_1 v1 + -: 447:#define TINYFORMAT_PASSARGS_2 v1, v2 + -: 448:#define TINYFORMAT_PASSARGS_3 v1, v2, v3 + -: 449:#define TINYFORMAT_PASSARGS_4 v1, v2, v3, v4 + -: 450:#define TINYFORMAT_PASSARGS_5 v1, v2, v3, v4, v5 + -: 451:#define TINYFORMAT_PASSARGS_6 v1, v2, v3, v4, v5, v6 + -: 452:#define TINYFORMAT_PASSARGS_7 v1, v2, v3, v4, v5, v6, v7 + -: 453:#define TINYFORMAT_PASSARGS_8 v1, v2, v3, v4, v5, v6, v7, v8 + -: 454:#define TINYFORMAT_PASSARGS_9 v1, v2, v3, v4, v5, v6, v7, v8, v9 + -: 455:#define TINYFORMAT_PASSARGS_10 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10 + -: 456:#define TINYFORMAT_PASSARGS_11 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11 + -: 457:#define TINYFORMAT_PASSARGS_12 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12 + -: 458:#define TINYFORMAT_PASSARGS_13 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13 + -: 459:#define TINYFORMAT_PASSARGS_14 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 + -: 460:#define TINYFORMAT_PASSARGS_15 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 + -: 461:#define TINYFORMAT_PASSARGS_16 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16 + -: 462: + -: 463:#define TINYFORMAT_PASSARGS_TAIL_1 + -: 464:#define TINYFORMAT_PASSARGS_TAIL_2 , v2 + -: 465:#define TINYFORMAT_PASSARGS_TAIL_3 , v2, v3 + -: 466:#define TINYFORMAT_PASSARGS_TAIL_4 , v2, v3, v4 + -: 467:#define TINYFORMAT_PASSARGS_TAIL_5 , v2, v3, v4, v5 + -: 468:#define TINYFORMAT_PASSARGS_TAIL_6 , v2, v3, v4, v5, v6 + -: 469:#define TINYFORMAT_PASSARGS_TAIL_7 , v2, v3, v4, v5, v6, v7 + -: 470:#define TINYFORMAT_PASSARGS_TAIL_8 , v2, v3, v4, v5, v6, v7, v8 + -: 471:#define TINYFORMAT_PASSARGS_TAIL_9 , v2, v3, v4, v5, v6, v7, v8, v9 + -: 472:#define TINYFORMAT_PASSARGS_TAIL_10 , v2, v3, v4, v5, v6, v7, v8, v9, v10 + -: 473:#define TINYFORMAT_PASSARGS_TAIL_11 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11 + -: 474:#define TINYFORMAT_PASSARGS_TAIL_12 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12 + -: 475:#define TINYFORMAT_PASSARGS_TAIL_13 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13 + -: 476:#define TINYFORMAT_PASSARGS_TAIL_14 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 + -: 477:#define TINYFORMAT_PASSARGS_TAIL_15 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 + -: 478:#define TINYFORMAT_PASSARGS_TAIL_16 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16 + -: 479: + -: 480:#define TINYFORMAT_FOREACH_ARGNUM(m) \ + -: 481: m(1) m(2) m(3) m(4) m(5) m(6) m(7) m(8) m(9) m(10) m(11) m(12) m(13) m(14) m(15) m(16) + -: 482://[[[end]]] + -: 483: + -: 484: + -: 485: + -: 486:namespace detail { + -: 487: + -: 488:// Type-opaque holder for an argument to format(), with associated actions on + -: 489:// the type held as explicit function pointers. This allows FormatArg's for + -: 490:// each argument to be allocated as a homogenous array inside FormatList + -: 491:// whereas a naive implementation based on inheritance does not. + -: 492:class FormatArg + -: 493:{ + -: 494: public: + -: 495: FormatArg() + -: 496: : m_value(NULL), + -: 497: m_formatImpl(NULL), + -: 498: m_toIntImpl(NULL) + -: 499: { } + -: 500: + -: 501: template + #####: 502: FormatArg(const T& value) + #####: 503: : m_value(static_cast(&value)), + #####: 504: m_formatImpl(&formatImpl), + #####: 505: m_toIntImpl(&toIntImpl) + #####: 506: { } +------------------ +_ZN10tinyformat6detail9FormatArgC2IiEERKT_: + #####: 502: FormatArg(const T& value) + #####: 503: : m_value(static_cast(&value)), + #####: 504: m_formatImpl(&formatImpl), + #####: 505: m_toIntImpl(&toIntImpl) + #####: 506: { } +------------------ +_ZN10tinyformat6detail9FormatArgC2IPKcEERKT_: + #####: 502: FormatArg(const T& value) + #####: 503: : m_value(static_cast(&value)), + #####: 504: m_formatImpl(&formatImpl), + #####: 505: m_toIntImpl(&toIntImpl) + #####: 506: { } +------------------ + -: 507: + #####: 508: void format(std::ostream& out, const char* fmtBegin, + -: 509: const char* fmtEnd, int ntrunc) const + -: 510: { + #####: 511: TINYFORMAT_ASSERT(m_value); + #####: 512: TINYFORMAT_ASSERT(m_formatImpl); + #####: 513: m_formatImpl(out, fmtBegin, fmtEnd, ntrunc, m_value); + #####: 514: } + -: 515: + #####: 516: int toInt() const + -: 517: { + #####: 518: TINYFORMAT_ASSERT(m_value); + #####: 519: TINYFORMAT_ASSERT(m_toIntImpl); + #####: 520: return m_toIntImpl(m_value); + -: 521: } + -: 522: + -: 523: private: + -: 524: template + #####: 525: TINYFORMAT_HIDDEN static void formatImpl(std::ostream& out, const char* fmtBegin, + -: 526: const char* fmtEnd, int ntrunc, const void* value) + -: 527: { + #####: 528: formatValue(out, fmtBegin, fmtEnd, ntrunc, *static_cast(value)); + #####: 529: } +------------------ +_ZN10tinyformat6detail9FormatArg10formatImplIiEEvRSoPKcS5_iPKv: + #####: 525: TINYFORMAT_HIDDEN static void formatImpl(std::ostream& out, const char* fmtBegin, + -: 526: const char* fmtEnd, int ntrunc, const void* value) + -: 527: { + #####: 528: formatValue(out, fmtBegin, fmtEnd, ntrunc, *static_cast(value)); + #####: 529: } +------------------ +_ZN10tinyformat6detail9FormatArg10formatImplIPKcEEvRSoS4_S4_iPKv: + #####: 525: TINYFORMAT_HIDDEN static void formatImpl(std::ostream& out, const char* fmtBegin, + -: 526: const char* fmtEnd, int ntrunc, const void* value) + -: 527: { + #####: 528: formatValue(out, fmtBegin, fmtEnd, ntrunc, *static_cast(value)); + #####: 529: } +------------------ + -: 530: + -: 531: template + #####: 532: TINYFORMAT_HIDDEN static int toIntImpl(const void* value) + -: 533: { + #####: 534: return convertToInt::invoke(*static_cast(value)); + -: 535: } +------------------ +_ZN10tinyformat6detail9FormatArg9toIntImplIiEEiPKv: + #####: 532: TINYFORMAT_HIDDEN static int toIntImpl(const void* value) + -: 533: { + #####: 534: return convertToInt::invoke(*static_cast(value)); + -: 535: } +------------------ +_ZN10tinyformat6detail9FormatArg9toIntImplIPKcEEiPKv: + #####: 532: TINYFORMAT_HIDDEN static int toIntImpl(const void* value) + -: 533: { + #####: 534: return convertToInt::invoke(*static_cast(value)); + -: 535: } +------------------ + -: 536: + -: 537: const void* m_value; + -: 538: void (*m_formatImpl)(std::ostream& out, const char* fmtBegin, + -: 539: const char* fmtEnd, int ntrunc, const void* value); + -: 540: int (*m_toIntImpl)(const void* value); + -: 541:}; + -: 542: + -: 543: + -: 544:// Parse and return an integer from the string c, as atoi() + -: 545:// On return, c is set to one past the end of the integer. + #####: 546:inline int parseIntAndAdvance(const char*& c) + -: 547:{ + #####: 548: int i = 0; + #####: 549: for(;*c >= '0' && *c <= '9'; ++c) + #####: 550: i = 10*i + (*c - '0'); + #####: 551: return i; + -: 552:} + -: 553: + -: 554:// Print literal part of format string and return next format spec + -: 555:// position. + -: 556:// + -: 557:// Skips over any occurrences of '%%', printing a literal '%' to the + -: 558:// output. The position of the first % character of the next + -: 559:// nontrivial format spec is returned, or the end of string. + #####: 560:inline const char* printFormatStringLiteral(std::ostream& out, const char* fmt) + -: 561:{ + #####: 562: const char* c = fmt; + #####: 563: for(;; ++c) + -: 564: { + #####: 565: switch(*c) + -: 566: { + #####: 567: case '\0': + #####: 568: out.write(fmt, c - fmt); + #####: 569: return c; + #####: 570: case '%': + #####: 571: out.write(fmt, c - fmt); + #####: 572: if(*(c+1) != '%') + #####: 573: return c; + -: 574: // for "%%", tack trailing % onto next literal section. + #####: 575: fmt = ++c; + #####: 576: break; + #####: 577: default: + #####: 578: break; + -: 579: } + -: 580: } + -: 581:} + -: 582: + -: 583: + -: 584:// Parse a format string and set the stream state accordingly. + -: 585:// + -: 586:// The format mini-language recognized here is meant to be the one from C99, + -: 587:// with the form "%[flags][width][.precision][length]type". + -: 588:// + -: 589:// Formatting options which can't be natively represented using the ostream + -: 590:// state are returned in spacePadPositive (for space padded positive numbers) + -: 591:// and ntrunc (for truncating conversions). argIndex is incremented if + -: 592:// necessary to pull out variable width and precision . The function returns a + -: 593:// pointer to the character after the end of the current format spec. + #####: 594:inline const char* streamStateFromFormat(std::ostream& out, bool& spacePadPositive, + -: 595: int& ntrunc, const char* fmtStart, + -: 596: const detail::FormatArg* formatters, + -: 597: int& argIndex, int numFormatters) + -: 598:{ + #####: 599: if(*fmtStart != '%') + -: 600: { + #####: 601: TINYFORMAT_ERROR("tinyformat: Not enough conversion specifiers in format string"); + -: 602: return fmtStart; + -: 603: } + -: 604: // Reset stream state to defaults. + #####: 605: out.width(0); + #####: 606: out.precision(6); + #####: 607: out.fill(' '); + -: 608: // Reset most flags; ignore irrelevant unitbuf & skipws. + #####: 609: out.unsetf(std::ios::adjustfield | std::ios::basefield | + -: 610: std::ios::floatfield | std::ios::showbase | std::ios::boolalpha | + -: 611: std::ios::showpoint | std::ios::showpos | std::ios::uppercase); + #####: 612: bool precisionSet = false; + #####: 613: bool widthSet = false; + #####: 614: int widthExtra = 0; + #####: 615: const char* c = fmtStart + 1; + -: 616: // 1) Parse flags + #####: 617: for(;; ++c) + -: 618: { + #####: 619: switch(*c) + -: 620: { + #####: 621: case '#': + #####: 622: out.setf(std::ios::showpoint | std::ios::showbase); + #####: 623: continue; + #####: 624: case '0': + -: 625: // overridden by left alignment ('-' flag) + #####: 626: if(!(out.flags() & std::ios::left)) + -: 627: { + -: 628: // Use internal padding so that numeric values are + -: 629: // formatted correctly, eg -00010 rather than 000-10 + #####: 630: out.fill('0'); + #####: 631: out.setf(std::ios::internal, std::ios::adjustfield); + -: 632: } + #####: 633: continue; + #####: 634: case '-': + #####: 635: out.fill(' '); + #####: 636: out.setf(std::ios::left, std::ios::adjustfield); + #####: 637: continue; + #####: 638: case ' ': + -: 639: // overridden by show positive sign, '+' flag. + #####: 640: if(!(out.flags() & std::ios::showpos)) + #####: 641: spacePadPositive = true; + #####: 642: continue; + #####: 643: case '+': + #####: 644: out.setf(std::ios::showpos); + #####: 645: spacePadPositive = false; + #####: 646: widthExtra = 1; + #####: 647: continue; + #####: 648: default: + #####: 649: break; + -: 650: } + #####: 651: break; + -: 652: } + -: 653: // 2) Parse width + #####: 654: if(*c >= '0' && *c <= '9') + -: 655: { + #####: 656: widthSet = true; + #####: 657: out.width(parseIntAndAdvance(c)); + -: 658: } + #####: 659: if(*c == '*') + -: 660: { + #####: 661: widthSet = true; + #####: 662: int width = 0; + #####: 663: if(argIndex < numFormatters) + #####: 664: width = formatters[argIndex++].toInt(); + -: 665: else + #####: 666: TINYFORMAT_ERROR("tinyformat: Not enough arguments to read variable width"); + #####: 667: if(width < 0) + -: 668: { + -: 669: // negative widths correspond to '-' flag set + #####: 670: out.fill(' '); + #####: 671: out.setf(std::ios::left, std::ios::adjustfield); + #####: 672: width = -width; + -: 673: } + #####: 674: out.width(width); + #####: 675: ++c; + -: 676: } + -: 677: // 3) Parse precision + #####: 678: if(*c == '.') + -: 679: { + #####: 680: ++c; + #####: 681: int precision = 0; + #####: 682: if(*c == '*') + -: 683: { + #####: 684: ++c; + #####: 685: if(argIndex < numFormatters) + #####: 686: precision = formatters[argIndex++].toInt(); + -: 687: else + #####: 688: TINYFORMAT_ERROR("tinyformat: Not enough arguments to read variable precision"); + -: 689: } + -: 690: else + -: 691: { + #####: 692: if(*c >= '0' && *c <= '9') + #####: 693: precision = parseIntAndAdvance(c); + #####: 694: else if(*c == '-') // negative precisions ignored, treated as zero. + #####: 695: parseIntAndAdvance(++c); + -: 696: } + #####: 697: out.precision(precision); + #####: 698: precisionSet = true; + -: 699: } + -: 700: // 4) Ignore any C99 length modifier + #####: 701: while(*c == 'l' || *c == 'h' || *c == 'L' || + #####: 702: *c == 'j' || *c == 'z' || *c == 't') + #####: 703: ++c; + -: 704: // 5) We're up to the conversion specifier character. + -: 705: // Set stream flags based on conversion specifier (thanks to the + -: 706: // boost::format class for forging the way here). + #####: 707: bool intConversion = false; + #####: 708: switch(*c) + -: 709: { + #####: 710: case 'u': case 'd': case 'i': + #####: 711: out.setf(std::ios::dec, std::ios::basefield); + #####: 712: intConversion = true; + #####: 713: break; + #####: 714: case 'o': + #####: 715: out.setf(std::ios::oct, std::ios::basefield); + #####: 716: intConversion = true; + #####: 717: break; + #####: 718: case 'X': + #####: 719: out.setf(std::ios::uppercase); + -: 720: // Falls through + #####: 721: case 'x': case 'p': + #####: 722: out.setf(std::ios::hex, std::ios::basefield); + #####: 723: intConversion = true; + #####: 724: break; + #####: 725: case 'E': + #####: 726: out.setf(std::ios::uppercase); + -: 727: // Falls through + #####: 728: case 'e': + #####: 729: out.setf(std::ios::scientific, std::ios::floatfield); + #####: 730: out.setf(std::ios::dec, std::ios::basefield); + #####: 731: break; + #####: 732: case 'F': + #####: 733: out.setf(std::ios::uppercase); + -: 734: // Falls through + #####: 735: case 'f': + #####: 736: out.setf(std::ios::fixed, std::ios::floatfield); + #####: 737: break; + #####: 738: case 'G': + #####: 739: out.setf(std::ios::uppercase); + -: 740: // Falls through + #####: 741: case 'g': + #####: 742: out.setf(std::ios::dec, std::ios::basefield); + -: 743: // As in boost::format, let stream decide float format. + #####: 744: out.flags(out.flags() & ~std::ios::floatfield); + #####: 745: break; + #####: 746: case 'a': case 'A': + #####: 747: TINYFORMAT_ERROR("tinyformat: the %a and %A conversion specs " + -: 748: "are not supported"); + -: 749: break; + #####: 750: case 'c': + -: 751: // Handled as special case inside formatValue() + #####: 752: break; + #####: 753: case 's': + #####: 754: if(precisionSet) + #####: 755: ntrunc = static_cast(out.precision()); + -: 756: // Make %s print booleans as "true" and "false" + #####: 757: out.setf(std::ios::boolalpha); + #####: 758: break; + #####: 759: case 'n': + -: 760: // Not supported - will cause problems! + #####: 761: TINYFORMAT_ERROR("tinyformat: %n conversion spec not supported"); + -: 762: break; + #####: 763: case '\0': + #####: 764: TINYFORMAT_ERROR("tinyformat: Conversion spec incorrectly " + -: 765: "terminated by end of string"); + -: 766: return c; + #####: 767: default: + #####: 768: break; + -: 769: } + #####: 770: if(intConversion && precisionSet && !widthSet) + -: 771: { + -: 772: // "precision" for integers gives the minimum number of digits (to be + -: 773: // padded with zeros on the left). This isn't really supported by the + -: 774: // iostreams, but we can approximately simulate it with the width if + -: 775: // the width isn't otherwise used. + #####: 776: out.width(out.precision() + widthExtra); + #####: 777: out.setf(std::ios::internal, std::ios::adjustfield); + #####: 778: out.fill('0'); + -: 779: } + #####: 780: return c+1; + -: 781:} + -: 782: + -: 783: + -: 784://------------------------------------------------------------------------------ + #####: 785:inline void formatImpl(std::ostream& out, const char* fmt, + -: 786: const detail::FormatArg* formatters, + -: 787: int numFormatters) + -: 788:{ + -: 789: // Saved stream state + #####: 790: std::streamsize origWidth = out.width(); + #####: 791: std::streamsize origPrecision = out.precision(); + #####: 792: std::ios::fmtflags origFlags = out.flags(); + #####: 793: char origFill = out.fill(); + -: 794: + #####: 795: for (int argIndex = 0; argIndex < numFormatters; ++argIndex) + -: 796: { + -: 797: // Parse the format string + #####: 798: fmt = printFormatStringLiteral(out, fmt); + #####: 799: bool spacePadPositive = false; + #####: 800: int ntrunc = -1; + #####: 801: const char* fmtEnd = streamStateFromFormat(out, spacePadPositive, ntrunc, fmt, + -: 802: formatters, argIndex, numFormatters); + #####: 803: if (argIndex >= numFormatters) + -: 804: { + -: 805: // Check args remain after reading any variable width/precision + #####: 806: TINYFORMAT_ERROR("tinyformat: Not enough format arguments"); + -: 807: return; + -: 808: } + #####: 809: const FormatArg& arg = formatters[argIndex]; + -: 810: // Format the arg into the stream. + #####: 811: if(!spacePadPositive) + #####: 812: arg.format(out, fmt, fmtEnd, ntrunc); + -: 813: else + -: 814: { + -: 815: // The following is a special case with no direct correspondence + -: 816: // between stream formatting and the printf() behaviour. Simulate + -: 817: // it crudely by formatting into a temporary string stream and + -: 818: // munging the resulting string. + #####: 819: std::ostringstream tmpStream; + #####: 820: tmpStream.copyfmt(out); + #####: 821: tmpStream.setf(std::ios::showpos); + #####: 822: arg.format(tmpStream, fmt, fmtEnd, ntrunc); + #####: 823: std::string result = tmpStream.str(); // allocates... yuck. + #####: 824: for(size_t i = 0, iend = result.size(); i < iend; ++i) + #####: 825: if(result[i] == '+') result[i] = ' '; + #####: 826: out << result; + #####: 827: } + #####: 828: fmt = fmtEnd; + -: 829: } + -: 830: + -: 831: // Print remaining part of format string. + #####: 832: fmt = printFormatStringLiteral(out, fmt); + #####: 833: if(*fmt != '\0') + #####: 834: TINYFORMAT_ERROR("tinyformat: Too many conversion specifiers in format string"); + -: 835: + -: 836: // Restore stream state + #####: 837: out.width(origWidth); + #####: 838: out.precision(origPrecision); + #####: 839: out.flags(origFlags); + #####: 840: out.fill(origFill); + -: 841:} + -: 842: + -: 843:} // namespace detail + -: 844: + -: 845: + -: 846:/// List of template arguments format(), held in a type-opaque way. + -: 847:/// + -: 848:/// A const reference to FormatList (typedef'd as FormatListRef) may be + -: 849:/// conveniently used to pass arguments to non-template functions: All type + -: 850:/// information has been stripped from the arguments, leaving just enough of a + -: 851:/// common interface to perform formatting as required. + -: 852:class FormatList + -: 853:{ + -: 854: public: + #####: 855: FormatList(detail::FormatArg* formatters, int N) + #####: 856: : m_formatters(formatters), m_N(N) { } + -: 857: + -: 858: friend void vformat(std::ostream& out, const char* fmt, + -: 859: const FormatList& list); + -: 860: + -: 861: private: + -: 862: const detail::FormatArg* m_formatters; + -: 863: int m_N; + -: 864:}; + -: 865: + -: 866:/// Reference to type-opaque format list for passing to vformat() + -: 867:typedef const FormatList& FormatListRef; + -: 868: + -: 869: + -: 870:namespace detail { + -: 871: + -: 872:// Format list subclass with fixed storage to avoid dynamic allocation + -: 873:template + -: 874:class FormatListN : public FormatList + -: 875:{ + -: 876: public: + -: 877:#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES + -: 878: template + #####: 879: FormatListN(const Args&... args) + -: 880: : FormatList(&m_formatterStore[0], N), + #####: 881: m_formatterStore { FormatArg(args)... } + #####: 882: { static_assert(sizeof...(args) == N, "Number of args must be N"); } +------------------ +_ZN10tinyformat6detail11FormatListNILi1EEC2IJiEEEDpRKT_: + #####: 879: FormatListN(const Args&... args) + -: 880: : FormatList(&m_formatterStore[0], N), + #####: 881: m_formatterStore { FormatArg(args)... } + #####: 882: { static_assert(sizeof...(args) == N, "Number of args must be N"); } +------------------ +_ZN10tinyformat6detail11FormatListNILi2EEC2IJPKcS5_EEEDpRKT_: + #####: 879: FormatListN(const Args&... args) + -: 880: : FormatList(&m_formatterStore[0], N), + #####: 881: m_formatterStore { FormatArg(args)... } + #####: 882: { static_assert(sizeof...(args) == N, "Number of args must be N"); } +------------------ + -: 883:#else // C++98 version + -: 884: void init(int) {} + -: 885:# define TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR(n) \ + -: 886: \ + -: 887: template \ + -: 888: FormatListN(TINYFORMAT_VARARGS(n)) \ + -: 889: : FormatList(&m_formatterStore[0], n) \ + -: 890: { TINYFORMAT_ASSERT(n == N); init(0, TINYFORMAT_PASSARGS(n)); } \ + -: 891: \ + -: 892: template \ + -: 893: void init(int i, TINYFORMAT_VARARGS(n)) \ + -: 894: { \ + -: 895: m_formatterStore[i] = FormatArg(v1); \ + -: 896: init(i+1 TINYFORMAT_PASSARGS_TAIL(n)); \ + -: 897: } + -: 898: + -: 899: TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR) + -: 900:# undef TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR + -: 901:#endif + -: 902: + -: 903: private: + -: 904: FormatArg m_formatterStore[N]; + -: 905:}; + -: 906: + -: 907:// Special 0-arg version - MSVC says zero-sized C array in struct is nonstandard + -: 908:template<> class FormatListN<0> : public FormatList + -: 909:{ + -: 910: public: FormatListN() : FormatList(0, 0) {} + -: 911:}; + -: 912: + -: 913:} // namespace detail + -: 914: + -: 915: + -: 916://------------------------------------------------------------------------------ + -: 917:// Primary API functions + -: 918: + -: 919:#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES + -: 920: + -: 921:/// Make type-agnostic format list from list of template arguments. + -: 922:/// + -: 923:/// The exact return type of this function is an implementation detail and + -: 924:/// shouldn't be relied upon. Instead it should be stored as a FormatListRef: + -: 925:/// + -: 926:/// FormatListRef formatList = makeFormatList( /*...*/ ); + -: 927:template + #####: 928:detail::FormatListN makeFormatList(const Args&... args) + -: 929:{ + #####: 930: return detail::FormatListN(args...); + -: 931:} +------------------ +_ZN10tinyformat14makeFormatListIJiEEENS_6detail11FormatListNIXsZT_EEEDpRKT_: + #####: 928:detail::FormatListN makeFormatList(const Args&... args) + -: 929:{ + #####: 930: return detail::FormatListN(args...); + -: 931:} +------------------ +_ZN10tinyformat14makeFormatListIJPKcS2_EEENS_6detail11FormatListNIXsZT_EEEDpRKT_: + #####: 928:detail::FormatListN makeFormatList(const Args&... args) + -: 929:{ + #####: 930: return detail::FormatListN(args...); + -: 931:} +------------------ + -: 932: + -: 933:#else // C++98 version + -: 934: + -: 935:inline detail::FormatListN<0> makeFormatList() + -: 936:{ + -: 937: return detail::FormatListN<0>(); + -: 938:} + -: 939:#define TINYFORMAT_MAKE_MAKEFORMATLIST(n) \ + -: 940:template \ + -: 941:detail::FormatListN makeFormatList(TINYFORMAT_VARARGS(n)) \ + -: 942:{ \ + -: 943: return detail::FormatListN(TINYFORMAT_PASSARGS(n)); \ + -: 944:} + -: 945:TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_MAKEFORMATLIST) + -: 946:#undef TINYFORMAT_MAKE_MAKEFORMATLIST + -: 947: + -: 948:#endif + -: 949: + -: 950:/// Format list of arguments to the stream according to the given format string. + -: 951:/// + -: 952:/// The name vformat() is chosen for the semantic similarity to vprintf(): the + -: 953:/// list of format arguments is held in a single function argument. + #####: 954:inline void vformat(std::ostream& out, const char* fmt, FormatListRef list) + -: 955:{ + #####: 956: detail::formatImpl(out, fmt, list.m_formatters, list.m_N); + #####: 957:} + -: 958: + -: 959: + -: 960:#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES + -: 961: + -: 962:/// Format list of arguments to the stream according to given format string. + -: 963:template + #####: 964:void format(std::ostream& out, const char* fmt, const Args&... args) + -: 965:{ + #####: 966: vformat(out, fmt, makeFormatList(args...)); + #####: 967:} +------------------ +_ZN10tinyformat6formatIJiEEEvRSoPKcDpRKT_: + #####: 964:void format(std::ostream& out, const char* fmt, const Args&... args) + -: 965:{ + #####: 966: vformat(out, fmt, makeFormatList(args...)); + #####: 967:} +------------------ +_ZN10tinyformat6formatIJPKcS2_EEEvRSoS2_DpRKT_: + #####: 964:void format(std::ostream& out, const char* fmt, const Args&... args) + -: 965:{ + #####: 966: vformat(out, fmt, makeFormatList(args...)); + #####: 967:} +------------------ + -: 968: + -: 969:/// Format list of arguments according to the given format string and return + -: 970:/// the result as a string. + -: 971:template + #####: 972:std::string format(const char* fmt, const Args&... args) + -: 973:{ + #####: 974: std::ostringstream oss; + #####: 975: format(oss, fmt, args...); + #####: 976: return oss.str(); + #####: 977:} +------------------ +_ZN10tinyformat6formatIJiEEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPKcDpRKT_: + #####: 972:std::string format(const char* fmt, const Args&... args) + -: 973:{ + #####: 974: std::ostringstream oss; + #####: 975: format(oss, fmt, args...); + #####: 976: return oss.str(); + #####: 977:} +------------------ +_ZN10tinyformat6formatIJPKcS2_EEENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES2_DpRKT_: + #####: 972:std::string format(const char* fmt, const Args&... args) + -: 973:{ + #####: 974: std::ostringstream oss; + #####: 975: format(oss, fmt, args...); + #####: 976: return oss.str(); + #####: 977:} +------------------ + -: 978: + -: 979:/// Format list of arguments to std::cout, according to the given format string + -: 980:template + -: 981:void printf(const char* fmt, const Args&... args) + -: 982:{ + -: 983: format(std::cout, fmt, args...); + -: 984:} + -: 985: + -: 986:template + -: 987:void printfln(const char* fmt, const Args&... args) + -: 988:{ + -: 989: format(std::cout, fmt, args...); + -: 990: std::cout << '\n'; + -: 991:} + -: 992: + -: 993: + -: 994:#else // C++98 version + -: 995: + -: 996:inline void format(std::ostream& out, const char* fmt) + -: 997:{ + -: 998: vformat(out, fmt, makeFormatList()); + -: 999:} + -: 1000: + -: 1001:inline std::string format(const char* fmt) + -: 1002:{ + -: 1003: std::ostringstream oss; + -: 1004: format(oss, fmt); + -: 1005: return oss.str(); + -: 1006:} + -: 1007: + -: 1008:inline void printf(const char* fmt) + -: 1009:{ + -: 1010: format(std::cout, fmt); + -: 1011:} + -: 1012: + -: 1013:inline void printfln(const char* fmt) + -: 1014:{ + -: 1015: format(std::cout, fmt); + -: 1016: std::cout << '\n'; + -: 1017:} + -: 1018: + -: 1019:#define TINYFORMAT_MAKE_FORMAT_FUNCS(n) \ + -: 1020: \ + -: 1021:template \ + -: 1022:void format(std::ostream& out, const char* fmt, TINYFORMAT_VARARGS(n)) \ + -: 1023:{ \ + -: 1024: vformat(out, fmt, makeFormatList(TINYFORMAT_PASSARGS(n))); \ + -: 1025:} \ + -: 1026: \ + -: 1027:template \ + -: 1028:std::string format(const char* fmt, TINYFORMAT_VARARGS(n)) \ + -: 1029:{ \ + -: 1030: std::ostringstream oss; \ + -: 1031: format(oss, fmt, TINYFORMAT_PASSARGS(n)); \ + -: 1032: return oss.str(); \ + -: 1033:} \ + -: 1034: \ + -: 1035:template \ + -: 1036:void printf(const char* fmt, TINYFORMAT_VARARGS(n)) \ + -: 1037:{ \ + -: 1038: format(std::cout, fmt, TINYFORMAT_PASSARGS(n)); \ + -: 1039:} \ + -: 1040: \ + -: 1041:template \ + -: 1042:void printfln(const char* fmt, TINYFORMAT_VARARGS(n)) \ + -: 1043:{ \ + -: 1044: format(std::cout, fmt, TINYFORMAT_PASSARGS(n)); \ + -: 1045: std::cout << '\n'; \ + -: 1046:} + -: 1047: + -: 1048:TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_FORMAT_FUNCS) + -: 1049:#undef TINYFORMAT_MAKE_FORMAT_FUNCS + -: 1050: + -: 1051:#endif + -: 1052: + -: 1053: + -: 1054:} // namespace tinyformat + -: 1055: + -: 1056:#endif // TINYFORMAT_H_INCLUDED + -: 1057:// #nocov end diff --git a/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#Vector.h.gcov b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#Vector.h.gcov new file mode 100644 index 0000000..19905f2 --- /dev/null +++ b/covr/RcppExports.gcno/#home#matt-fidler#R#x86_64-pc-linux-gnu-library#4.6#Rcpp#include#Rcpp#vector#Vector.h.gcov @@ -0,0 +1,1349 @@ + -: 0:Source:/home/matt-fidler/R/x86_64-pc-linux-gnu-library/4.6/Rcpp/include/Rcpp/vector/Vector.h + -: 0:Graph:./RcppExports.gcno + -: 0:Data:./RcppExports.gcda + -: 0:Runs:15 + -: 1:// Vector.h: Rcpp R/C++ interface class library -- vectors + -: 2:// + -: 3:// Copyright (C) 2010 - 2026 Dirk Eddelbuettel and Romain Francois + -: 4:// + -: 5:// This file is part of Rcpp. + -: 6:// + -: 7:// Rcpp is free software: you can redistribute it and/or modify it + -: 8:// under the terms of the GNU General Public License as published by + -: 9:// the Free Software Foundation, either version 2 of the License, or + -: 10:// (at your option) any later version. + -: 11:// + -: 12:// Rcpp is distributed in the hope that it will be useful, but + -: 13:// WITHOUT ANY WARRANTY; without even the implied warranty of + -: 14:// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + -: 15:// GNU General Public License for more details. + -: 16:// + -: 17:// You should have received a copy of the GNU General Public License + -: 18:// along with Rcpp. If not, see . + -: 19: + -: 20:#ifndef Rcpp__vector__Vector_h + -: 21:#define Rcpp__vector__Vector_h + -: 22: + -: 23:#include + -: 24: + -: 25:namespace Rcpp{ + -: 26: + -: 27:template class StoragePolicy = PreserveStorage > + -: 28:class Vector : + -: 29: public StoragePolicy< Vector >, + -: 30: public SlotProxyPolicy< Vector >, + -: 31: public AttributeProxyPolicy< Vector >, + -: 32: public NamesProxyPolicy< Vector >, + -: 33: public RObjectMethods< Vector >, + -: 34: public VectorBase< RTYPE, true, Vector > + -: 35:{ + -: 36:public: + -: 37: + -: 38: typedef StoragePolicy Storage ; + -: 39: + -: 40: typename traits::r_vector_cache_type::type cache ; + -: 41: typedef typename traits::r_vector_proxy::type Proxy ; + -: 42: typedef typename traits::r_vector_const_proxy::type const_Proxy ; + -: 43: typedef typename traits::r_vector_name_proxy::type NameProxy ; + -: 44: typedef typename traits::r_vector_proxy::type value_type ; + -: 45: typedef typename traits::r_vector_iterator::type iterator ; + -: 46: typedef typename traits::r_vector_const_iterator::type const_iterator ; + -: 47: typedef typename traits::init_type::type init_type ; + -: 48: typedef typename traits::r_vector_element_converter::type converter_type ; + -: 49: typedef typename traits::storage_type::type stored_type ; + -: 50: + -: 51: /** + -: 52: * Default constructor. Creates a vector of the appropriate type + -: 53: * and 0 length + -: 54: */ + -: 55: Vector() { + -: 56: Storage::set__( Rf_allocVector(RTYPE, 0 ) ); + -: 57: init() ; + -: 58: } + -: 59: + -: 60: /** + -: 61: * copy constructor. shallow copy of the SEXP + -: 62: */ + -: 63: Vector( const Vector& other){ + -: 64: Storage::copy__(other) ; + -: 65: } + -: 66: + -: 67: Vector& operator=(const Vector& rhs) { + -: 68: return Storage::copy__(rhs) ; + -: 69: } + -: 70: + -: 71: Vector( SEXP x ) { + -: 72: Rcpp::Shield safe(x); + -: 73: Storage::set__( r_cast(safe) ) ; + -: 74: } + -: 75: + -: 76: template + -: 77: Vector( const GenericProxy& proxy ){ + -: 78: Rcpp::Shield safe(proxy.get()); + -: 79: Storage::set__( r_cast(safe) ) ; + -: 80: } + -: 81: + -: 82: explicit Vector( const no_init_vector& obj) { + -: 83: Storage::set__( Rf_allocVector( RTYPE, obj.get() ) ) ; + -: 84: } + -: 85: + -: 86: template + -: 87: Vector( const T& size, const stored_type& u, + -: 88: typename Rcpp::traits::enable_if::value, void>::type* = 0) { + -: 89: RCPP_DEBUG_2( "Vector<%d>( const T& size = %d, const stored_type& u )", RTYPE, size) + -: 90: Storage::set__( Rf_allocVector( RTYPE, size) ) ; + -: 91: fill( u ) ; + -: 92: } + -: 93: + -: 94: Vector( const int& size, const stored_type& u) { + -: 95: RCPP_DEBUG_2( "Vector<%d>( const int& size = %d, const stored_type& u )", RTYPE, size) + -: 96: Storage::set__( Rf_allocVector( RTYPE, size) ) ; + -: 97: fill( u ) ; + -: 98: } + -: 99: + -: 100: // constructor for CharacterVector() + -: 101: Vector( const std::string& st ){ + -: 102: RCPP_DEBUG_2( "Vector<%d>( const std::string& = %s )", RTYPE, st.c_str() ) + -: 103: Storage::set__( internal::vector_from_string(st) ) ; + -: 104: } + -: 105: + -: 106: // constructor for CharacterVector() + -: 107: Vector( const char* st ) { + -: 108: RCPP_DEBUG_2( "Vector<%d>( const char* = %s )", RTYPE, st ) + -: 109: Storage::set__(internal::vector_from_string(st) ) ; + -: 110: } + -: 111: + -: 112: template + -: 113: Vector( const T& siz, stored_type (*gen)(void), + -: 114: typename Rcpp::traits::enable_if::value, void>::type* = 0) { + -: 115: RCPP_DEBUG_2( "Vector<%d>( const int& siz = %s, stored_type (*gen)(void) )", RTYPE, siz ) + -: 116: Storage::set__( Rf_allocVector( RTYPE, siz) ) ; + -: 117: std::generate( begin(), end(), gen ); + -: 118: } + -: 119: + -: 120: // Add template class T and then restict T to arithmetic. + -: 121: template + #####: 122: Vector(T size, + #####: 123: typename Rcpp::traits::enable_if::value, void>::type* = 0) { + #####: 124: Storage::set__( Rf_allocVector( RTYPE, size) ) ; + #####: 125: init() ; + #####: 126: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEEC2ImEET_PNS_6traits9enable_ifIXsrNS5_13is_arithmeticIS4_EE5valueEvE4typeE: + #####: 122: Vector(T size, + #####: 123: typename Rcpp::traits::enable_if::value, void>::type* = 0) { + #####: 124: Storage::set__( Rf_allocVector( RTYPE, size) ) ; + #####: 125: init() ; + #####: 126: } +------------------ +_ZN4Rcpp6VectorILi16ENS_15PreserveStorageEEC2ImEET_PNS_6traits9enable_ifIXsrNS5_13is_arithmeticIS4_EE5valueEvE4typeE: + #####: 122: Vector(T size, + #####: 123: typename Rcpp::traits::enable_if::value, void>::type* = 0) { + #####: 124: Storage::set__( Rf_allocVector( RTYPE, size) ) ; + #####: 125: init() ; + #####: 126: } +------------------ + -: 127: + -: 128: Vector( const int& size ) { + -: 129: Storage::set__( Rf_allocVector( RTYPE, size) ) ; + -: 130: init() ; + -: 131: } + -: 132: + -: 133: Vector( const Dimension& dims) { + -: 134: Storage::set__( Rf_allocVector( RTYPE, dims.prod() ) ) ; + -: 135: init() ; + -: 136: if( dims.size() > 1 ){ + -: 137: AttributeProxyPolicy::attr( "dim" ) = dims; + -: 138: } + -: 139: } + -: 140: + -: 141: // Enable construction from bool for LogicalVectors + -: 142: // SFINAE only work for template. Add template class T and then restict T to + -: 143: // bool. + -: 144: template + -: 145: Vector(T value, + -: 146: typename Rcpp::traits::enable_if::value && RTYPE == LGLSXP, void>::type* = 0) { + -: 147: Storage::set__(Rf_allocVector(RTYPE, 1)); + -: 148: fill(value); + -: 149: } + -: 150: + -: 151: template + -: 152: Vector( const Dimension& dims, const U& u) { + -: 153: RCPP_DEBUG_2( "Vector<%d>( const Dimension& (%d), const U& )", RTYPE, dims.size() ) + -: 154: Storage::set__( Rf_allocVector( RTYPE, dims.prod() ) ) ; + -: 155: fill(u) ; + -: 156: if( dims.size() > 1 ){ + -: 157: AttributeProxyPolicy::attr( "dim" ) = dims; + -: 158: } + -: 159: } + -: 160: + -: 161: template + -: 162: Vector( const VectorBase& other ) { + -: 163: RCPP_DEBUG_2( "Vector<%d>( const VectorBase& ) [VEC = %s]", RTYPE, DEMANGLE(VEC) ) + -: 164: import_sugar_expression( other, typename traits::same_type::type() ) ; + -: 165: } + -: 166: + -: 167: template + -: 168: Vector( const T& size, const U& u, + -: 169: typename Rcpp::traits::enable_if::value, void>::type* = 0) { + -: 170: RCPP_DEBUG_2( "Vector<%d>( const T& size, const U& u )", RTYPE, size ) + -: 171: Storage::set__( Rf_allocVector( RTYPE, size) ) ; + -: 172: fill_or_generate( u ) ; + -: 173: } + -: 174: + -: 175: template + -: 176: Vector( const sugar::SingleLogicalResult& obj ) { + -: 177: Rcpp::Shield safe(const_cast&>(obj).get_sexp() ); + -: 178: Storage::set__( r_cast(safe) ) ; + -: 179: RCPP_DEBUG_2( "Vector<%d>( const sugar::SingleLogicalResult& ) [T = %s]", RTYPE, DEMANGLE(T) ) + -: 180: } + -: 181: + -: 182: template + -: 183: Vector( const T& siz, stored_type (*gen)(U1), const U1& u1, + -: 184: typename Rcpp::traits::enable_if::value, void>::type* = 0) { + -: 185: Storage::set__( Rf_allocVector( RTYPE, siz) ) ; + -: 186: RCPP_DEBUG_2( "const T& siz, stored_type (*gen)(U1), const U1& u1 )", RTYPE, siz ) + -: 187: iterator first = begin(), last = end() ; + -: 188: while( first != last ) *first++ = gen(u1) ; + -: 189: } + -: 190: + -: 191: template + -: 192: Vector( const T& siz, stored_type (*gen)(U1,U2), const U1& u1, const U2& u2, + -: 193: typename Rcpp::traits::enable_if::value, void>::type* = 0) { + -: 194: Storage::set__( Rf_allocVector( RTYPE, siz) ) ; + -: 195: RCPP_DEBUG_2( "const T& siz, stored_type (*gen)(U1,U2), const U1& u1, const U2& u2)", RTYPE, siz ) + -: 196: iterator first = begin(), last = end() ; + -: 197: while( first != last ) *first++ = gen(u1,u2) ; + -: 198: } + -: 199: + -: 200: template + -: 201: Vector( const T& siz, stored_type (*gen)(U1,U2,U3), const U1& u1, const U2& u2, const U3& u3, + -: 202: typename Rcpp::traits::enable_if::value, void>::type* = 0) { + -: 203: Storage::set__( Rf_allocVector( RTYPE, siz) ) ; + -: 204: RCPP_DEBUG_2( "const T& siz, stored_type (*gen)(U1,U2,U3), const U1& u1, const U2& u2, const U3& u3)", RTYPE, siz ) + -: 205: iterator first = begin(), last = end() ; + -: 206: while( first != last ) *first++ = gen(u1,u2,u3) ; + -: 207: } + -: 208: + -: 209: template + -: 210: Vector( InputIterator first, InputIterator last){ + -: 211: RCPP_DEBUG_1( "Vector<%d>( InputIterator first, InputIterator last", RTYPE ) + -: 212: Storage::set__( Rf_allocVector(RTYPE, std::distance(first, last) ) ) ; + -: 213: std::copy( first, last, begin() ) ; + -: 214: } + -: 215: + -: 216: template + -: 217: Vector( InputIterator first, InputIterator last, T n, + -: 218: typename Rcpp::traits::enable_if::value, void>::type* = 0) { + -: 219: Storage::set__(Rf_allocVector(RTYPE, n)) ; + -: 220: RCPP_DEBUG_2( "Vector<%d>( InputIterator first, InputIterator last, T n = %d)", RTYPE, n ) + -: 221: std::copy( first, last, begin() ) ; + -: 222: } + -: 223: + -: 224: template + -: 225: Vector( InputIterator first, InputIterator last, Func func) { + -: 226: Storage::set__( Rf_allocVector( RTYPE, std::distance(first,last) ) ); + -: 227: RCPP_DEBUG_1( "Vector<%d>( InputIterator, InputIterator, Func )", RTYPE ) + -: 228: std::transform( first, last, begin(), func) ; + -: 229: } + -: 230: + -: 231: template + -: 232: Vector( InputIterator first, InputIterator last, Func func, T n, + -: 233: typename Rcpp::traits::enable_if::value, void>::type* = 0){ + -: 234: Storage::set__( Rf_allocVector( RTYPE, n ) ); + -: 235: RCPP_DEBUG_2( "Vector<%d>( InputIterator, InputIterator, Func, T n = %d )", RTYPE, n ) + -: 236: std::transform( first, last, begin(), func) ; + -: 237: } + -: 238: + -: 239: Vector( std::initializer_list list ) { + -: 240: assign( list.begin() , list.end() ) ; + -: 241: } + -: 242: + -: 243: template + -: 244: Vector& operator=( const T& x) { + -: 245: assign_object( x, typename traits::is_sugar_expression::type() ) ; + -: 246: return *this ; + -: 247: } + -: 248: + -: 249: static inline stored_type get_na() { + -: 250: return traits::get_na(); + -: 251: } + -: 252: static inline bool is_na( stored_type x){ + -: 253: return traits::is_na(x); + -: 254: } + -: 255: + -: 256: #ifdef RCPP_COMMA_INITIALIZATION + -: 257: internal::ListInitialization operator=( init_type x){ + -: 258: iterator start = begin() ; *start = x; + -: 259: return internal::ListInitialization( start + 1 ) ; ; + -: 260: } + -: 261: #endif + -: 262: + -: 263: /** + -: 264: * the length of the vector, uses Rf_xlength + -: 265: */ + -: 266: inline R_xlen_t length() const { + -: 267: return ::Rf_xlength( Storage::get__() ) ; + -: 268: } + -: 269: + -: 270: /** + -: 271: * alias of length + -: 272: */ + -: 273: inline R_xlen_t size() const { + -: 274: return ::Rf_xlength( Storage::get__() ) ; + -: 275: } + -: 276: + -: 277: /** + -: 278: * offset based on the dimensions of this vector + -: 279: */ + -: 280: R_xlen_t offset(const int& i, const int& j) const { + -: 281: if( !::Rf_isMatrix(Storage::get__()) ) throw not_a_matrix() ; + -: 282: + -: 283: /* we need to extract the dimensions */ + -: 284: const int* dim = dims() ; + -: 285: const int nrow = dim[0] ; + -: 286: const int ncol = dim[1] ; + -: 287: if(i < 0|| i >= nrow || j < 0 || j >= ncol ) { + -: 288: const char* fmt = "Location index is out of bounds: " + -: 289: "[row index=%i; row extent=%i; " + -: 290: "column index=%i; column extent=%i]."; + -: 291: throw index_out_of_bounds(fmt, i, nrow, j, ncol); + -: 292: } + -: 293: return i + static_cast(nrow)*j ; + -: 294: } + -: 295: + -: 296: /** + -: 297: * one dimensional offset doing bounds checking to ensure + -: 298: * it is valid + -: 299: */ + -: 300: R_xlen_t offset(const R_xlen_t& i) const { // #nocov start + -: 301: if(i < 0 || i >= ::Rf_xlength(Storage::get__()) ) { + -: 302: const char* fmt = "Index out of bounds: [index=%i; extent=%i]."; + -: 303: throw index_out_of_bounds(fmt, i, ::Rf_xlength(Storage::get__()) ) ; + -: 304: } + -: 305: return i ; // #nocov end + -: 306: } + -: 307: + -: 308: R_xlen_t offset(const std::string& name) const { + -: 309: SEXP names = RCPP_GET_NAMES( Storage::get__() ) ; + -: 310: if( Rf_isNull(names) ) { + -: 311: throw index_out_of_bounds("Object was created without names."); + -: 312: } + -: 313: + -: 314: R_xlen_t n=size() ; + -: 315: for( R_xlen_t i=0; i + -: 327: void fill( const U& u){ + -: 328: fill__dispatch( typename traits::is_trivial::type(), u ) ; + -: 329: } + -: 330: + #####: 331: inline iterator begin() { return cache.get() ; } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE5beginEv: + #####: 331: inline iterator begin() { return cache.get() ; } +------------------ +_ZN4Rcpp6VectorILi16ENS_15PreserveStorageEE5beginEv: + #####: 331: inline iterator begin() { return cache.get() ; } +------------------ + -: 332: inline iterator end() { return cache.get() + size(); } + -: 333: inline const_iterator begin() const{ return cache.get_const() ; } + -: 334: inline const_iterator end() const{ return cache.get_const() + size() ; } + -: 335: inline const_iterator cbegin() const{ return cache.get_const() ; } + -: 336: inline const_iterator cend() const{ return cache.get_const() + size() ; } + -: 337: + -: 338: inline Proxy operator[]( R_xlen_t i ){ return cache.ref(i) ; } + -: 339: inline const_Proxy operator[]( R_xlen_t i ) const { return cache.ref(i) ; } + -: 340: + -: 341: inline Proxy operator()( const size_t& i) { + -: 342: return cache.ref( offset(i) ) ; + -: 343: } + -: 344: inline const_Proxy operator()( const size_t& i) const { + -: 345: return cache.ref( offset(i) ) ; + -: 346: } + -: 347: + -: 348: inline Proxy at( const size_t& i) { // #nocov start + -: 349: return cache.ref( offset(i) ) ; + -: 350: } + -: 351: inline const_Proxy at( const size_t& i) const { + -: 352: return cache.ref( offset(i) ) ; + -: 353: } // #nocov end + -: 354: + -: 355: inline Proxy operator()( const size_t& i, const size_t& j) { + -: 356: return cache.ref( offset(i,j) ) ; + -: 357: } + -: 358: inline const_Proxy operator()( const size_t& i, const size_t& j) const { + -: 359: return cache.ref( offset(i,j) ) ; + -: 360: } + -: 361: + -: 362: inline NameProxy operator[]( const std::string& name ){ + -: 363: return NameProxy( *this, name ) ; + -: 364: } + -: 365: inline NameProxy operator()( const std::string& name ){ + -: 366: return NameProxy( *this, name ) ; + -: 367: } + -: 368: + -: 369: inline NameProxy operator[]( const std::string& name ) const { + -: 370: return NameProxy( const_cast(*this), name ) ; + -: 371: } + -: 372: inline NameProxy operator()( const std::string& name ) const { + -: 373: return NameProxy( const_cast(*this), name ) ; + -: 374: } + -: 375: + -: 376: inline operator RObject() const { + -: 377: return RObject( Storage::get__() ); + -: 378: } + -: 379: + -: 380: // sugar subsetting requires dispatch on VectorBase + -: 381: template + -: 382: SubsetProxy + -: 383: operator[](const VectorBase& rhs) { + -: 384: return SubsetProxy( + -: 385: *this, + -: 386: rhs + -: 387: ); + -: 388: } + -: 389: + -: 390: template + -: 391: const SubsetProxy + -: 392: operator[](const VectorBase& rhs) const { + -: 393: return SubsetProxy( + -: 394: const_cast< Vector& >(*this), + -: 395: rhs + -: 396: ); + -: 397: } + -: 398: + -: 399: Vector& sort(bool decreasing = false) { + -: 400: // sort() does not apply to List, RawVector or ExpressionVector. + -: 401: // + -: 402: // The function below does nothing for qualified Vector types, + -: 403: // and is undefined for other types. Hence there will be a + -: 404: // compiler error when sorting List, RawVector or ExpressionVector. + -: 405: internal::Sort_is_not_allowed_for_this_type::do_nothing(); + -: 406: + -: 407: typename traits::storage_type::type* start = internal::r_vector_start( Storage::get__() ); + -: 408: + -: 409: if (!decreasing) { + -: 410: std::sort( + -: 411: start, + -: 412: start + size(), + -: 413: internal::NAComparator::type>() + -: 414: ); + -: 415: } else { + -: 416: std::sort( + -: 417: start, + -: 418: start + size(), + -: 419: internal::NAComparatorGreater::type>() + -: 420: ); + -: 421: } + -: 422: + -: 423: return *this; + -: 424: } + -: 425: + -: 426: template + -: 427: void assign( InputIterator first, InputIterator last){ + -: 428: /* FIXME: we can do better than this r_cast to avoid + -: 429: allocating an unnecessary temporary object + -: 430: */ + -: 431: Shield wrapped(wrap(first, last)); + -: 432: Shield casted(r_cast(wrapped)); + -: 433: Storage::set__(casted) ; + -: 434: } + -: 435: + -: 436: template + -: 437: static Vector import( InputIterator first, InputIterator last){ + -: 438: Vector v ; + -: 439: v.assign( first , last ) ; + -: 440: return v ; + -: 441: } + -: 442: + -: 443: template + -: 444: static Vector import_transform( InputIterator first, InputIterator last, F f){ + -: 445: return Vector( first, last, f) ; + -: 446: } + -: 447: + -: 448: template + -: 449: void push_back( const T& object){ + -: 450: push_back__impl( converter_type::get(object), + -: 451: typename traits::same_type() + -: 452: ) ; + -: 453: } + -: 454: + -: 455: template + -: 456: void push_back( const T& object, const std::string& name ){ + -: 457: push_back_name__impl( converter_type::get(object), name, + -: 458: typename traits::same_type() + -: 459: ) ; + -: 460: } + -: 461: + -: 462: template + -: 463: void push_front( const T& object){ + -: 464: push_front__impl( converter_type::get(object), + -: 465: typename traits::same_type() ) ; + -: 466: } + -: 467: + -: 468: template + -: 469: void push_front( const T& object, const std::string& name){ + -: 470: push_front_name__impl( converter_type::get(object), name, + -: 471: typename traits::same_type() ) ; + -: 472: } + -: 473: + -: 474: + -: 475: template + -: 476: iterator insert( iterator position, const T& object){ + -: 477: return insert__impl( position, converter_type::get(object), + -: 478: typename traits::same_type() + -: 479: ) ; + -: 480: } + -: 481: + -: 482: template + -: 483: iterator insert( int position, const T& object){ + -: 484: return insert__impl( cache.get() + position, converter_type::get(object), + -: 485: typename traits::same_type() + -: 486: ); + -: 487: } + -: 488: + -: 489: iterator erase( int position){ + -: 490: return erase_single__impl( cache.get() + position) ; + -: 491: } + -: 492: + -: 493: iterator erase( iterator position){ + -: 494: return erase_single__impl( position ) ; + -: 495: } + -: 496: + -: 497: iterator erase( int first, int last){ + -: 498: iterator start = cache.get() ; + -: 499: return erase_range__impl( start + first, start + last ) ; + -: 500: } + -: 501: + -: 502: iterator erase( iterator first, iterator last){ + -: 503: return erase_range__impl( first, last ) ; + -: 504: } + -: 505: + 270*: 506: void update(SEXP){ + 270*: 507: cache.update(*this) ; + 270*: 508: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE6updateEP7SEXPREC: + 270: 506: void update(SEXP){ + 270: 507: cache.update(*this) ; + 270: 508: } +------------------ +_ZN4Rcpp6VectorILi16ENS_15PreserveStorageEE6updateEP7SEXPREC: + #####: 506: void update(SEXP){ + #####: 507: cache.update(*this) ; + #####: 508: } +------------------ + -: 509: + -: 510: template + #####: 511: static void replace_element( iterator it, SEXP names, R_xlen_t index, const U& u){ + #####: 512: replace_element__dispatch( typename traits::is_named::type(), + -: 513: it, names, index, u ) ; + #####: 514: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE15replace_elementINS_6traits12named_objectINS0_ILi16ES1_EEEEEEvNS_8internal14Proxy_IteratorINS8_13generic_proxyILi19ES1_EEEEP7SEXPREClRKT_: + #####: 511: static void replace_element( iterator it, SEXP names, R_xlen_t index, const U& u){ + #####: 512: replace_element__dispatch( typename traits::is_named::type(), + -: 513: it, names, index, u ) ; + #####: 514: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE15replace_elementINS_6traits12named_objectIiEEEEvNS_8internal14Proxy_IteratorINS7_13generic_proxyILi19ES1_EEEEP7SEXPREClRKT_: + #####: 511: static void replace_element( iterator it, SEXP names, R_xlen_t index, const U& u){ + #####: 512: replace_element__dispatch( typename traits::is_named::type(), + -: 513: it, names, index, u ) ; + #####: 514: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE15replace_elementINS_6traits12named_objectIA1_cEEEEvNS_8internal14Proxy_IteratorINS8_13generic_proxyILi19ES1_EEEEP7SEXPREClRKT_: + #####: 511: static void replace_element( iterator it, SEXP names, R_xlen_t index, const U& u){ + #####: 512: replace_element__dispatch( typename traits::is_named::type(), + -: 513: it, names, index, u ) ; + #####: 514: } +------------------ + -: 515: + -: 516: template + -: 517: static void replace_element__dispatch( traits::false_type, iterator it, SEXP names, R_xlen_t index, const U& u){ + -: 518: *it = converter_type::get(u); + -: 519: } + -: 520: + -: 521: template + #####: 522: static void replace_element__dispatch( traits::true_type, iterator it, SEXP names, R_xlen_t index, const U& u){ + #####: 523: replace_element__dispatch__isArgument( typename traits::same_type(), it, names, index, u ) ; + #####: 524: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE25replace_element__dispatchINS_6traits12named_objectINS0_ILi16ES1_EEEEEEvNS4_17integral_constantIbLb1EEENS_8internal14Proxy_IteratorINSA_13generic_proxyILi19ES1_EEEEP7SEXPREClRKT_: + #####: 522: static void replace_element__dispatch( traits::true_type, iterator it, SEXP names, R_xlen_t index, const U& u){ + #####: 523: replace_element__dispatch__isArgument( typename traits::same_type(), it, names, index, u ) ; + #####: 524: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE25replace_element__dispatchINS_6traits12named_objectIiEEEEvNS4_17integral_constantIbLb1EEENS_8internal14Proxy_IteratorINS9_13generic_proxyILi19ES1_EEEEP7SEXPREClRKT_: + #####: 522: static void replace_element__dispatch( traits::true_type, iterator it, SEXP names, R_xlen_t index, const U& u){ + #####: 523: replace_element__dispatch__isArgument( typename traits::same_type(), it, names, index, u ) ; + #####: 524: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE25replace_element__dispatchINS_6traits12named_objectIA1_cEEEEvNS4_17integral_constantIbLb1EEENS_8internal14Proxy_IteratorINSA_13generic_proxyILi19ES1_EEEEP7SEXPREClRKT_: + #####: 522: static void replace_element__dispatch( traits::true_type, iterator it, SEXP names, R_xlen_t index, const U& u){ + #####: 523: replace_element__dispatch__isArgument( typename traits::same_type(), it, names, index, u ) ; + #####: 524: } +------------------ + -: 525: + -: 526: template + #####: 527: static void replace_element__dispatch__isArgument( traits::false_type, iterator it, SEXP names, R_xlen_t index, const U& u){ + -: 528: RCPP_DEBUG_2( " Vector::replace_element__dispatch<%s>(true, index= %d) ", DEMANGLE(U), index ) ; + -: 529: + #####: 530: *it = converter_type::get(u.object ) ; + #####: 531: SET_STRING_ELT( names, index, ::Rf_mkChar( u.name.c_str() ) ) ; + #####: 532: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE37replace_element__dispatch__isArgumentINS_6traits12named_objectINS0_ILi16ES1_EEEEEEvNS4_17integral_constantIbLb0EEENS_8internal14Proxy_IteratorINSA_13generic_proxyILi19ES1_EEEEP7SEXPREClRKT_: + #####: 527: static void replace_element__dispatch__isArgument( traits::false_type, iterator it, SEXP names, R_xlen_t index, const U& u){ + -: 528: RCPP_DEBUG_2( " Vector::replace_element__dispatch<%s>(true, index= %d) ", DEMANGLE(U), index ) ; + -: 529: + #####: 530: *it = converter_type::get(u.object ) ; + #####: 531: SET_STRING_ELT( names, index, ::Rf_mkChar( u.name.c_str() ) ) ; + #####: 532: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE37replace_element__dispatch__isArgumentINS_6traits12named_objectIiEEEEvNS4_17integral_constantIbLb0EEENS_8internal14Proxy_IteratorINS9_13generic_proxyILi19ES1_EEEEP7SEXPREClRKT_: + #####: 527: static void replace_element__dispatch__isArgument( traits::false_type, iterator it, SEXP names, R_xlen_t index, const U& u){ + -: 528: RCPP_DEBUG_2( " Vector::replace_element__dispatch<%s>(true, index= %d) ", DEMANGLE(U), index ) ; + -: 529: + #####: 530: *it = converter_type::get(u.object ) ; + #####: 531: SET_STRING_ELT( names, index, ::Rf_mkChar( u.name.c_str() ) ) ; + #####: 532: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE37replace_element__dispatch__isArgumentINS_6traits12named_objectIA1_cEEEEvNS4_17integral_constantIbLb0EEENS_8internal14Proxy_IteratorINSA_13generic_proxyILi19ES1_EEEEP7SEXPREClRKT_: + #####: 527: static void replace_element__dispatch__isArgument( traits::false_type, iterator it, SEXP names, R_xlen_t index, const U& u){ + -: 528: RCPP_DEBUG_2( " Vector::replace_element__dispatch<%s>(true, index= %d) ", DEMANGLE(U), index ) ; + -: 529: + #####: 530: *it = converter_type::get(u.object ) ; + #####: 531: SET_STRING_ELT( names, index, ::Rf_mkChar( u.name.c_str() ) ) ; + #####: 532: } +------------------ + -: 533: + -: 534: template + -: 535: static void replace_element__dispatch__isArgument( traits::true_type, iterator it, SEXP names, R_xlen_t index, const U& u){ + -: 536: RCPP_DEBUG_2( " Vector::replace_element__dispatch<%s>(true, index= %d) ", DEMANGLE(U), index ) ; + -: 537: + -: 538: *it = R_MissingArg ; + -: 539: SET_STRING_ELT( names, index, ::Rf_mkChar( u.name.c_str() ) ) ; + -: 540: } + -: 541: + -: 542: typedef internal::RangeIndexer Indexer ; + -: 543: + -: 544: inline Indexer operator[]( const Range& range ){ + -: 545: return Indexer( const_cast(*this), range ); + -: 546: } + -: 547: + -: 548: template + -: 549: Vector& operator+=( const VectorBase& rhs ) { + -: 550: const EXPR_VEC& ref = rhs.get_ref() ; + -: 551: iterator start = begin() ; + -: 552: R_xlen_t n = size() ; + -: 553: // TODO: maybe unroll this + -: 554: stored_type tmp ; + -: 555: for( R_xlen_t i=0; i( left ) ){ + -: 558: tmp = ref[i] ; + -: 559: left = traits::is_na( tmp ) ? tmp : ( left + tmp ) ; + -: 560: } + -: 561: } + -: 562: return *this ; + -: 563: } + -: 564: + -: 565: template + -: 566: Vector& operator+=( const VectorBase& rhs ) { + -: 567: const EXPR_VEC& ref = rhs.get_ref() ; + -: 568: iterator start = begin() ; + -: 569: R_xlen_t n = size() ; + -: 570: stored_type tmp ; + -: 571: for( R_xlen_t i=0; i(start[i]) ){ + -: 573: start[i] += ref[i] ; + -: 574: } + -: 575: } + -: 576: return *this ; + -: 577: + -: 578: } + -: 579: + -: 580: /** + -: 581: * Does this vector have an element with the target name + -: 582: */ + -: 583: bool containsElementNamed( const char* target ) const { + -: 584: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 585: if( Rf_isNull(names) ) return false ; + -: 586: R_xlen_t n = Rf_xlength(names) ; + -: 587: for( R_xlen_t i=0; i::init( SEXP = <%p> )", RTYPE, Storage::get__() ) + #####: 616: internal::r_init_vector(Storage::get__()) ; + #####: 617: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE4initEv: + #####: 614: void init(){ + -: 615: RCPP_DEBUG_2( "VECTOR<%d>::init( SEXP = <%p> )", RTYPE, Storage::get__() ) + #####: 616: internal::r_init_vector(Storage::get__()) ; + #####: 617: } +------------------ +_ZN4Rcpp6VectorILi16ENS_15PreserveStorageEE4initEv: + #####: 614: void init(){ + -: 615: RCPP_DEBUG_2( "VECTOR<%d>::init( SEXP = <%p> )", RTYPE, Storage::get__() ) + #####: 616: internal::r_init_vector(Storage::get__()) ; + #####: 617: } +------------------ + -: 618: + -: 619:private: + -: 620: + -: 621: void push_back__impl(const stored_type& object, traits::true_type ) { + -: 622: Shield object_sexp( object ) ; + -: 623: R_xlen_t n = size() ; + -: 624: Vector target( n + 1 ) ; + -: 625: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 626: iterator target_it( target.begin() ) ; + -: 627: iterator it(begin()) ; + -: 628: iterator this_end(end()); + -: 629: if( Rf_isNull(names) ){ + -: 630: for( ; it < this_end; ++it, ++target_it ){ + -: 631: *target_it = *it ; // #nocov start + -: 632: } + -: 633: } else { + -: 634: Shield newnames( ::Rf_allocVector( STRSXP, n + 1) ) ; + -: 635: int i = 0 ; + -: 636: for( ; it < this_end; ++it, ++target_it, i++ ){ + -: 637: *target_it = *it ; + -: 638: SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) ) ; + -: 639: } + -: 640: SET_STRING_ELT( newnames, i, Rf_mkChar("") ) ; + -: 641: target.attr("names") = newnames ; // #nocov end + -: 642: } + -: 643: *target_it = object_sexp; + -: 644: Storage::set__( target.get__() ) ; + -: 645: } + -: 646: + -: 647: void push_back__impl(const stored_type& object, traits::false_type ) { + -: 648: R_xlen_t n = size() ; + -: 649: Vector target( n + 1 ) ; + -: 650: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 651: iterator target_it( target.begin() ) ; + -: 652: iterator it(begin()) ; + -: 653: iterator this_end(end()); + -: 654: if( Rf_isNull(names) ){ + -: 655: for( ; it < this_end; ++it, ++target_it ){ + -: 656: *target_it = *it ; + -: 657: } + -: 658: } else { + -: 659: Shield newnames( ::Rf_allocVector( STRSXP, n + 1) ) ; + -: 660: int i = 0 ; + -: 661: for( ; it < this_end; ++it, ++target_it, i++ ){ + -: 662: *target_it = *it ; + -: 663: SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) ) ; + -: 664: } + -: 665: SET_STRING_ELT( newnames, i, Rf_mkChar("") ) ; + -: 666: target.attr("names") = newnames ; + -: 667: } + -: 668: *target_it = object; + -: 669: Storage::set__( target.get__() ) ; + -: 670: } + -: 671: + -: 672: void push_back_name__impl(const stored_type& object, const std::string& name, traits::true_type ) { + -: 673: Shield object_sexp( object ) ; + -: 674: R_xlen_t n = size() ; + -: 675: Vector target( n + 1 ) ; + -: 676: iterator target_it( target.begin() ) ; + -: 677: iterator it(begin()) ; + -: 678: iterator this_end(end()); + -: 679: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 680: Shield newnames( ::Rf_allocVector( STRSXP, n+1 ) ) ; + -: 681: int i=0; + -: 682: if( Rf_isNull(names) ){ + -: 683: for( ; it < this_end; ++it, ++target_it,i++ ){ + -: 684: *target_it = *it ; // #nocov + -: 685: SET_STRING_ELT( newnames, i , R_BlankString ); // #nocov + -: 686: } + -: 687: } else { + -: 688: for( ; it < this_end; ++it, ++target_it, i++ ){ + -: 689: *target_it = *it ; + -: 690: SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) ) ; + -: 691: } + -: 692: } + -: 693: SET_STRING_ELT( newnames, i, Rf_mkChar( name.c_str() ) ); + -: 694: target.attr("names") = newnames ; + -: 695: + -: 696: *target_it = object_sexp; + -: 697: Storage::set__( target.get__() ) ; + -: 698: } + -: 699: void push_back_name__impl(const stored_type& object, const std::string& name, traits::false_type ) { + -: 700: R_xlen_t n = size() ; + -: 701: Vector target( n + 1 ) ; + -: 702: iterator target_it( target.begin() ) ; + -: 703: iterator it(begin()) ; + -: 704: iterator this_end(end()); + -: 705: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 706: Shield newnames( ::Rf_allocVector( STRSXP, n+1 ) ) ; + -: 707: int i=0; + -: 708: if( Rf_isNull(names) ){ + -: 709: Shield dummy( Rf_mkChar("") ); + -: 710: for( ; it < this_end; ++it, ++target_it,i++ ){ + -: 711: *target_it = *it ; + -: 712: SET_STRING_ELT( newnames, i , dummy ); + -: 713: } + -: 714: } else { + -: 715: for( ; it < this_end; ++it, ++target_it, i++ ){ + -: 716: *target_it = *it ; + -: 717: SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) ) ; + -: 718: } + -: 719: } + -: 720: SET_STRING_ELT( newnames, i, Rf_mkChar( name.c_str() ) ); + -: 721: target.attr("names") = newnames ; + -: 722: + -: 723: *target_it = object; + -: 724: Storage::set__( target.get__() ) ; + -: 725: } + -: 726: + -: 727: void push_front__impl(const stored_type& object, traits::true_type ) { + -: 728: Shield object_sexp( object ) ; + -: 729: R_xlen_t n = size() ; + -: 730: Vector target( n+1); + -: 731: iterator target_it(target.begin()); + -: 732: iterator it(begin()); + -: 733: iterator this_end(end()); + -: 734: *target_it = object_sexp ; + -: 735: ++target_it ; + -: 736: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 737: if( Rf_isNull(names) ){ + -: 738: for( ; it newnames( ::Rf_allocVector( STRSXP, n + 1) ); + -: 743: int i=1 ; + -: 744: SET_STRING_ELT( newnames, 0, Rf_mkChar("") ) ; + -: 745: for( ; it newnames( ::Rf_allocVector( STRSXP, n + 1) ); + -: 769: int i=1 ; + -: 770: SET_STRING_ELT( newnames, 0, Rf_mkChar("") ) ; + -: 771: for( ; it object_sexp(object) ; + -: 783: R_xlen_t n = size() ; + -: 784: Vector target( n + 1 ) ; + -: 785: iterator target_it( target.begin() ) ; + -: 786: iterator it(begin()) ; + -: 787: iterator this_end(end()); + -: 788: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 789: Shield newnames( ::Rf_allocVector( STRSXP, n+1 ) ) ; + -: 790: int i=1; + -: 791: SET_STRING_ELT( newnames, 0, Rf_mkChar( name.c_str() ) ); + -: 792: *target_it = object_sexp; + -: 793: ++target_it ; + -: 794: + -: 795: if( Rf_isNull(names) ){ + -: 796: for( ; it < this_end; ++it, ++target_it,i++ ){ + -: 797: *target_it = *it ; + -: 798: SET_STRING_ELT( newnames, i , R_BlankString ); + -: 799: } + -: 800: } else { + -: 801: for( ; it < this_end; ++it, ++target_it, i++ ){ + -: 802: *target_it = *it ; + -: 803: SET_STRING_ELT( newnames, i, STRING_ELT(names, i-1 ) ) ; + -: 804: } + -: 805: } + -: 806: target.attr("names") = newnames ; + -: 807: Storage::set__( target.get__() ) ; + -: 808: + -: 809: } + -: 810: void push_front_name__impl(const stored_type& object, const std::string& name, traits::false_type ) { + -: 811: R_xlen_t n = size() ; + -: 812: Vector target( n + 1 ) ; + -: 813: iterator target_it( target.begin() ) ; + -: 814: iterator it(begin()) ; + -: 815: iterator this_end(end()); + -: 816: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 817: Shield newnames( ::Rf_allocVector( STRSXP, n+1 ) ) ; + -: 818: int i=1; + -: 819: SET_STRING_ELT( newnames, 0, Rf_mkChar( name.c_str() ) ); + -: 820: *target_it = object; + -: 821: ++target_it ; + -: 822: + -: 823: if( Rf_isNull(names) ){ + -: 824: for( ; it < this_end; ++it, ++target_it,i++ ){ + -: 825: *target_it = *it ; + -: 826: SET_STRING_ELT( newnames, i , R_BlankString ); + -: 827: } + -: 828: } else { + -: 829: for( ; it < this_end; ++it, ++target_it, i++ ){ + -: 830: *target_it = *it ; + -: 831: SET_STRING_ELT( newnames, i, STRING_ELT(names, i-1 ) ) ; + -: 832: } + -: 833: } + -: 834: target.attr("names") = newnames ; + -: 835: + -: 836: Storage::set__( target.get__() ) ; + -: 837: + -: 838: } + -: 839: + -: 840: iterator insert__impl( iterator position, const stored_type& object_, traits::true_type ) { + -: 841: Shield object( object_ ) ; + -: 842: R_xlen_t n = size() ; + -: 843: Vector target( n+1 ) ; + -: 844: iterator target_it = target.begin(); + -: 845: iterator it = begin() ; + -: 846: iterator this_end = end() ; + -: 847: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 848: iterator result ; + -: 849: if( Rf_isNull(names) ){ + -: 850: for( ; it < position; ++it, ++target_it){ + -: 851: *target_it = *it ; + -: 852: } + -: 853: result = target_it; + -: 854: *target_it = object ; + -: 855: ++target_it ; + -: 856: for( ; it < this_end; ++it, ++target_it ){ + -: 857: *target_it = *it ; + -: 858: } + -: 859: } else{ + -: 860: Shield newnames( ::Rf_allocVector( STRSXP, n + 1 ) ) ; + -: 861: int i=0; + -: 862: for( ; it < position; ++it, ++target_it, i++){ + -: 863: *target_it = *it ; + -: 864: SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) ) ; + -: 865: } + -: 866: result = target_it; + -: 867: *target_it = object ; + -: 868: SET_STRING_ELT( newnames, i, ::Rf_mkChar("") ) ; + -: 869: i++ ; + -: 870: ++target_it ; + -: 871: for( ; it < this_end; ++it, ++target_it, i++ ){ + -: 872: *target_it = *it ; + -: 873: SET_STRING_ELT( newnames, i, STRING_ELT(names, i - 1) ) ; + -: 874: } + -: 875: target.attr( "names" ) = newnames ; + -: 876: } + -: 877: Storage::set__( target.get__() ) ; + -: 878: return result ; + -: 879: } + -: 880: + -: 881: iterator insert__impl( iterator position, const stored_type& object, traits::false_type ) { + -: 882: R_xlen_t n = size() ; + -: 883: Vector target( n+1 ) ; + -: 884: iterator target_it = target.begin(); + -: 885: iterator it = begin() ; + -: 886: iterator this_end = end() ; + -: 887: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 888: iterator result ; + -: 889: if( Rf_isNull(names) ){ + -: 890: for( ; it < position; ++it, ++target_it){ + -: 891: *target_it = *it ; + -: 892: } + -: 893: result = target_it; + -: 894: *target_it = object ; + -: 895: ++target_it ; + -: 896: for( ; it < this_end; ++it, ++target_it ){ + -: 897: *target_it = *it ; + -: 898: } + -: 899: } else{ + -: 900: Shield newnames( ::Rf_allocVector( STRSXP, n + 1 ) ) ; + -: 901: int i=0; + -: 902: for( ; it < position; ++it, ++target_it, i++){ + -: 903: *target_it = *it ; + -: 904: SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) ) ; + -: 905: } + -: 906: result = target_it; + -: 907: *target_it = object ; + -: 908: SET_STRING_ELT( newnames, i, ::Rf_mkChar("") ) ; + -: 909: i++ ; + -: 910: ++target_it ; + -: 911: for( ; it < this_end; ++it, ++target_it, i++ ){ + -: 912: *target_it = *it ; + -: 913: SET_STRING_ELT( newnames, i, STRING_ELT(names, i - 1) ) ; + -: 914: } + -: 915: target.attr( "names" ) = newnames ; + -: 916: } + -: 917: Storage::set__( target.get__() ) ; + -: 918: return result ; + -: 919: } + -: 920: + -: 921: iterator erase_single__impl( iterator position ) { + -: 922: if( position < begin() || position > end() ) { + -: 923: R_xlen_t requested_loc; + -: 924: R_xlen_t available_locs = std::distance(begin(), end()); + -: 925: + -: 926: if(position > end()){ + -: 927: requested_loc = std::distance(position, begin()); + -: 928: } else { + -: 929: // This will be a negative number + -: 930: requested_loc = std::distance(begin(), position); + -: 931: } + -: 932: const char* fmt = "Iterator index is out of bounds: " + -: 933: "[iterator index=%i; iterator extent=%i]"; + -: 934: throw index_out_of_bounds(fmt, requested_loc, available_locs ) ; + -: 935: } + -: 936: + -: 937: R_xlen_t n = size() ; + -: 938: + -: 939: Vector target( n - 1 ) ; + -: 940: iterator target_it(target.begin()) ; + -: 941: iterator it(begin()) ; + -: 942: iterator this_end(end()) ; + -: 943: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 944: if( Rf_isNull(names) ){ + -: 945: int i=0; + -: 946: for( ; it < position; ++it, ++target_it, i++){ + -: 947: *target_it = *it; + -: 948: } + -: 949: ++it ; + -: 950: for( ; it < this_end ; ++it, ++target_it){ + -: 951: *target_it = *it; + -: 952: } + -: 953: Storage::set__( target.get__() ) ; + -: 954: return begin()+i ; + -: 955: } else { + -: 956: Shield newnames(::Rf_allocVector( STRSXP, n-1 )); + -: 957: int i= 0 ; + -: 958: for( ; it < position; ++it, ++target_it,i++){ + -: 959: *target_it = *it; + -: 960: SET_STRING_ELT( newnames, i , STRING_ELT(names,i) ) ; + -: 961: } + -: 962: int result=i ; + -: 963: ++it ; + -: 964: i++ ; + -: 965: for( ; it < this_end ; ++it, ++target_it, i++){ + -: 966: *target_it = *it; + -: 967: SET_STRING_ELT( newnames, i-1, STRING_ELT(names,i) ) ; + -: 968: } + -: 969: target.attr( "names" ) = newnames ; + -: 970: Storage::set__( target.get__() ) ; + -: 971: return begin()+result ; + -: 972: } + -: 973: } + -: 974: + -: 975: iterator erase_range__impl( iterator first, iterator last ) { + -: 976: if( first > last ) throw std::range_error("invalid range") ; + -: 977: if( last > end() || first < begin() ) { + -: 978: R_xlen_t requested_loc; + -: 979: R_xlen_t available_locs = std::distance(begin(), end()); + -: 980: std::string iter_problem; + -: 981: + -: 982: if(last > end()){ + -: 983: requested_loc = std::distance(last, begin()); + -: 984: iter_problem = "last"; + -: 985: } else { + -: 986: // This will be a negative number + -: 987: requested_loc = std::distance(begin(), first); + -: 988: iter_problem = "first"; + -: 989: } + -: 990: const char* fmt = "Iterator index is out of bounds: " + -: 991: "[iterator=%s; index=%i; extent=%i]"; + -: 992: throw index_out_of_bounds(fmt, iter_problem, + -: 993: requested_loc, available_locs ) ; + -: 994: } + -: 995: + -: 996: iterator it = begin() ; + -: 997: iterator this_end = end() ; + -: 998: R_xlen_t nremoved = std::distance(first,last) ; + -: 999: R_xlen_t target_size = size() - nremoved ; + -: 1000: Vector target( target_size ) ; + -: 1001: iterator target_it = target.begin() ; + -: 1002: + -: 1003: SEXP names = RCPP_GET_NAMES(Storage::get__()) ; + -: 1004: int result = 0; + -: 1005: if( Rf_isNull(names) ){ + -: 1006: int i=0; + -: 1007: for( ; it < first; ++it, ++target_it, i++ ){ + -: 1008: *target_it = *it ; + -: 1009: } + -: 1010: result = i; + -: 1011: for( it = last ; it < this_end; ++it, ++target_it ){ + -: 1012: *target_it = *it ; + -: 1013: } + -: 1014: } else{ + -: 1015: Shield newnames( ::Rf_allocVector(STRSXP, target_size) ) ; + -: 1016: int i= 0 ; + -: 1017: for( ; it < first; ++it, ++target_it, i++ ){ + -: 1018: *target_it = *it ; + -: 1019: SET_STRING_ELT( newnames, i, STRING_ELT(names, i ) ); + -: 1020: } + -: 1021: result = i; + -: 1022: for( it = last ; it < this_end; ++it, ++target_it, i++ ){ + -: 1023: *target_it = *it ; + -: 1024: SET_STRING_ELT( newnames, i, STRING_ELT(names, i + nremoved ) ); + -: 1025: } + -: 1026: target.attr("names" ) = newnames ; + -: 1027: } + -: 1028: Storage::set__( target.get__() ) ; + -: 1029: + -: 1030: return begin() + result; + -: 1031: + -: 1032: } + -: 1033: + -: 1034: template + -: 1035: inline void assign_sugar_expression( const T& x ) { + -: 1036: R_xlen_t n = size() ; + -: 1037: if( n == x.size() ){ + -: 1038: // just copy the data + -: 1039: import_expression(x, n ) ; + -: 1040: } else{ + -: 1041: // different size, so we change the memory + -: 1042: Shield wrapped(wrap(x)); + -: 1043: Shield casted(r_cast(wrapped)); + -: 1044: Storage::set__(casted); + -: 1045: } + -: 1046: } + -: 1047: + -: 1048: // sugar + -: 1049: template + -: 1050: inline void assign_object( const T& x, traits::true_type ) { + -: 1051: assign_sugar_expression( x.get_ref() ) ; + -: 1052: } + -: 1053: + -: 1054: // anything else + -: 1055: template + -: 1056: inline void assign_object( const T& x, traits::false_type ) { + -: 1057: Shield wrapped(wrap(x)); + -: 1058: Shield casted(r_cast(wrapped)); + -: 1059: Storage::set__(casted); + -: 1060: } + -: 1061: + -: 1062: // we are importing a real sugar expression, i.e. not a vector + -: 1063: template + -: 1064: inline void import_sugar_expression( const Rcpp::VectorBase& other, traits::false_type ) { + -: 1065: RCPP_DEBUG_4( "Vector<%d>::import_sugar_expression( VectorBase<%d,%d,%s>, false_type )", RTYPE, NA, RTYPE, DEMANGLE(VEC) ) ; + -: 1066: R_xlen_t n = other.size() ; + -: 1067: Storage::set__( Rf_allocVector( RTYPE, n ) ) ; + -: 1068: import_expression( other.get_ref() , n ) ; + -: 1069: } + -: 1070: + -: 1071: // we are importing a sugar expression that actually is a vector + -: 1072: template + -: 1073: inline void import_sugar_expression( const Rcpp::VectorBase& other, traits::true_type ) { + -: 1074: RCPP_DEBUG_4( "Vector<%d>::import_sugar_expression( VectorBase<%d,%d,%s>, true_type )", RTYPE, NA, RTYPE, DEMANGLE(VEC) ) ; + -: 1075: Storage::set__( other.get_ref() ) ; + -: 1076: } + -: 1077: + -: 1078: + -: 1079: template + -: 1080: inline void import_expression( const T& other, R_xlen_t n ) { + -: 1081: iterator start = begin() ; + -: 1082: RCPP_LOOP_UNROLL(start,other) + -: 1083: } + -: 1084: + -: 1085: template + -: 1086: inline void fill_or_generate( const T& t) { + -: 1087: fill_or_generate__impl( t, typename traits::is_generator::type() ) ; + -: 1088: } + -: 1089: + -: 1090: template + -: 1091: inline void fill_or_generate__impl( const T& gen, traits::true_type) { + -: 1092: iterator first = begin() ; + -: 1093: iterator last = end() ; + -: 1094: while( first != last ) *first++ = gen() ; + -: 1095: } + -: 1096: + -: 1097: template + -: 1098: inline void fill_or_generate__impl( const T& t, traits::false_type) { + -: 1099: fill(t) ; + -: 1100: } + -: 1101: + -: 1102: template + -: 1103: void fill__dispatch( traits::false_type, const U& u){ + -: 1104: // when this is not trivial, this is SEXP + -: 1105: Shield elem( converter_type::get( u ) ); + -: 1106: iterator it(begin()); + -: 1107: for( R_xlen_t i=0; i + -: 1113: void fill__dispatch( traits::true_type, const U& u){ + -: 1114: std::fill( begin(), end(), converter_type::get( u ) ) ; + -: 1115: } + -: 1116: + -: 1117:public: + -: 1118: + -: 1119: static Vector create(){ + -: 1120: return Vector( 0 ) ; + -: 1121: } + -: 1122: + -: 1123:public: + -: 1124: template + #####: 1125: static Vector create(const T&... t){ + -: 1126: return create__dispatch( typename traits::integral_constant::value + #####: 1128: >::type(), t... ) ; + -: 1129: } + -: 1130: + -: 1131:private: + -: 1132: template + -: 1133: static Vector create__dispatch(traits::false_type, const T&... t){ + -: 1134: Vector res(sizeof...(T)) ; + -: 1135: iterator it(res.begin()); + -: 1136: create_dispatch_impl(it, t...); + -: 1137: return res; + -: 1138: } + -: 1139: + -: 1140: template + #####: 1141: static Vector create__dispatch( traits::true_type, const T&... t) { + #####: 1142: Vector res(sizeof...(T)) ; + #####: 1143: Shield names(::Rf_allocVector(STRSXP, sizeof...(T))); + #####: 1144: int index = 0; + #####: 1145: iterator it(res.begin()); + #####: 1146: replace_element_impl(it, names, index, t...); + #####: 1147: res.attr("names") = names; + #####: 1148: return res; + #####: 1149: } + -: 1150: + -: 1151: template + -: 1152: static void create_dispatch_impl(iterator& it, const T& t) { + -: 1153: *it = converter_type::get(t); + -: 1154: } + -: 1155: + -: 1156: template + -: 1157: static void create_dispatch_impl(iterator& it, const T& t, const TArgs&... args) { + -: 1158: *it = converter_type::get(t); + -: 1159: create_dispatch_impl(++it, args...); + -: 1160: } + -: 1161: + -: 1162: template + #####: 1163: static void replace_element_impl(iterator& it, Shield& names, int& index, const T& t) { + #####: 1164: replace_element(it, names, index, t); + #####: 1165: } + -: 1166: + -: 1167: template + #####: 1168: static void replace_element_impl(iterator& it, Shield& names, int& index, const T& t, const TArgs&... args) { + #####: 1169: replace_element(it, names, index, t); + #####: 1170: replace_element_impl(++it, names, ++index, args...); + #####: 1171: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE20replace_element_implINS_6traits12named_objectIiEEJNS5_INS0_ILi16ES1_EEEEEEEvRNS_8internal14Proxy_IteratorINS9_13generic_proxyILi19ES1_EEEERNS_6ShieldIP7SEXPRECEERiRKT_DpRKT0_: + #####: 1168: static void replace_element_impl(iterator& it, Shield& names, int& index, const T& t, const TArgs&... args) { + #####: 1169: replace_element(it, names, index, t); + #####: 1170: replace_element_impl(++it, names, ++index, args...); + #####: 1171: } +------------------ +_ZN4Rcpp6VectorILi19ENS_15PreserveStorageEE20replace_element_implINS_6traits12named_objectIA1_cEEJNS5_IiEENS5_INS0_ILi16ES1_EEEEEEEvRNS_8internal14Proxy_IteratorINSB_13generic_proxyILi19ES1_EEEERNS_6ShieldIP7SEXPRECEERiRKT_DpRKT0_: + #####: 1168: static void replace_element_impl(iterator& it, Shield& names, int& index, const T& t, const TArgs&... args) { + #####: 1169: replace_element(it, names, index, t); + #####: 1170: replace_element_impl(++it, names, ++index, args...); + #####: 1171: } +------------------ + -: 1172: + -: 1173:public: + -: 1174: + -: 1175: inline SEXP eval() const { + -: 1176: return Rcpp_eval( Storage::get__(), R_GlobalEnv ) ; + -: 1177: } + -: 1178: + -: 1179: inline SEXP eval(SEXP env) const { + -: 1180: return Rcpp_eval( Storage::get__(), env ); + -: 1181: } + -: 1182: + -: 1183: + -: 1184:} ; /* Vector */ + -: 1185: + -: 1186:template class StoragePolicy > + -: 1187:inline std::ostream &operator<<(std::ostream & s, const Vector & rhs) { + -: 1188: typedef Vector VECTOR; + -: 1189: + -: 1190: typename VECTOR::iterator i = const_cast(rhs).begin(); + -: 1191: typename VECTOR::iterator iend = const_cast(rhs).end(); + -: 1192: + -: 1193: if (i != iend) { + -: 1194: s << (*i); + -: 1195: ++i; + -: 1196: + -: 1197: for ( ; i != iend; ++i) { + -: 1198: s << " " << (*i); + -: 1199: } + -: 1200: } + -: 1201: + -: 1202: return s; + -: 1203:} + -: 1204: + -: 1205:template