| 38 | Formula_Impl(){} ; |
| 39 | |
| 40 | Formula_Impl(SEXP x){ |
| 41 | switch( TYPEOF( x ) ){ |
| 42 | case LANGSXP: |
| 43 | if( ::Rf_inherits( x, "formula") ){ |
| 44 | Storage::set__( x ); |
| 45 | } else{ |
| 46 | Storage::set__( internal::convert_using_rfunction( x, "as.formula") ) ; |
| 47 | } |
| 48 | break; |
| 49 | case EXPRSXP: |
| 50 | case VECSXP: |
| 51 | /* lists or expression, try the first one */ |
| 52 | if( ::Rf_length(x) > 0 ){ |
| 53 | SEXP y = VECTOR_ELT( x, 0 ) ; |
| 54 | if( ::Rf_inherits( y, "formula" ) ){ |
| 55 | Storage::set__( y ) ; |
| 56 | } else{ |
| 57 | SEXP z = internal::convert_using_rfunction( y, "as.formula") ; |
| 58 | Storage::set__( z ) ; |
| 59 | } |
| 60 | } else{ |
| 61 | throw not_compatible( "cannot create formula from empty list or expression" ) ; |
| 62 | } |
| 63 | break; |
| 64 | default: |
| 65 | Storage::set__( internal::convert_using_rfunction( x, "as.formula") ) ; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | explicit Formula_Impl( const std::string& code ) { |
| 70 | Storage::set__( internal::convert_using_rfunction( ::Rf_mkString(code.c_str()), "as.formula") ) ; |
no test coverage detected