[Rcpp-commits] r3218 - in pkg/Rcpp: . inst inst/include inst/include/Rcpp inst/include/Rcpp/iostream src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Oct 26 03:34:01 CEST 2011
Author: edd
Date: 2011-10-26 03:34:00 +0200 (Wed, 26 Oct 2011)
New Revision: 3218
Added:
pkg/Rcpp/inst/include/Rcpp/iostream/
pkg/Rcpp/inst/include/Rcpp/iostream/Rostream.h
pkg/Rcpp/inst/include/Rcpp/iostream/Rstreambuf.h
pkg/Rcpp/src/Rostream.cpp
pkg/Rcpp/src/Rstreambuf.cpp
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/DESCRIPTION
pkg/Rcpp/inst/NEWS
pkg/Rcpp/inst/THANKS
pkg/Rcpp/inst/include/Rcpp.h
Log:
Adds patch by Jelmer Ypma which implements a new device Rcout which acts like
std::cout but is implemented using Rprintf to cooperate more cleanly with the
output buffering by R
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2011-10-21 22:49:03 UTC (rev 3217)
+++ pkg/Rcpp/ChangeLog 2011-10-26 01:34:00 UTC (rev 3218)
@@ -1,3 +1,12 @@
+2011-10-25 Dirk Eddelbuettel <edd at debian.org>
+
+ * src/Rostream.cpp: Patch by Jelmer Ypma which adds a new device
+ 'Rcout' not unlike std::cout but uses Rprintf internally
+ * src/Rstreambuf.cpp: Idem
+ * include/include/Rcpp/iostream/Rostream.h: Idem
+ * include/include/Rcpp/iostream/Rstreambuf.h: Idem
+ * include/include/Rcpp.h: Include new headers
+
2011-09-29 Dirk Eddelbuettel <edd at debian.org>
* DESCRIPTION: Release 0.9.7
Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION 2011-10-21 22:49:03 UTC (rev 3217)
+++ pkg/Rcpp/DESCRIPTION 2011-10-26 01:34:00 UTC (rev 3218)
@@ -1,6 +1,6 @@
Package: Rcpp
Title: Seamless R and C++ Integration
-Version: 0.9.7
+Version: 0.9.7.1
Date: $Date$
Author: Dirk Eddelbuettel and Romain Francois,
with contributions by Douglas Bates and John Chambers
Modified: pkg/Rcpp/inst/NEWS
===================================================================
--- pkg/Rcpp/inst/NEWS 2011-10-21 22:49:03 UTC (rev 3217)
+++ pkg/Rcpp/inst/NEWS 2011-10-26 01:34:00 UTC (rev 3218)
@@ -1,3 +1,9 @@
+0.9.8 201x-yy-zz
+
+ o Applied patch by Jelmer Ypma which adds an output stream class
+ 'Rcout' not unlike std::cout, but implemented via Rprintf to
+ cooperate with R and its output buffering.
+
0.9.7 2011-09-29
o Applied two patches kindly provided by Martyn Plummer which provide
Modified: pkg/Rcpp/inst/THANKS
===================================================================
--- pkg/Rcpp/inst/THANKS 2011-10-21 22:49:03 UTC (rev 3217)
+++ pkg/Rcpp/inst/THANKS 2011-10-26 01:34:00 UTC (rev 3218)
@@ -10,7 +10,7 @@
Uwe Ligges for help with Windows (32 and 64 bit) build issues
Tama Ma for a patch that extends Module constructors
Karl Millar for a patch helping with a non-g++ compiler
-Martyn Plummer for help with Solaris build issues
+Martyn Plummer for help and patches regarding Solaris build issues
David Reiss for the first-ever contributed patch (Rcpp*View)
Brian Ripley for help with Win64 + Solaris build issues
Dominick Samperi for starting what is now in the RcppClassic package
@@ -19,3 +19,4 @@
Luke Tierney for helpful discussions on R internals
Simon Urbanek for help on OS X build issues and with R internals
Ken Williams for additional OS X testing
+Jelmer Ypma for contributing the Rcout iostreams class patch
Added: pkg/Rcpp/inst/include/Rcpp/iostream/Rostream.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/iostream/Rostream.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/iostream/Rostream.h 2011-10-26 01:34:00 UTC (rev 3218)
@@ -0,0 +1,47 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+//
+// Rostream.h: Rcpp R/C++ interface class library -- output stream
+//
+// Copyright (C) 2011 Dirk Eddelbuettel, Romain Francois and Jelmer Ypma
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __ROSTREAM_H__
+#define __ROSTREAM_H__
+
+#include <RcppCommon.h>
+#include <Rcpp/iostream/Rstreambuf.h>
+
+// modified from
+// http://stackoverflow.com/questions/243696/correctly-over-loading-a-stringbuf-to-replace-cout-in-a-matlab-mex-file
+
+namespace Rcpp {
+
+ class Rostream : public std::ostream {
+
+ protected:
+ Rstreambuf buf;
+
+ public:
+ Rostream();
+ };
+
+ // declare global variable
+ extern Rostream Rcout;
+
+}
+
+#endif
Added: pkg/Rcpp/inst/include/Rcpp/iostream/Rstreambuf.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/iostream/Rstreambuf.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/iostream/Rstreambuf.h 2011-10-26 01:34:00 UTC (rev 3218)
@@ -0,0 +1,44 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+//
+// Rostream.h: Rcpp R/C++ interface class library -- stream buffer
+//
+// Copyright (C) 2011 Dirk Eddelbuettel, Romain Francois and Jelmer Ypma
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef __RSTREAMBUF_H__
+#define __RSTREAMBUF_H__
+
+#include <streambuf>
+#include <RcppCommon.h>
+
+// modified from
+// http://stackoverflow.com/questions/243696/correctly-over-loading-a-stringbuf-to-replace-cout-in-a-matlab-mex-file
+
+namespace Rcpp {
+
+ class Rstreambuf : public std::streambuf {
+ public:
+
+ protected:
+ virtual std::streamsize xsputn(const char *s, std::streamsize n );
+
+ virtual int overflow(int c = EOF );
+ };
+
+}
+
+#endif
Modified: pkg/Rcpp/inst/include/Rcpp.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp.h 2011-10-21 22:49:03 UTC (rev 3217)
+++ pkg/Rcpp/inst/include/Rcpp.h 2011-10-26 01:34:00 UTC (rev 3218)
@@ -68,4 +68,8 @@
#include <Rcpp/sugar/sugar.h>
#include <Rcpp/stats/stats.h>
+// "Rcout" iostream class contributed by Jelmer Ypma
+#include <Rcpp/iostream/Rstreambuf.h>
+#include <Rcpp/iostream/Rostream.h>
+
#endif
Added: pkg/Rcpp/src/Rostream.cpp
===================================================================
--- pkg/Rcpp/src/Rostream.cpp (rev 0)
+++ pkg/Rcpp/src/Rostream.cpp 2011-10-26 01:34:00 UTC (rev 3218)
@@ -0,0 +1,28 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+//
+// Rostream.cpp: Rcpp R/C++ interface class library -- output stream
+//
+// Copyright (C) 2011 Dirk Eddelbuettel, Romain Francois and Jelmer Ypma
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+#include <RcppCommon.h>
+#include <Rcpp/iostream/Rostream.h>
+
+Rcpp::Rostream::Rostream() : std::ostream( &buf ) {}
+
+// define global variable Rcout
+Rcpp::Rostream Rcpp::Rcout;
Added: pkg/Rcpp/src/Rstreambuf.cpp
===================================================================
--- pkg/Rcpp/src/Rstreambuf.cpp (rev 0)
+++ pkg/Rcpp/src/Rstreambuf.cpp 2011-10-26 01:34:00 UTC (rev 3218)
@@ -0,0 +1,35 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+//
+// Rostream.h: Rcpp R/C++ interface class library -- stream buffer
+//
+// Copyright (C) 2011 Dirk Eddelbuettel, Romain Francois and Jelmer Ypma
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+#include <RcppCommon.h>
+#include <Rcpp/iostream/Rstreambuf.h>
+
+std::streamsize Rcpp::Rstreambuf::xsputn(const char *s, std::streamsize num ) {
+ Rprintf( "%.*s", num, s );
+ return num;
+}
+
+int Rcpp::Rstreambuf::overflow(int c ) {
+ if (c != EOF) {
+ Rprintf( "%.1s", &c );
+ }
+ return c;
+}
More information about the Rcpp-commits
mailing list