From: Jean-Marc Lasgouttes Date: Fri, 22 Oct 1999 09:45:25 +0000 (+0000) Subject: Better support for various streams implementations X-Git-Tag: 1.6.10~22586 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=28aa3975e650f7fc87601ba3bbfd7eeca19b80a6;p=features.git Better support for various streams implementations git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@229 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index d0f5741e87..7f1555ebda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +1999-10-22 Jean-Marc Lasgouttes + + * configure.in: use LYX_CXX_STL_MODERN_STREAMS; check for headers + and . + + * acinclude.m4 (LYX_CXX_STL_MODERN_STREAMS): new test. Checks + whether 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 * src/insets/figinset.C: added ifdef guards around the fl_free diff --git a/acinclude.m4 b/acinclude.m4 index 5135dae80a..7d85682b38 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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 +using std::stack; ],[ stack 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 +],[ + 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 + 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]) diff --git a/configure.in b/configure.in index f06dce6d43..e9762ba47b 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/src/support/DebugStream.C b/src/support/DebugStream.C index a450373c73..3fff6ac0db 100644 --- a/src/support/DebugStream.C +++ b/src/support/DebugStream.C @@ -6,7 +6,6 @@ // but should be adaptable to any project. //#define TEST_DEBUGSTREAM -//#define MODERN_STL //#include "DebugStream.h" #include "debug.h" @@ -14,10 +13,16 @@ // 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 #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); diff --git a/src/support/DebugStream.h b/src/support/DebugStream.h index 6fb383ed9f..8952248bf2 100644 --- a/src/support/DebugStream.h +++ b/src/support/DebugStream.h @@ -12,25 +12,7 @@ #ifndef DEBUGSTREAM_H #define DEBUGSTREAM_H -#ifdef _STANDARD_C_PLUS_PLUS -#define MODERN_STL -#endif - -#ifdef MODERN_STL -#include -#else -#include -#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 diff --git a/src/support/LIstream.h b/src/support/LIstream.h new file mode 100644 index 0000000000..b59353cb9e --- /dev/null +++ b/src/support/LIstream.h @@ -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 +#endif + +#ifdef HAVE_ISTREAM +#include +#else +#include +#endif + +using std::istream; + +#endif diff --git a/src/support/LOstream.h b/src/support/LOstream.h new file mode 100644 index 0000000000..018266731f --- /dev/null +++ b/src/support/LOstream.h @@ -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 +#endif + +#ifdef HAVE_OSTREAM +#include +#else +#include +#endif + +using std::ostream; +using std::endl; + +#endif diff --git a/src/support/lyxstring.h b/src/support/lyxstring.h index d78adfe03f..91df64af7b 100644 --- a/src/support/lyxstring.h +++ b/src/support/lyxstring.h @@ -29,6 +29,9 @@ #include // needed at least for compilers that do not #endif // understand `explicit' (JMarc) +#include "LOstream.h" +#include "LIstream.h" + #if 0 #include #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');