[Rcpp-commits] r1151 - pkg/Rcpp/inst/include/Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 4 04:31:59 CEST 2010


Author: edd
Date: 2010-05-04 04:31:58 +0200 (Tue, 04 May 2010)
New Revision: 1151

Modified:
   pkg/Rcpp/inst/include/Rcpp/exceptions.h
Log:
also use 'int pos' in exception; suppresses a warning triggered from RcppGSL


Modified: pkg/Rcpp/inst/include/Rcpp/exceptions.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/exceptions.h	2010-05-04 02:04:22 UTC (rev 1150)
+++ pkg/Rcpp/inst/include/Rcpp/exceptions.h	2010-05-04 02:31:58 UTC (rev 1151)
@@ -25,22 +25,29 @@
 namespace Rcpp{
 
 class exception : public std::exception {
-	public:
-		exception(const char* message_, const char* file, int line ) ;
-		virtual ~exception() throw() ;
-		virtual const char* what() const throw() ;
-	private:
-		std::string message ;
+public:
+    exception(const char* message_, const char* file, int line ) ;
+    virtual ~exception() throw() ;
+    virtual const char* what() const throw() ;
+private:
+    std::string message ;
 } ;
 
+// simple helper
+static std::string toString(const int i) { 
+    std::ostringstream ostr;
+    ostr << i;
+    return ostr.str();
+}
+
 class no_such_env : public std::exception{                                     
 public:                                                                        
-	no_such_env( const std::string& name ) throw() : message( std::string("no such environment: '") + name + "'" ){} ;
-	no_such_env( int pos ) throw() : message( "no environment in given position ") {} ;
-	virtual ~no_such_env() throw(){} ;                                         
-	virtual const char* what() const throw(){ return message.c_str() ; } ;     
+    no_such_env( const std::string& name ) throw() : message( std::string("no such environment: '") + name + "'" ){} ;
+    no_such_env( int pos ) throw() : message( "no environment in given position '" + toString(pos) + "'") {} ;
+    virtual ~no_such_env() throw(){} ;                                         
+    virtual const char* what() const throw(){ return message.c_str() ; } ;     
 private:                                                                       
-	std::string message ;                                                      
+    std::string message ;                                                      
 } ;
 
 



More information about the Rcpp-commits mailing list