| 25 | public: |
| 26 | |
| 27 | class NamesProxy : public GenericProxy<NamesProxy> { |
| 28 | public: |
| 29 | NamesProxy( CLASS& v) : parent(v){} ; |
| 30 | |
| 31 | /* lvalue uses */ |
| 32 | NamesProxy& operator=(const NamesProxy& rhs) { |
| 33 | if( this != &rhs) set( rhs.get() ) ; |
| 34 | return *this ; |
| 35 | } |
| 36 | |
| 37 | template <typename T> |
| 38 | NamesProxy& operator=(const T& rhs); |
| 39 | |
| 40 | template <typename T> operator T() const; |
| 41 | |
| 42 | private: |
| 43 | CLASS& parent; |
| 44 | |
| 45 | SEXP get() const { |
| 46 | return RCPP_GET_NAMES(parent.get__()) ; |
| 47 | } |
| 48 | |
| 49 | void set(SEXP x) { |
| 50 | Shield<SEXP> safe_x(x); |
| 51 | |
| 52 | /* check if we can use a fast version */ |
| 53 | if( TYPEOF(x) == STRSXP && parent.size() == Rf_length(x) ){ // #nocov start |
| 54 | Rf_namesgets(parent, x); |
| 55 | } else { |
| 56 | /* use the slower and more flexible version (callback to R) */ |
| 57 | SEXP namesSym = Rf_install( "names<-" ); |
| 58 | Shield<SEXP> call(Rf_lang3(namesSym, parent, x)); |
| 59 | Shield<SEXP> new_vec(Rcpp_fast_eval(call, R_GlobalEnv)); |
| 60 | parent.set__(new_vec); // #nocov end |
| 61 | } |
| 62 | |
| 63 | } |
| 64 | |
| 65 | } ; |
| 66 | |
| 67 | class const_NamesProxy : public GenericProxy<const_NamesProxy>{ |
| 68 | public: |