]> git.lyx.org Git - features.git/commitdiff
Better support for various streams implementations
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 22 Oct 1999 09:45:25 +0000 (09:45 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 22 Oct 1999 09:45:25 +0000 (09:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@229 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
acinclude.m4
configure.in
src/support/DebugStream.C
src/support/DebugStream.h
src/support/LIstream.h [new file with mode: 0644]
src/support/LOstream.h [new file with mode: 0644]
src/support/lyxstring.h

index d0f5741e8774d306c2a70c83283dafa24f51c9fa..7f1555ebda9d787c8ce36d17a1ad6c2f972eea81 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+1999-10-22  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * configure.in: use LYX_CXX_STL_MODERN_STREAMS; check for headers
+       <ostream> and <istream>.
+       
+       * acinclude.m4 (LYX_CXX_STL_MODERN_STREAMS): new test. Checks
+       whether <fstream> provides the latest standard features, or if we
+       have an oldstyle library (like in egcs).
+       (LYX_CXX_STL_STRING): fix the test.
+
+       * src/support/DebugStream.{C,h}: use L{I,O}stream.h and condition the
+       code on MODERN_STL_STREAM.
+
+       * src/support/lyxstring.h: use L{I,O}stream.h.
+
+       * src/support/L{I,O}stream.h: new files, designed to setup
+       correctly streams for our use
+         - includes the right header depending on STL capabilities
+         - puts std::ostream and std::endl (for LOStream.h) or
+         std::istream (LIStream.h) in toplevel namespace.
+
 1999-10-22  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * src/insets/figinset.C: added ifdef guards around the fl_free
index 5135dae80ac809dd751953864a15b720294f05dd..7d85682b38979c56487f2b6e81d24f21ca1749fe 100644 (file)
@@ -281,6 +281,7 @@ AC_DEFUN(LYX_CXX_STL_STACK,[
 AC_CACHE_CHECK(for broken STL stack template,lyx_cv_broken_stack,
  [AC_TRY_COMPILE([
 #include <stack>
+using std::stack;
 ],[
     stack<int> stakk;
     stakk.push(0);
@@ -292,6 +293,22 @@ if test $lyx_cv_broken_stack = yes ; then
    correctly])
 fi])
 
+dnl Usage: LYX_CXX_STL_MODERN_STREAMS : checks whether the C++ compiler
+dnl   supports modern STL streams
+AC_DEFUN(LYX_CXX_STL_MODERN_STREAMS,[
+AC_CACHE_CHECK(for modern STL streams,lyx_cv_modern_streams,
+ [AC_TRY_COMPILE([
+#include <fstream>
+],[
+ std::streambuf * test = std::cerr.rdbuf();
+ test->pubsync();
+],lyx_cv_modern_streams=yes,lyx_cv_modern_streams=no)
+])
+if test $lyx_cv_modern_streams = yes ; then
+  AC_DEFINE(MODERN_STL_STREAMS, 1, 
+   [Define if you have modern standard-compliant STL streams])
+fi])
+
 
 dnl Usage: LYX_CXX_STL_STRING : checks whether the C++ compiler
 dnl   has a working stl string container, the check is really stupid
@@ -306,6 +323,7 @@ AC_DEFUN(LYX_CXX_STL_STRING,[
     ],[
        AC_TRY_COMPILE([
            #include <string>
+           using std::string;
        ],[
            string a("hello there");
            a.clear();
@@ -315,16 +333,20 @@ AC_DEFUN(LYX_CXX_STL_STRING,[
            with_included_string=no
        ],[
            with_included_string=yes
-           AC_DEFINE(USE_INCLUDED_STRING, 1,
-           [Define to use the lyxstring class bundled with LyX.])
-           lyx_flags="$lyx_flags included-string"
+           
        ])
     ])
+    if test x$with_included_string = xyes ; then
+       AC_DEFINE(USE_INCLUDED_STRING, 1,
+           [Define to use the lyxstring class bundled with LyX.])
+           lyx_flags="$lyx_flags included-string"
+    fi
     AM_CONDITIONAL(USE_LYXSTRING, test x$with_included_string = xyes)
     AC_MSG_RESULT([$with_included_string])
 ])
 
 
+
 dnl LYX_CXX_MUTABLE
 AC_DEFUN(LYX_CXX_MUTABLE, [
 AC_REQUIRE([LYX_PROG_CXX])
index f06dce6d43182d4aff1f427f8db77eea5dfc69be..e9762ba47b20605158ec8a55fedc97b3aa37e59c 100644 (file)
@@ -67,8 +67,10 @@ LYX_CXX_STL_STRING
 LYX_CXX_NAMESPACES
 LYX_CXX_CHEADERS
 LYX_CXX_RTTI
+AC_CHECK_HEADERS(ostream istream)
+LYX_CXX_STL_MODERN_STREAMS
 
-### Libarary Files
+### Library Files
 dnl by testing these we check if it is ok to have
 dnl -lc and -lm as args to the compiler
 AC_CHECK_LIB(m, sin)
index a450373c7368517fd31033a17db4ed0f4ff3b4ef..3fff6ac0dbb611d983d6f7f881ea8d8a5a3d50cf 100644 (file)
@@ -6,7 +6,6 @@
 // but should be adaptable to any project.
 
 //#define TEST_DEBUGSTREAM
-//#define MODERN_STL
 
 //#include "DebugStream.h"
 #include "debug.h"
 // Since the current C++ lib in egcs does not have a standard implementation
 // of basic_streambuf and basic_filebuf we don't have to include this
 // header.
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
 #include <fstream>
 #endif
 
+using std::streambuf;
+using std::streamsize;
+using std::filebuf;
+using std::cerr;
+using std::ios;
+
 ostream & operator<<(ostream & o, Debug::type t)
 {
        return o << int(t);
@@ -54,7 +59,7 @@ public:
 protected:
        ///
        virtual int sync() {
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
                sb2->pubsync();
                return sb1->pubsync();
 #else
@@ -64,7 +69,7 @@ protected:
        }
        ///
        virtual streamsize xsputn(char const * p, streamsize n) {
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
                sb2->sputn(p, n);
                return sb1->sputn(p, n);
 #else
@@ -74,7 +79,7 @@ protected:
        }
        ///
        virtual int overflow(int c = EOF) {
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
                sb2->sputc(c);
                return sb1->sputc(c);
 #else
@@ -98,7 +103,7 @@ public:
 protected:
        ///
        virtual int sync() {
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
                return sb->pubsync();
 #else
                return sb->sync();
@@ -106,7 +111,7 @@ protected:
        }
        ///
        virtual streamsize xsputn(char const * p, streamsize n) {
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
                return sb->sputn(p, n);
 #else
                return sb->xsputn(p, n);
@@ -114,7 +119,7 @@ protected:
        }
        ///
        virtual int overflow(int c = EOF) {
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
                return sb->sputc(c);
 #else
                return sb->overflow(c);
index 6fb383ed9fb91fa63585d56bdd47e50824e03e75..8952248bf2e0f964c484ec4c9bbffdefc738012d 100644 (file)
 #ifndef DEBUGSTREAM_H
 #define DEBUGSTREAM_H
 
-#ifdef _STANDARD_C_PLUS_PLUS
-#define MODERN_STL
-#endif
-
-#ifdef MODERN_STL
-#include <ostream>
-#else
-#include <iostream>
-#endif
-
-//#ifdef MODERN_STL
-using std::ostream;
-using std::streambuf;
-using std::streamsize;
-using std::filebuf;
-using std::cerr;
-using std::ios;
-using std::endl; 
-//#endif
+#include "LOstream.h"
 
 #ifdef TEST_DEBUGSTREAM
 #include <string>
diff --git a/src/support/LIstream.h b/src/support/LIstream.h
new file mode 100644 (file)
index 0000000..b59353c
--- /dev/null
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *         Copyright (C) 1995 Matthias Ettrich
+ *          Copyright (C) 1995-1999 The LyX Team.
+ *
+ *======================================================*/
+
+
+#ifndef LISTREAM_H
+#define LISTREAM_H 
+
+#ifdef HAVE_CONFIG_H
+#include <config.h> 
+#endif
+
+#ifdef HAVE_ISTREAM
+#include <istream>
+#else 
+#include <iostream>
+#endif
+
+using std::istream;
+
+#endif
diff --git a/src/support/LOstream.h b/src/support/LOstream.h
new file mode 100644 (file)
index 0000000..0182667
--- /dev/null
@@ -0,0 +1,29 @@
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *         Copyright (C) 1995 Matthias Ettrich
+ *          Copyright (C) 1995-1999 The LyX Team.
+ *
+ *======================================================*/
+
+
+#ifndef LOSTREAM_H
+#define LOSTREAM_H 
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif             
+
+#ifdef HAVE_OSTREAM
+#include <ostream>
+#else 
+#include <iostream>
+#endif
+
+using std::ostream;
+using std::endl; 
+
+#endif
index d78adfe03f3499c13573755f0a7483a39b5b46aa..91df64af7ba581335af870f8df27f8e764f97862 100644 (file)
@@ -29,6 +29,9 @@
 #include <config.h> // needed at least for compilers that do not
 #endif              // understand `explicit' (JMarc)
 
+#include "LOstream.h"
+#include "LIstream.h"
+
 #if 0
 #include <iterator>
 #endif
@@ -588,7 +591,6 @@ lyxstring operator+(lyxstring::value_type a, lyxstring const & b);
 lyxstring operator+(lyxstring const & a, lyxstring::value_type const * b);
 lyxstring operator+(lyxstring const & a, lyxstring::value_type b);
 
-class istream; class ostream;
 istream & operator>>(istream &, lyxstring &);
 ostream & operator<<(ostream &, lyxstring const &);
 istream & getline(istream &, lyxstring &, lyxstring::value_type delim = '\n');