|
| 1 | +// Copyright (C) 2013 Romain Francois |
| 2 | +// |
| 3 | +// This file is part of Rcpp. |
| 4 | +// |
| 5 | +// Rcppis 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 <http://www.gnu.org/licenses/>. |
| 17 | + |
| 18 | +#ifndef Rcpp_Na_Proxy_h |
| 19 | +#define Rcpp_Na_Proxy_h |
| 20 | + |
| 21 | +namespace Rcpp{ |
| 22 | + class Na_Proxy{} ; |
| 23 | + static Na_Proxy NA ; |
| 24 | +} |
| 25 | + |
| 26 | +inline bool operator==(double x , Rcpp::Na_Proxy){ return Rcpp::traits::is_na<REALSXP>(x) ; } |
| 27 | +inline bool operator==(int x , Rcpp::Na_Proxy){ return Rcpp::traits::is_na<INTSXP>(x) ; } |
| 28 | +inline bool operator==(Rcpp::String x, Rcpp::Na_Proxy){ return Rcpp::traits::is_na<STRSXP>(x.get_sexp()) ; } |
| 29 | +inline bool operator==(Rcomplex x , Rcpp::Na_Proxy){ return Rcpp::traits::is_na<CPLXSXP>(x) ; } |
| 30 | +inline bool operator==(SEXP x , Rcpp::Na_Proxy){ return TYPEOF(x)==CHARSXP && Rcpp::traits::is_na<STRSXP>(x) ; } |
| 31 | +inline bool operator==(std::string , Rcpp::Na_Proxy){ return false ; } |
| 32 | +inline bool operator==(const char* , Rcpp::Na_Proxy){ return false ; } |
| 33 | +inline bool operator==(Rcpp::internal::string_proxy<STRSXP> x, Rcpp::Na_Proxy){ |
| 34 | + return Rcpp::traits::is_na<STRSXP>(x.get()) ; |
| 35 | +} |
| 36 | +inline bool operator==(Rcpp::internal::const_string_proxy<STRSXP> x, Rcpp::Na_Proxy){ |
| 37 | + return Rcpp::traits::is_na<STRSXP>(x.get()) ; |
| 38 | +} |
| 39 | + |
| 40 | +inline bool operator==(Rcpp::Na_Proxy, double x ){ return Rcpp::traits::is_na<REALSXP>(x) ; } |
| 41 | +inline bool operator==(Rcpp::Na_Proxy, int x ){ return Rcpp::traits::is_na<INTSXP>(x) ; } |
| 42 | +inline bool operator==(Rcpp::Na_Proxy, Rcpp::String x ){ return Rcpp::traits::is_na<STRSXP>(x.get_sexp()) ; } |
| 43 | +inline bool operator==(Rcpp::Na_Proxy, SEXP x ){ return TYPEOF(x)==CHARSXP && Rcpp::traits::is_na<STRSXP>(x) ; } |
| 44 | +inline bool operator==(Rcpp::Na_Proxy, Rcomplex x ){ return Rcpp::traits::is_na<CPLXSXP>(x) ; } |
| 45 | +inline bool operator==(Rcpp::Na_Proxy, std::string ){ return false ; } |
| 46 | +inline bool operator==(Rcpp::Na_Proxy, const char* ){ return false ; } |
| 47 | +inline bool operator==(Rcpp::Na_Proxy, Rcpp::internal::string_proxy<STRSXP> x){ |
| 48 | + return Rcpp::traits::is_na<STRSXP>(x.get()) ; |
| 49 | +} |
| 50 | +inline bool operator==(Rcpp::Na_Proxy, Rcpp::internal::const_string_proxy<STRSXP> x){ |
| 51 | + return Rcpp::traits::is_na<STRSXP>(x.get()) ; |
| 52 | +} |
| 53 | + |
| 54 | +#endif |
0 commit comments