Replaced ostream with FILE* in wxExpr.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2913 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -330,7 +330,7 @@
|
|||||||
* Use standard C++ streams if 1. If 0, use wxWin
|
* Use standard C++ streams if 1. If 0, use wxWin
|
||||||
* streams implementation.
|
* streams implementation.
|
||||||
*/
|
*/
|
||||||
#define wxUSE_STD_IOSTREAM 1
|
#define wxUSE_STD_IOSTREAM 0
|
||||||
/*
|
/*
|
||||||
* wxLibrary class
|
* wxLibrary class
|
||||||
*/
|
*/
|
||||||
|
@@ -250,6 +250,7 @@ if test $DEBUG_CONFIGURE = 1; then
|
|||||||
DEFAULT_wxUSE_LIBJPEG=no
|
DEFAULT_wxUSE_LIBJPEG=no
|
||||||
DEFAULT_wxUSE_ODBC=no
|
DEFAULT_wxUSE_ODBC=no
|
||||||
|
|
||||||
|
DEFAULT_wxUSE_STD_IOSTREAM=no
|
||||||
DEFAULT_wxUSE_FILE=no
|
DEFAULT_wxUSE_FILE=no
|
||||||
DEFAULT_wxUSE_TEXTFILE=no
|
DEFAULT_wxUSE_TEXTFILE=no
|
||||||
DEFAULT_wxUSE_TIMEDATE=no
|
DEFAULT_wxUSE_TIMEDATE=no
|
||||||
@@ -347,6 +348,7 @@ else
|
|||||||
DEFAULT_wxUSE_LIBJPEG=yes
|
DEFAULT_wxUSE_LIBJPEG=yes
|
||||||
DEFAULT_wxUSE_ODBC=no
|
DEFAULT_wxUSE_ODBC=no
|
||||||
|
|
||||||
|
DEFAULT_wxUSE_STD_IOSTREAM=yes
|
||||||
DEFAULT_wxUSE_FILE=yes
|
DEFAULT_wxUSE_FILE=yes
|
||||||
DEFAULT_wxUSE_TEXTFILE=yes
|
DEFAULT_wxUSE_TEXTFILE=yes
|
||||||
DEFAULT_wxUSE_TIMEDATE=yes
|
DEFAULT_wxUSE_TIMEDATE=yes
|
||||||
@@ -518,6 +520,7 @@ WX_ARG_ENABLE(unicode, [ --enable-unicode compile wxString with Unic
|
|||||||
WX_ARG_ENABLE(wcsrtombs, [ --enable-wcsrtombs use wcsrtombs instead of buggy (GNU libc1/Linux libc5) wcstombs], wxUSE_WCSRTOMBS)
|
WX_ARG_ENABLE(wcsrtombs, [ --enable-wcsrtombs use wcsrtombs instead of buggy (GNU libc1/Linux libc5) wcstombs], wxUSE_WCSRTOMBS)
|
||||||
WX_ARG_ENABLE(wxprintfv, [ --enable-wxprintfv use wxWindows implementation of vprintf()], wxUSE_EXPERIMENTAL_PRINTF)
|
WX_ARG_ENABLE(wxprintfv, [ --enable-wxprintfv use wxWindows implementation of vprintf()], wxUSE_EXPERIMENTAL_PRINTF)
|
||||||
WX_ARG_ENABLE(joystick, [ --enable-joystick compile in joystick support (Linux only)], wxUSE_JOYSTICK)
|
WX_ARG_ENABLE(joystick, [ --enable-joystick compile in joystick support (Linux only)], wxUSE_JOYSTICK)
|
||||||
|
WX_ARG_ENABLE(std_iostreams, [ --enable-std_iostreams use standard C++ stream classes], wxUSE_STD_IOSTREAM)
|
||||||
|
|
||||||
dnl ---------------------------------------------------------------------------
|
dnl ---------------------------------------------------------------------------
|
||||||
dnl "big" options (i.e. those which change a lot of things throughout the library)
|
dnl "big" options (i.e. those which change a lot of things throughout the library)
|
||||||
@@ -1533,6 +1536,10 @@ if test "$wxUSE_FILE" = "yes"; then
|
|||||||
AC_DEFINE(wxUSE_FILE)
|
AC_DEFINE(wxUSE_FILE)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "$wxUSE_STD_IOSTREAM" = "yes"; then
|
||||||
|
AC_DEFINE(wxUSE_STD_IOSTREAM)
|
||||||
|
fi
|
||||||
|
|
||||||
if test "$wxUSE_TEXTFILE" = "yes"; then
|
if test "$wxUSE_TEXTFILE" = "yes"; then
|
||||||
if test "$wxUSE_FILE" != "yes"; then
|
if test "$wxUSE_FILE" != "yes"; then
|
||||||
AC_MSG_WARN(wxTextFile requires wxFile and it won't be compiled without it)
|
AC_MSG_WARN(wxTextFile requires wxFile and it won't be compiled without it)
|
||||||
|
@@ -21,8 +21,6 @@
|
|||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
|
|
||||||
#include "wx/ioswrap.h"
|
|
||||||
|
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
#include "wx/hash.h"
|
#include "wx/hash.h"
|
||||||
|
|
||||||
@@ -141,9 +139,9 @@ class WXDLLEXPORT wxExpr
|
|||||||
wxExpr *AttributeValue(const wxString& word) const; // Use only for a clause
|
wxExpr *AttributeValue(const wxString& word) const; // Use only for a clause
|
||||||
wxString Functor(void) const; // Only for a clause
|
wxString Functor(void) const; // Only for a clause
|
||||||
bool IsFunctor(const wxString& s) const; // Only for a clause
|
bool IsFunctor(const wxString& s) const; // Only for a clause
|
||||||
void WriteClause(ostream& stream); // Write this expression as a top-level clause
|
void WriteClause(FILE* stream); // Write this expression as a top-level clause
|
||||||
void WriteExpr(ostream& stream); // Write as any other subexpression
|
void WriteExpr(FILE* stream); // Write as any other subexpression
|
||||||
void WriteLispExpr(ostream& stream);
|
void WriteLispExpr(FILE* stream);
|
||||||
|
|
||||||
// Append an expression to a list
|
// Append an expression to a list
|
||||||
void Append(wxExpr *expr);
|
void Append(wxExpr *expr);
|
||||||
@@ -244,13 +242,13 @@ public:
|
|||||||
bool Read(const wxString& filename);
|
bool Read(const wxString& filename);
|
||||||
bool ReadFromString(const wxString& buffer);
|
bool ReadFromString(const wxString& buffer);
|
||||||
bool Write(const wxString& fileName);
|
bool Write(const wxString& fileName);
|
||||||
bool Write(ostream& stream);
|
bool Write(FILE* stream);
|
||||||
void WriteLisp(ostream& stream);
|
void WriteLisp(FILE* stream);
|
||||||
|
|
||||||
// Compatibility
|
// Compatibility
|
||||||
inline bool ReadProlog(wxChar *filename) { return Read(wxString(filename)); }
|
inline bool ReadProlog(wxChar *filename) { return Read(wxString(filename)); }
|
||||||
inline bool ReadPrologFromString(char *buffer) { return ReadFromString(wxString(buffer)); }
|
inline bool ReadPrologFromString(char *buffer) { return ReadFromString(wxString(buffer)); }
|
||||||
inline void WriteProlog(ostream& stream) { Write(stream); }
|
inline void WriteProlog(FILE* stream) { Write(stream); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxExprDatabase)
|
DECLARE_DYNAMIC_CLASS(wxExprDatabase)
|
||||||
|
@@ -20,18 +20,11 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_IOSTREAMH
|
|
||||||
#include <fstream.h>
|
|
||||||
#else
|
|
||||||
#include <fstream>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
|
|
||||||
#include "wx/expr.h"
|
#include "wx/expr.h"
|
||||||
#include "wx/wxexpr.h"
|
#include "wx/wxexpr.h"
|
||||||
|
|
||||||
@@ -671,7 +664,7 @@ void wxExpr::AssignAttributeValue(wxChar *att, wxChar **var) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxExpr::WriteClause(ostream& stream) // Write this expression as a top-level clause
|
void wxExpr::WriteClause(FILE* stream) // Write this expression as a top-level clause
|
||||||
{
|
{
|
||||||
if (type != wxExprList)
|
if (type != wxExprList)
|
||||||
return;
|
return;
|
||||||
@@ -680,23 +673,24 @@ void wxExpr::WriteClause(ostream& stream) // Write this expression as a top-lev
|
|||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
node->WriteExpr(stream);
|
node->WriteExpr(stream);
|
||||||
stream << "(";
|
fprintf( stream, "(" );
|
||||||
node = node->next;
|
node = node->next;
|
||||||
bool first = TRUE;
|
bool first = TRUE;
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
if (!first)
|
if (!first)
|
||||||
stream << " ";
|
fprintf( stream, " " );
|
||||||
node->WriteExpr(stream);
|
node->WriteExpr(stream);
|
||||||
node = node->next;
|
node = node->next;
|
||||||
if (node) stream << ",\n";
|
if (node)
|
||||||
|
fprintf( stream, ",\n" );
|
||||||
first = FALSE;
|
first = FALSE;
|
||||||
}
|
}
|
||||||
stream << ").\n\n";
|
fprintf( stream, ").\n\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxExpr::WriteExpr(ostream& stream) // Write as any other subexpression
|
void wxExpr::WriteExpr(FILE* stream) // Write as any other subexpression
|
||||||
{
|
{
|
||||||
// This seems to get round an optimizer bug when
|
// This seems to get round an optimizer bug when
|
||||||
// using Watcom C++ 10a in WIN32 compilation mode.
|
// using Watcom C++ 10a in WIN32 compilation mode.
|
||||||
@@ -713,25 +707,18 @@ void wxExpr::WriteExpr(ostream& stream) // Write as any other subexpression
|
|||||||
{
|
{
|
||||||
case wxExprInteger:
|
case wxExprInteger:
|
||||||
{
|
{
|
||||||
stream << value.integer;
|
fprintf( stream, "%ld", value.integer );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxExprReal:
|
case wxExprReal:
|
||||||
{
|
{
|
||||||
double f = value.real;
|
double f = value.real;
|
||||||
/* Now the parser can cope with this.
|
fprintf( stream, "%.6g", f);
|
||||||
// Prevent printing in 'e' notation. Any better way?
|
|
||||||
if (fabs(f) < 0.00001)
|
|
||||||
f = 0.0;
|
|
||||||
*/
|
|
||||||
char buf[40];
|
|
||||||
sprintf(buf, "%.6g", f);
|
|
||||||
stream << buf;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxExprString:
|
case wxExprString:
|
||||||
{
|
{
|
||||||
stream << "\"";
|
fprintf( stream, "\"" );
|
||||||
int i;
|
int i;
|
||||||
const wxWX2MBbuf val = wxConvLibc.cWX2MB(value.string);
|
const wxWX2MBbuf val = wxConvLibc.cWX2MB(value.string);
|
||||||
int len = strlen(val);
|
int len = strlen(val);
|
||||||
@@ -739,11 +726,13 @@ void wxExpr::WriteExpr(ostream& stream) // Write as any other subexpression
|
|||||||
{
|
{
|
||||||
char ch = val[i];
|
char ch = val[i];
|
||||||
if (ch == '"' || ch == '\\')
|
if (ch == '"' || ch == '\\')
|
||||||
stream << "\\";
|
fprintf( stream, "\\" );
|
||||||
stream << ch;
|
char tmp[2];
|
||||||
|
tmp[0] = ch;
|
||||||
|
tmp[1] = 0;
|
||||||
|
fprintf( stream, tmp );
|
||||||
}
|
}
|
||||||
|
fprintf( stream, "\"" );
|
||||||
stream << "\"";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxExprWord:
|
case wxExprWord:
|
||||||
@@ -763,19 +752,19 @@ void wxExpr::WriteExpr(ostream& stream) // Write as any other subexpression
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (quote_it)
|
if (quote_it)
|
||||||
stream << "'";
|
fprintf( stream ,"'" );
|
||||||
|
|
||||||
stream << val;
|
fprintf( stream, (const char*) val );
|
||||||
|
|
||||||
if (quote_it)
|
if (quote_it)
|
||||||
stream << "'";
|
fprintf( stream, "'" );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxExprList:
|
case wxExprList:
|
||||||
{
|
{
|
||||||
if (!value.first)
|
if (!value.first)
|
||||||
stream << "[]";
|
fprintf( stream, "[]" );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxExpr *expr = value.first;
|
wxExpr *expr = value.first;
|
||||||
@@ -785,19 +774,20 @@ void wxExpr::WriteExpr(ostream& stream) // Write as any other subexpression
|
|||||||
wxExpr *arg1 = expr->next;
|
wxExpr *arg1 = expr->next;
|
||||||
wxExpr *arg2 = arg1->next;
|
wxExpr *arg2 = arg1->next;
|
||||||
arg1->WriteExpr(stream);
|
arg1->WriteExpr(stream);
|
||||||
stream << " = ";
|
fprintf( stream, " = " );
|
||||||
arg2->WriteExpr(stream);
|
arg2->WriteExpr(stream);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stream << "[";
|
fprintf( stream, "[" );
|
||||||
while (expr)
|
while (expr)
|
||||||
{
|
{
|
||||||
expr->WriteExpr(stream);
|
expr->WriteExpr(stream);
|
||||||
expr = expr->next;
|
expr = expr->next;
|
||||||
if (expr) stream << ", ";
|
if (expr)
|
||||||
|
fprintf( stream, ", " );
|
||||||
}
|
}
|
||||||
stream << "]";
|
fprintf( stream, "]" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -806,43 +796,48 @@ void wxExpr::WriteExpr(ostream& stream) // Write as any other subexpression
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxExpr::WriteLispExpr(ostream& stream)
|
void wxExpr::WriteLispExpr(FILE* stream)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case wxExprInteger:
|
case wxExprInteger:
|
||||||
{
|
{
|
||||||
stream << value.integer;
|
fprintf( stream, "%ld", value.integer );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxExprReal:
|
case wxExprReal:
|
||||||
{
|
{
|
||||||
stream << value.real;
|
fprintf( stream, "%.6g", value.real );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxExprString:
|
case wxExprString:
|
||||||
{
|
{
|
||||||
stream << "\"" << value.string << "\"";
|
fprintf( stream, "\"" );
|
||||||
|
const wxWX2MBbuf val = wxConvLibc.cWX2MB(value.string);
|
||||||
|
fprintf( stream, (const char*) val );
|
||||||
|
fprintf( stream, "\"" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxExprWord:
|
case wxExprWord:
|
||||||
{
|
{
|
||||||
stream << value.word;
|
const wxWX2MBbuf val = wxConvLibc.cWX2MB(value.word);
|
||||||
|
fprintf( stream, (const char*) val );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxExprList:
|
case wxExprList:
|
||||||
{
|
{
|
||||||
wxExpr *expr = value.first;
|
wxExpr *expr = value.first;
|
||||||
|
|
||||||
stream << "(";
|
fprintf( stream, "(" );
|
||||||
while (expr)
|
while (expr)
|
||||||
{
|
{
|
||||||
expr->WriteLispExpr(stream);
|
expr->WriteLispExpr(stream);
|
||||||
expr = expr->next;
|
expr = expr->next;
|
||||||
if (expr) stream << " ";
|
if (expr)
|
||||||
|
fprintf( stream, " " );
|
||||||
}
|
}
|
||||||
|
|
||||||
stream << ")";
|
fprintf( stream, ")" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxExprNull: break;
|
case wxExprNull: break;
|
||||||
@@ -1079,13 +1074,15 @@ bool wxExprDatabase::ReadFromString(const wxString& buffer)
|
|||||||
|
|
||||||
bool wxExprDatabase::Write(const wxString& fileName)
|
bool wxExprDatabase::Write(const wxString& fileName)
|
||||||
{
|
{
|
||||||
ofstream str(MBSTRINGCAST fileName.mb_str());
|
FILE *stream = fopen( fileName.fn_str(), "w+" );
|
||||||
if (str.bad())
|
|
||||||
|
if (!stream)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return Write(str);
|
|
||||||
|
return Write(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxExprDatabase::Write(ostream& stream)
|
bool wxExprDatabase::Write(FILE *stream)
|
||||||
{
|
{
|
||||||
noErrors = 0;
|
noErrors = 0;
|
||||||
wxNode *node = First();
|
wxNode *node = First();
|
||||||
@@ -1098,7 +1095,7 @@ bool wxExprDatabase::Write(ostream& stream)
|
|||||||
return (noErrors == 0);
|
return (noErrors == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxExprDatabase::WriteLisp(ostream& stream)
|
void wxExprDatabase::WriteLisp(FILE* stream)
|
||||||
{
|
{
|
||||||
noErrors = 0;
|
noErrors = 0;
|
||||||
wxNode *node = First();
|
wxNode *node = First();
|
||||||
@@ -1106,7 +1103,7 @@ void wxExprDatabase::WriteLisp(ostream& stream)
|
|||||||
{
|
{
|
||||||
wxExpr *expr = (wxExpr *)node->Data();
|
wxExpr *expr = (wxExpr *)node->Data();
|
||||||
expr->WriteLispExpr(stream);
|
expr->WriteLispExpr(stream);
|
||||||
stream << "\n\n";
|
fprintf( stream, "\n\n" );
|
||||||
node = node->Next();
|
node = node->Next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user