mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Better support for various streams implementations
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@229 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f157947948
commit
28aa3975e6
21
ChangeLog
21
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>
|
1999-10-22 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||||
|
|
||||||
* src/insets/figinset.C: added ifdef guards around the fl_free
|
* src/insets/figinset.C: added ifdef guards around the fl_free
|
||||||
|
28
acinclude.m4
28
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_CACHE_CHECK(for broken STL stack template,lyx_cv_broken_stack,
|
||||||
[AC_TRY_COMPILE([
|
[AC_TRY_COMPILE([
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
using std::stack;
|
||||||
],[
|
],[
|
||||||
stack<int> stakk;
|
stack<int> stakk;
|
||||||
stakk.push(0);
|
stakk.push(0);
|
||||||
@ -292,6 +293,22 @@ if test $lyx_cv_broken_stack = yes ; then
|
|||||||
correctly])
|
correctly])
|
||||||
fi])
|
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 Usage: LYX_CXX_STL_STRING : checks whether the C++ compiler
|
||||||
dnl has a working stl string container, the check is really stupid
|
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([
|
AC_TRY_COMPILE([
|
||||||
#include <string>
|
#include <string>
|
||||||
|
using std::string;
|
||||||
],[
|
],[
|
||||||
string a("hello there");
|
string a("hello there");
|
||||||
a.clear();
|
a.clear();
|
||||||
@ -315,16 +333,20 @@ AC_DEFUN(LYX_CXX_STL_STRING,[
|
|||||||
with_included_string=no
|
with_included_string=no
|
||||||
],[
|
],[
|
||||||
with_included_string=yes
|
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)
|
AM_CONDITIONAL(USE_LYXSTRING, test x$with_included_string = xyes)
|
||||||
AC_MSG_RESULT([$with_included_string])
|
AC_MSG_RESULT([$with_included_string])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dnl LYX_CXX_MUTABLE
|
dnl LYX_CXX_MUTABLE
|
||||||
AC_DEFUN(LYX_CXX_MUTABLE, [
|
AC_DEFUN(LYX_CXX_MUTABLE, [
|
||||||
AC_REQUIRE([LYX_PROG_CXX])
|
AC_REQUIRE([LYX_PROG_CXX])
|
||||||
|
@ -67,8 +67,10 @@ LYX_CXX_STL_STRING
|
|||||||
LYX_CXX_NAMESPACES
|
LYX_CXX_NAMESPACES
|
||||||
LYX_CXX_CHEADERS
|
LYX_CXX_CHEADERS
|
||||||
LYX_CXX_RTTI
|
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 by testing these we check if it is ok to have
|
||||||
dnl -lc and -lm as args to the compiler
|
dnl -lc and -lm as args to the compiler
|
||||||
AC_CHECK_LIB(m, sin)
|
AC_CHECK_LIB(m, sin)
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
// but should be adaptable to any project.
|
// but should be adaptable to any project.
|
||||||
|
|
||||||
//#define TEST_DEBUGSTREAM
|
//#define TEST_DEBUGSTREAM
|
||||||
//#define MODERN_STL
|
|
||||||
|
|
||||||
//#include "DebugStream.h"
|
//#include "DebugStream.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@ -14,10 +13,16 @@
|
|||||||
// Since the current C++ lib in egcs does not have a standard implementation
|
// 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
|
// of basic_streambuf and basic_filebuf we don't have to include this
|
||||||
// header.
|
// header.
|
||||||
#ifdef MODERN_STL
|
#ifdef MODERN_STL_STREAMS
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using std::streambuf;
|
||||||
|
using std::streamsize;
|
||||||
|
using std::filebuf;
|
||||||
|
using std::cerr;
|
||||||
|
using std::ios;
|
||||||
|
|
||||||
ostream & operator<<(ostream & o, Debug::type t)
|
ostream & operator<<(ostream & o, Debug::type t)
|
||||||
{
|
{
|
||||||
return o << int(t);
|
return o << int(t);
|
||||||
@ -54,7 +59,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
virtual int sync() {
|
virtual int sync() {
|
||||||
#ifdef MODERN_STL
|
#ifdef MODERN_STL_STREAMS
|
||||||
sb2->pubsync();
|
sb2->pubsync();
|
||||||
return sb1->pubsync();
|
return sb1->pubsync();
|
||||||
#else
|
#else
|
||||||
@ -64,7 +69,7 @@ protected:
|
|||||||
}
|
}
|
||||||
///
|
///
|
||||||
virtual streamsize xsputn(char const * p, streamsize n) {
|
virtual streamsize xsputn(char const * p, streamsize n) {
|
||||||
#ifdef MODERN_STL
|
#ifdef MODERN_STL_STREAMS
|
||||||
sb2->sputn(p, n);
|
sb2->sputn(p, n);
|
||||||
return sb1->sputn(p, n);
|
return sb1->sputn(p, n);
|
||||||
#else
|
#else
|
||||||
@ -74,7 +79,7 @@ protected:
|
|||||||
}
|
}
|
||||||
///
|
///
|
||||||
virtual int overflow(int c = EOF) {
|
virtual int overflow(int c = EOF) {
|
||||||
#ifdef MODERN_STL
|
#ifdef MODERN_STL_STREAMS
|
||||||
sb2->sputc(c);
|
sb2->sputc(c);
|
||||||
return sb1->sputc(c);
|
return sb1->sputc(c);
|
||||||
#else
|
#else
|
||||||
@ -98,7 +103,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
virtual int sync() {
|
virtual int sync() {
|
||||||
#ifdef MODERN_STL
|
#ifdef MODERN_STL_STREAMS
|
||||||
return sb->pubsync();
|
return sb->pubsync();
|
||||||
#else
|
#else
|
||||||
return sb->sync();
|
return sb->sync();
|
||||||
@ -106,7 +111,7 @@ protected:
|
|||||||
}
|
}
|
||||||
///
|
///
|
||||||
virtual streamsize xsputn(char const * p, streamsize n) {
|
virtual streamsize xsputn(char const * p, streamsize n) {
|
||||||
#ifdef MODERN_STL
|
#ifdef MODERN_STL_STREAMS
|
||||||
return sb->sputn(p, n);
|
return sb->sputn(p, n);
|
||||||
#else
|
#else
|
||||||
return sb->xsputn(p, n);
|
return sb->xsputn(p, n);
|
||||||
@ -114,7 +119,7 @@ protected:
|
|||||||
}
|
}
|
||||||
///
|
///
|
||||||
virtual int overflow(int c = EOF) {
|
virtual int overflow(int c = EOF) {
|
||||||
#ifdef MODERN_STL
|
#ifdef MODERN_STL_STREAMS
|
||||||
return sb->sputc(c);
|
return sb->sputc(c);
|
||||||
#else
|
#else
|
||||||
return sb->overflow(c);
|
return sb->overflow(c);
|
||||||
|
@ -12,25 +12,7 @@
|
|||||||
#ifndef DEBUGSTREAM_H
|
#ifndef DEBUGSTREAM_H
|
||||||
#define DEBUGSTREAM_H
|
#define DEBUGSTREAM_H
|
||||||
|
|
||||||
#ifdef _STANDARD_C_PLUS_PLUS
|
#include "LOstream.h"
|
||||||
#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
|
|
||||||
|
|
||||||
#ifdef TEST_DEBUGSTREAM
|
#ifdef TEST_DEBUGSTREAM
|
||||||
#include <string>
|
#include <string>
|
||||||
|
28
src/support/LIstream.h
Normal file
28
src/support/LIstream.h
Normal file
@ -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
|
29
src/support/LOstream.h
Normal file
29
src/support/LOstream.h
Normal file
@ -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
|
@ -29,6 +29,9 @@
|
|||||||
#include <config.h> // needed at least for compilers that do not
|
#include <config.h> // needed at least for compilers that do not
|
||||||
#endif // understand `explicit' (JMarc)
|
#endif // understand `explicit' (JMarc)
|
||||||
|
|
||||||
|
#include "LOstream.h"
|
||||||
|
#include "LIstream.h"
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#endif
|
#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 const * b);
|
||||||
lyxstring operator+(lyxstring const & a, lyxstring::value_type b);
|
lyxstring operator+(lyxstring const & a, lyxstring::value_type b);
|
||||||
|
|
||||||
class istream; class ostream;
|
|
||||||
istream & operator>>(istream &, lyxstring &);
|
istream & operator>>(istream &, lyxstring &);
|
||||||
ostream & operator<<(ostream &, lyxstring const &);
|
ostream & operator<<(ostream &, lyxstring const &);
|
||||||
istream & getline(istream &, lyxstring &, lyxstring::value_type delim = '\n');
|
istream & getline(istream &, lyxstring &, lyxstring::value_type delim = '\n');
|
||||||
|
Loading…
Reference in New Issue
Block a user