+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
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);
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
],[
AC_TRY_COMPILE([
#include <string>
+ using std::string;
],[
string a("hello there");
a.clear();
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])
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)
// 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);
protected:
///
virtual int sync() {
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
sb2->pubsync();
return sb1->pubsync();
#else
}
///
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
}
///
virtual int overflow(int c = EOF) {
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
sb2->sputc(c);
return sb1->sputc(c);
#else
protected:
///
virtual int sync() {
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
return sb->pubsync();
#else
return sb->sync();
}
///
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);
}
///
virtual int overflow(int c = EOF) {
-#ifdef MODERN_STL
+#ifdef MODERN_STL_STREAMS
return sb->sputc(c);
#else
return sb->overflow(c);
#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>
--- /dev/null
+// -*- 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
--- /dev/null
+// -*- 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
#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
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');