[Rprotobuf-commits] r621 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Dec 28 00:48:20 CET 2013


Author: murray
Date: 2013-12-28 00:48:19 +0100 (Sat, 28 Dec 2013)
New Revision: 621

Modified:
   pkg/src/RSourceTree.cpp
   pkg/src/RWarningErrorCollector.cpp
   pkg/src/RconnectionCopyingInputStream.cpp
Log:
whitespace change only: clang-format



Modified: pkg/src/RSourceTree.cpp
===================================================================
--- pkg/src/RSourceTree.cpp	2013-12-27 23:46:01 UTC (rev 620)
+++ pkg/src/RSourceTree.cpp	2013-12-27 23:48:19 UTC (rev 621)
@@ -3,57 +3,54 @@
 
 namespace rprotobuf {
 
-	RSourceTree::RSourceTree() : directories() {}
-	
-	GPB::io::ZeroCopyInputStream * RSourceTree::Open(const std::string & filename){
-		/* first, try to open the file as it is */
-		int file_descriptor = open(filename.c_str(), O_RDONLY);
-	  	if (file_descriptor < 0) {
-	  		/* then try the directories */
-	  		std::set<std::string>::iterator it ; 
-	  		it = directories.begin() ;
-	  		std::string file ;
-	  		while( it != directories.end() ){
-	  			file = *it ;
-	  			file += "/" ; 
-	  			file += filename ;
-	  			file_descriptor = open( file.c_str() , O_RDONLY) ;
-	  			if( file_descriptor > 0 ) break ;
-	  			it++; 
-	  		}
-	  	}
-	  	
-	  	if( file_descriptor < 0 ){
-	  		return NULL ;
-	  	}
-	  	
-	  	GPB::io::FileInputStream* result = new GPB::io::FileInputStream(file_descriptor);
-		result->SetCloseOnDelete(true);
-		return result;
-	}
-	
-	void RSourceTree::addDirectory( const std::string& directory){
-		directories.insert( directory ) ;
-	}
-	void RSourceTree::addDirectories( SEXP dirs ){
-		int n = LENGTH(dirs);
-		for( int i=0; i<n; i++){
-			directories.insert( std::string(CHAR(STRING_ELT(dirs, i))) ) ;
-		}
-	}
-	
-	void RSourceTree::removeDirectory( const std::string& directory){
-		directories.erase( directory ) ;
-	}
-	void RSourceTree::removeDirectories( SEXP dirs){
-		int n = LENGTH(dirs);
-		for( int i=0; i<n; i++){
-			directories.erase( std::string(CHAR(STRING_ELT(dirs, i))) ) ;
-		}
-	}
-	
-	
-	
-} // namespace rprotobuf
+RSourceTree::RSourceTree() : directories() {}
 
+GPB::io::ZeroCopyInputStream* RSourceTree::Open(const std::string& filename) {
+    /* first, try to open the file as it is */
+    int file_descriptor = open(filename.c_str(), O_RDONLY);
+    if (file_descriptor < 0) {
+        /* then try the directories */
+        std::set<std::string>::iterator it;
+        it = directories.begin();
+        std::string file;
+        while (it != directories.end()) {
+            file = *it;
+            file += "/";
+            file += filename;
+            file_descriptor = open(file.c_str(), O_RDONLY);
+            if (file_descriptor > 0) break;
+            it++;
+        }
+    }
 
+    if (file_descriptor < 0) {
+        return NULL;
+    }
+
+    GPB::io::FileInputStream* result =
+        new GPB::io::FileInputStream(file_descriptor);
+    result->SetCloseOnDelete(true);
+    return result;
+}
+
+void RSourceTree::addDirectory(const std::string& directory) {
+    directories.insert(directory);
+}
+void RSourceTree::addDirectories(SEXP dirs) {
+    int n = LENGTH(dirs);
+    for (int i = 0; i < n; i++) {
+        directories.insert(std::string(CHAR(STRING_ELT(dirs, i))));
+    }
+}
+
+void RSourceTree::removeDirectory(const std::string& directory) {
+    directories.erase(directory);
+}
+void RSourceTree::removeDirectories(SEXP dirs) {
+    int n = LENGTH(dirs);
+    for (int i = 0; i < n; i++) {
+        directories.erase(std::string(CHAR(STRING_ELT(dirs, i))));
+    }
+}
+
+}  // namespace rprotobuf

