22 #ifndef Rcpp_vector_DimNameProxy_h
23 #define Rcpp_vector_DimNameProxy_h
37 if (Rf_length(other) == 0)
39 Rf_setAttrib(
data_, R_DimNamesSymbol, R_NilValue);
41 SEXP dims = Rf_getAttrib(
data_, R_DimSymbol);
42 if (INTEGER(dims)[
dim_] != Rf_length(other)) {
43 stop(
"dimension extent is '%d' while length of names is '%d'", INTEGER(dims)[
dim_], Rf_length(other));
46 SEXP dimnames = Rf_getAttrib(
data_, R_DimNamesSymbol);
47 if (Rf_isNull(dimnames)) {
48 Shield<SEXP> new_dimnames(Rf_allocVector(VECSXP, Rf_length(dims)));
49 SET_VECTOR_ELT(new_dimnames,
dim_, other);
50 Rf_setAttrib(
data_, R_DimNamesSymbol, new_dimnames);
52 SET_VECTOR_ELT(dimnames,
dim_, other);
63 return assign(SEXP(other));
66 inline operator SEXP()
const {
67 SEXP dimnames = Rf_getAttrib(
data_, R_DimNamesSymbol);
68 return Rf_isNull(dimnames) ? (R_NilValue) : (VECTOR_ELT(dimnames,
dim_));
72 inline operator T()
const {
73 SEXP dimnames = Rf_getAttrib(
data_, R_DimNamesSymbol);
74 if (Rf_isNull(dimnames)) {
77 return T(VECTOR_ELT(dimnames,
dim_));
DimNameProxy(SEXP data, int dim)
DimNameProxy & operator=(SEXP other)
DimNameProxy(DimNameProxy const &other)
DimNameProxy & assign(SEXP other)
DimNameProxy & operator=(const DimNameProxy &other)
void NORET stop(const char *fmt, Args &&... args)