[Phylobase-commits] r835 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Nov 19 15:46:09 CET 2012


Author: bbolker
Date: 2012-11-19 15:46:09 +0100 (Mon, 19 Nov 2012)
New Revision: 835

Modified:
   pkg/src/Makevars
   pkg/src/Makevars.win
   pkg/src/nxsblock.cpp
   pkg/src/nxscxxdiscretematrix.cpp
   pkg/src/nxspublicblocks.cpp
   pkg/src/nxsreader.cpp
   pkg/src/nxstreesblock.cpp
Log:

  replace cout/cerr with Rcpp::Rcout/Rcerr



Modified: pkg/src/Makevars
===================================================================
--- pkg/src/Makevars	2012-11-12 14:27:16 UTC (rev 834)
+++ pkg/src/Makevars	2012-11-19 14:46:09 UTC (rev 835)
@@ -1,2 +1,2 @@
-PKG_CPPFLAGS=-I. -DHAVE_INTTYPES_H
+PKG_CPPFLAGS=-I. -DHAVE_INTTYPES_H -DASSERTS_TO_EXCEPTIONS
 PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`

Modified: pkg/src/Makevars.win
===================================================================
--- pkg/src/Makevars.win	2012-11-12 14:27:16 UTC (rev 834)
+++ pkg/src/Makevars.win	2012-11-19 14:46:09 UTC (rev 835)
@@ -1,5 +1,5 @@
 ## PKG_LIBS = -s $(shell Rscript -e 'Rcpp:::LdFlags()') -L"$(RHOME)/bin" -lR --no-export-all-symbols --add-stdcall-alias
-PKG_CXXFLAGS =  -I. -DHAVE_INTTYPES_H
+PKG_CXXFLAGS =  -I. -DHAVE_INTTYPES_H -DASSERTS_TO_EXCEPTIONS
 PKG_LIBS = $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()")
 
 

Modified: pkg/src/nxsblock.cpp
===================================================================
--- pkg/src/nxsblock.cpp	2012-11-12 14:27:16 UTC (rev 834)
+++ pkg/src/nxsblock.cpp	2012-11-19 14:46:09 UTC (rev 835)
@@ -20,6 +20,9 @@
 #include "ncl/nxsdefs.h"
 #include "ncl/nxsblock.h"
 #include "ncl/nxsreader.h"
+
+#include <Rcpp.h>
+
 #include <cstdlib>
 using namespace std;
 
@@ -31,7 +34,7 @@
 #		if defined (ASSERTS_TO_EXCEPTIONS)
 			NxsString err;
 #		else
-			std::ostream & err(cerr);
+			std::ostream & err(Rcerr);
 #		endif
 			err << "\nNCL assertion failed:";
 			err << "\n  expr: " << expr;
@@ -41,7 +44,7 @@
 #		if defined (ASSERTS_TO_EXCEPTIONS)
 			throw NxsNCLAPIException(err);
 #		else
-			std::cerr << std::endl;
+			Rcpp::Rcerr << std::endl;
 			std::exit(1);
 #		endif
 		}

Modified: pkg/src/nxscxxdiscretematrix.cpp
===================================================================
--- pkg/src/nxscxxdiscretematrix.cpp	2012-11-12 14:27:16 UTC (rev 834)
+++ pkg/src/nxscxxdiscretematrix.cpp	2012-11-19 14:46:09 UTC (rev 835)
@@ -22,7 +22,7 @@
 #include <cassert>
 using std::string;
 using std::vector;
-using std::cout;
+//using std::cout;
 using std::endl;
 
 /**===========================================================================

Modified: pkg/src/nxspublicblocks.cpp
===================================================================
--- pkg/src/nxspublicblocks.cpp	2012-11-12 14:27:16 UTC (rev 834)
+++ pkg/src/nxspublicblocks.cpp	2012-11-19 14:46:09 UTC (rev 835)
@@ -23,6 +23,9 @@
 #include <fstream>
 #include "ncl/nxspublicblocks.h"
 #include "ncl/nxsreader.h"
+
+#include <Rcpp.h>
+
 using namespace std;
 
 
@@ -680,7 +683,7 @@
 		throw NxsException(msg);
 		}
 	if (verbose)
-		std::cerr << "Writing \"" << fn << "\" to store the translation of names\n";
+	    Rcpp::Rcerr << "Writing \"" << fn << "\" to store the translation of names\n";
 	writeTaxonNameTranslationStream(tnf, nameTrans, tb);
 	tnf.close();
 }

Modified: pkg/src/nxsreader.cpp
===================================================================
--- pkg/src/nxsreader.cpp	2012-11-12 14:27:16 UTC (rev 834)
+++ pkg/src/nxsreader.cpp	2012-11-19 14:46:09 UTC (rev 835)
@@ -23,6 +23,9 @@
 #include <climits>
 #include <sstream>
 #include <iterator>
+
+#include <Rcpp.h>
+
 #include "ncl/nxsreader.h"
 #include "ncl/nxsdefs.h"
 
@@ -1305,19 +1308,19 @@
 		return;
 	if (warnMode == NxsReader::WARNINGS_TO_STDERR)
 		{
-		std::cerr << "\nWarning:  ";
-		std::cerr << "\n " << msg << std::endl;
+		Rcpp::Rcerr << "\nWarning:  ";
+		Rcpp::Rcerr << "\n " << msg << std::endl;
 		if (line > 0 || pos > 0)
-			std::cerr << "at line " << line << ", column (approximately) " << col << " (file position " << pos << ")\n";
+			Rcpp::Rcerr << "at line " << line << ", column (approximately) " << col << " (file position " << pos << ")\n";
 		}
 	else if (warnMode != NxsReader::WARNINGS_TO_STDOUT)
 		{
-		std::cout << "\nWarning:  ";
+		Rcpp::Rcout << "\nWarning:  ";
 		if (line > 0 || pos > 0)
-			std::cout << "at line " << line << ", column " << col << " (file position " << pos << "):\n";
-		std::cout << "\n " << msg << '\n';
+			Rcpp::Rcout << "at line " << line << ", column " << col << " (file position " << pos << "):\n";
+		Rcpp::Rcout << "\n " << msg << '\n';
 		if (line > 0 || pos > 0)
-			std::cout << "at line " << line << ", column (approximately) " << col << " (file position " << pos << ')' << std::endl;
+			Rcpp::Rcout << "at line " << line << ", column (approximately) " << col << " (file position " << pos << ')' << std::endl;
 		}
 	else
 		{
@@ -1332,9 +1335,9 @@
 	if (warnMode == NxsReader::IGNORE_WARNINGS)
 		return;
 	if (warnMode == NxsReader::WARNINGS_TO_STDERR)
-		std::cerr << "[!Skipping unknown block (" << blockName << ")...]" << std::endl;
+		Rcpp::Rcerr << "[!Skipping unknown block (" << blockName << ")...]" << std::endl;
 	else if (warnMode != NxsReader::WARNINGS_TO_STDOUT)
-		std::cout << "[!Skipping unknown block (" << blockName << ")...]" << std::endl;
+		Rcpp::Rcout << "[!Skipping unknown block (" << blockName << ")...]" << std::endl;
 	}
 
 void ExceptionRaisingNxsReader::SkippingDisabledBlock(NxsString blockName)
@@ -1342,15 +1345,15 @@
 	if (warnMode == NxsReader::IGNORE_WARNINGS)
 		return;
 	if (warnMode == NxsReader::WARNINGS_TO_STDERR)
-		std::cerr << "[!Skipping disabled block (" << blockName << ")...]" << std::endl;
+		Rcpp::Rcerr << "[!Skipping disabled block (" << blockName << ")...]" << std::endl;
 	else if (warnMode != NxsReader::WARNINGS_TO_STDOUT)
-		std::cout << "[!Skipping disabled block (" << blockName << ")...]" << std::endl;
+		Rcpp::Rcout << "[!Skipping disabled block (" << blockName << ")...]" << std::endl;
 	}
 
 void NxsReader::statusMessage(const std::string & m) const
 {
 	if (alwaysReportStatusMessages || currentWarningLevel == UNCOMMON_SYNTAX_WARNING) {
-		std::cerr << m << std::endl;
+		Rcpp::Rcerr << m << std::endl;
 	}
 }
 

Modified: pkg/src/nxstreesblock.cpp
===================================================================
--- pkg/src/nxstreesblock.cpp	2012-11-12 14:27:16 UTC (rev 834)
+++ pkg/src/nxstreesblock.cpp	2012-11-19 14:46:09 UTC (rev 835)
@@ -19,6 +19,8 @@
 #include <climits>
 #include "ncl/nxstreesblock.h"
 
+#include <Rcpp.h>
+
 #include <sstream>
 #include <stack>
 
@@ -1003,13 +1005,13 @@
 				if (nd->IsTip())
 					{
 					nodeIndex = nd->GetTaxonIndex();
-					std::cout << " leaf node # = " <<  nodeIndex << '\n';
+					Rcpp::Rcout << " leaf node # = " <<  nodeIndex << '\n';
 					}
 				else
 					{
 					nodeIndex = internalNdIndex++;
 					nd->SetTaxonIndex(nodeIndex);
-					std::cout << " internal node # = " << nd->GetTaxonIndex()  << '\n';
+					Rcpp::Rcout << " internal node # = " << nd->GetTaxonIndex()  << '\n';
 					}
 				if (parentVector.size() < nodeIndex + 1)
 					{
@@ -1034,17 +1036,17 @@
 					branchLengthVector[nodeIndex] = -1.0;
 					}
 				}
-			std::cout << "Parents = [";
+			Rcpp::Rcout << "Parents = [";
 			for (std::vector<unsigned>::const_iterator nIt = parentVector.begin(); nIt != parentVector.end(); ++nIt)
-				{
-				std::cout << *nIt << ", ";				
-				}
-			std::cout << "]\nbranch lengths = [";
-			for (std::vector<double>::const_iterator nIt = branchLengthVector.begin(); nIt != branchLengthVector.end(); ++nIt)
-				{
-				std::cout << *nIt << ", ";				
-				}
-			std::cout << "]\n";
+			    {
+				Rcpp::Rcout << *nIt << ", ";				
+			    }
+			Rcpp::Rcout << "]\nbranch lengths = [";
+			for (std::vector<double>::const_iterator nIt = branchLengthVector.begin(); nIt != branchLengthVector.end();  ++nIt)
+			    {
+			 	Rcpp::Rcout << *nIt << ", ";				
+			    }
+			Rcpp::Rcout << "]\n";
 #endif
 		}
 	}
@@ -1328,9 +1330,9 @@
 				else if (prevToken == NXS_TREE_COLON_TOKEN)
 					throw NxsException("Expecting a branch length after a : but found (", token);
 				nchildren.top() += 1;
-				//std::cerr << "Open Parens nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
+				Rcpp::Rcerr << "Open Parens nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
 				nchildren.push(0);
-				//std::cerr << "Open Parens after push nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
+				Rcpp::Rcerr << "Open Parens after push nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
 				newickStream << '(';
 				prevToken = NXS_TREE_OPEN_PARENS_TOKEN;
 				handled = true;
@@ -1354,10 +1356,10 @@
 					else if (nchildren.top() > 3 || nchildren.size() > 1) /* three children are allowed not considered a polytomy */
 						hasPolytomies = true;
 					}
-				//std::cerr << "close parens nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
+				Rcpp::Rcerr << "close parens nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
 				nchildren.pop();
-				//if (!nchildren.empty())
-					//std::cerr << "close parens post-pop nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
+				if (!nchildren.empty())
+					Rcpp::Rcerr << "close parens post-pop nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
 				newickStream << ')';
 				prevToken = NXS_TREE_CLOSE_PARENS_TOKEN;
 				handled = true;
@@ -1431,7 +1433,7 @@
 				NxsString toAppend;
 				if (prevToken == NXS_TREE_CLOSE_PARENS_TOKEN)
 					{
-					//std::cerr << "validateInternalNodeLabels = " << validateInternalNodeLabels << '\n';
+					Rcpp::Rcerr << "validateInternalNodeLabels = " << validateInternalNodeLabels << '\n';
 					if (validateInternalNodeLabels)
 						{
 						std::map<std::string, unsigned>::const_iterator tt = capNameToInd.find(ucl);
@@ -1515,7 +1517,7 @@
 									}
 								taxaEncountered.insert(indWithAdditions);
 								nchildren.top() += 1;
-								//std::cerr << "treating as number " << ucl << " nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
+								Rcpp::Rcerr << "treating as number " << ucl << " nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
 
 								toAppend += (1 + indWithAdditions);
 								}
@@ -1541,7 +1543,7 @@
 								capNameToInd[tasstring] = valueInd;
 								taxaEncountered.insert(valueInd);
 								nchildren.top() += 1;
-								//std::cerr << "nonnumeric newtaxon " << ucl << " nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
+								Rcpp::Rcerr << "nonnumeric newtaxon " << ucl << " nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
 								toAppend += (1 + valueInd);
 								}
 							}
@@ -1557,7 +1559,7 @@
 									}
 								taxaEncountered.insert(*cit);
 								nchildren.top() += 1;
-								//std::cerr << "taxon set " << ucl << " nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
+								Rcpp::Rcerr << "taxon set " << ucl << " nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
 								if (!firstTaxonAdded)
 									toAppend.append(1, ',');
 								toAppend += (1 + *cit);
@@ -1574,7 +1576,7 @@
 						{
 						taxaEncountered.insert(ind);
 						nchildren.top() += 1;
-						//std::cerr << "taxon label " << ucl << " nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
+						Rcpp::Rcerr << "taxon label " << ucl << " nchildren.top = " << nchildren.top() << " nchildren.size() = " << nchildren.size() << " rooted = " << rooted << " hasPolytomies = " << hasPolytomies << std::endl;
 						toAppend += (1 + ind);
 						}
 					}



More information about the Phylobase-commits mailing list