Modified: pkg/src/RWarningErrorCollector.cpp
===================================================================
--- pkg/src/RWarningErrorCollector.cpp	2013-12-27 23:46:01 UTC (rev 620)
+++ pkg/src/RWarningErrorCollector.cpp	2013-12-27 23:48:19 UTC (rev 621)
@@ -1,13 +1,13 @@
 #include "rprotobuf.h"
-#include "RWarningErrorCollector.h" 
+#include "RWarningErrorCollector.h"
 
 namespace rprotobuf {
 
-	void RWarningErrorCollector::AddError(const std::string& filename, int line, int column,
-		const std::string& message) {
-		
-    	Rprintf( "%s:%d:%d:%s\n", filename.c_str(), line+1, column+1, message.c_str() ) ;
-	}
+void RWarningErrorCollector::AddError(const std::string& filename, int line,
+                                      int column, const std::string& message) {
 
-} // namespace rprotobuf
+    Rprintf("%s:%d:%d:%s\n", filename.c_str(), line + 1, column + 1,
+            message.c_str());
+}
 
+}  // namespace rprotobuf

Modified: pkg/src/RconnectionCopyingInputStream.cpp
===================================================================
--- pkg/src/RconnectionCopyingInputStream.cpp	2013-12-27 23:46:01 UTC (rev 620)
+++ pkg/src/RconnectionCopyingInputStream.cpp	2013-12-27 23:48:19 UTC (rev 621)
@@ -1,35 +1,35 @@
 #include "rprotobuf.h"
 #include "RconnectionCopyingInputStream.h"
 
-namespace rprotobuf{
-	/* N.B. connection must be opened in binary mode due to call
-	 * to readBin below. */
-	RconnectionCopyingInputStream::RconnectionCopyingInputStream(int id) : 
-                connection_id(id),
-                failure(false) {}
-	
-	/** 
-	 * call readBin to read size bytes from R
-	 * 
-	 * @param buffer buffer to fill with at most size bytes
-	 * @param size maximum number of bytes
-	 *
-	 * @return the number of bytes actually read
-	 */
-	int	RconnectionCopyingInputStream::Read(void * buffer, int size){
-		Rcpp::Language call( "readBin", connection_id, Rcpp::RawVector(0), size ) ;
-		Rcpp::RawVector res ;
-		try{
-			res = call.eval();
-		}  catch( ... ){
-			/* Failed to read anything from the connection,
-			 * could have been permissions, or connection opened
-			 * in the wrong type, etc. */
-                        failure = true;
-			return -1 ;
-		}
-		int len = res.size() ;
-		memcpy( buffer, reinterpret_cast<const void*>(res.begin()), len) ;
-		return len ;
-	}
+namespace rprotobuf {
+/* N.B. connection must be opened in binary mode due to call
+ * to readBin below. */
+RconnectionCopyingInputStream::RconnectionCopyingInputStream(int id)
+    : connection_id(id), failure(false) {}
+
+/**
+ * call readBin to read size bytes from R
+ *
+ * @param buffer buffer to fill with at most size bytes
+ * @param size maximum number of bytes
+ *
+ * @return the number of bytes actually read
+ */
+int RconnectionCopyingInputStream::Read(void* buffer, int size) {
+    Rcpp::Language call("readBin", connection_id, Rcpp::RawVector(0), size);
+    Rcpp::RawVector res;
+    try {
+        res = call.eval();
+    }
+    catch (...) {
+        /* Failed to read anything from the connection,
+         * could have been permissions, or connection opened
+         * in the wrong type, etc. */
+        failure = true;
+        return -1;
+    }
+    int len = res.size();
+    memcpy(buffer, reinterpret_cast<const void*>(res.begin()), len);
+    return len;
 }
+}



More information about the Rprotobuf-commits mailing list