From 1e047be829947fa48ffa8a2fd21b6cb882ee1dde Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 28 Jan 2022 14:43:37 +0100 Subject: [PATCH] implement [ so that it can keep "file" attribute --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/boundary.R | 8 ++++++++ man/cli.Rd | 3 +++ src/RcppExports.cpp | 5 +++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 36f80ad..72acb18 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,7 +44,7 @@ Suggests: tidyverse, testthat (>= 3.0.0), covr -RoxygenNote: 7.1.1 +RoxygenNote: 7.1.2 VignetteBuilder: knitr LinkingTo: Rcpp, RcppArmadillo diff --git a/NAMESPACE b/NAMESPACE index afca02b..183bd55 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +S3method("[",t2d_cli) S3method(c,t2d_opt_LINES) S3method(cas,default) S3method(cas,list) diff --git a/R/boundary.R b/R/boundary.R index 5c7862f..69bd21d 100644 --- a/R/boundary.R +++ b/R/boundary.R @@ -146,6 +146,14 @@ print.t2d_cli <- function(x, ..., n = 10) { invisible(x) } +#' @name cli +#' @export +`[.t2d_cli` <- function(x, ...) { + out <- NextMethod() + attr(out, "file") <- attr(x, "file") + class(out) <- class(x) + out +} #' Read boundary (*.cli) file #' diff --git a/man/cli.Rd b/man/cli.Rd index fe3d498..757cdfe 100644 --- a/man/cli.Rd +++ b/man/cli.Rd @@ -8,6 +8,7 @@ \alias{cli.data.frame} \alias{cli.t2d_cli} \alias{print.t2d_cli} +\alias{[.t2d_cli} \title{Boundary (*.cli) object} \usage{ cli(x, fname, ...) @@ -23,6 +24,8 @@ cli(x, fname, ...) \method{cli}{t2d_cli}(x, fname = NULL, df = NULL, ...) \method{print}{t2d_cli}(x, ..., n = 10) + +\method{[}{t2d_cli}(x, ...) } \arguments{ \item{x}{Either: A \code{character} string providing the name of an existing boundary file; diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index d8f98c9..19e8243 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -6,6 +6,11 @@ using namespace Rcpp; +#ifdef RCPP_USE_GLOBAL_ROSTREAM +Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); +Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); +#endif + // cas_lineadapt DataFrame cas_lineadapt(DataFrame df, int sep_len); RcppExport SEXP _telemac_cas_lineadapt(SEXP dfSEXP, SEXP sep_lenSEXP) {