use const wxMBConv& instead of wxMBConv& in public methods so that it's possible to pass in temporary objects;

don't use global wxConvUTF8 object internally, it may be unavailable at static objects destruction time


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45973 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-05-11 20:55:24 +00:00
parent 163d9efc6b
commit 5487ff0f50
16 changed files with 45 additions and 42 deletions

View File

@@ -353,7 +353,7 @@ The following functions control this option:
\param{const wxString\& }{localFilename = wxEmptyString},
\param{const wxString\& }{globalFilename = wxEmptyString},
\param{long}{ style = 0},
\param{wxMBConv\&}{ conv = wxConvUTF8}}
\param{const wxMBConv\&}{ conv = wxConvAuto()}}
This is the default and only constructor of the wxConfigBase class, and
derived classes.

View File

@@ -43,7 +43,7 @@ None
\func{}{wxDataInputStream}{\param{wxInputStream\&}{ stream}}
\func{}{wxDataInputStream}{\param{wxInputStream\&}{ stream}, \param{wxMBConv\&}{ conv = wxMBConvUTF8}}
\func{}{wxDataInputStream}{\param{wxInputStream\&}{ stream}, \param{const wxMBConv\&}{ conv = wxConvAuto()}}
Constructs a datastream object from an input stream. Only read methods will
be available. The second form is only available in Unicode build of wxWidgets.

View File

@@ -27,7 +27,7 @@ None
\func{}{wxDataOutputStream}{\param{wxOutputStream\&}{ stream}}
\func{}{wxDataOutputStream}{\param{wxOutputStream\&}{ stream}, \param{wxMBConv\&}{ conv = wxMBConvUTF8}}
\func{}{wxDataOutputStream}{\param{wxOutputStream\&}{ stream}, \param{const wxMBConv\&}{ conv = wxConvAuto(){}
Constructs a datastream object from an output stream. Only write methods will
be available. The second form is only available in Unicode build of wxWidgets.

View File

@@ -210,7 +210,7 @@ The number of bytes read.
\membersection{wxFFile::ReadAll}\label{wxffilereadall}
\func{bool}{ReadAll}{\param{wxString *}{ str}, \param{wxMBConv\&}{ conv = wxConvUTF8}}
\func{bool}{ReadAll}{\param{wxString *}{ str}, \param{const wxMBConv\&}{ conv = wxConvAuto()}}
Reads the entire contents of the file into a string.
@@ -277,7 +277,7 @@ Number of bytes written.
\membersection{wxFFile::Write}\label{wxffilewrites}
\func{bool}{Write}{\param{const wxString\& }{s}, \param{wxMBConv\&}{ conv = wxConvUTF8}}
\func{bool}{Write}{\param{const wxString\& }{s}, \param{const wxMBConv\&}{ conv = wxConvAuto()}}
Writes the contents of the string to the file, returns \true on success.

View File

@@ -335,7 +335,7 @@ the number of bytes actually written
\membersection{wxFile::Write}\label{wxfilewrites}
\func{bool}{Write}{\param{const wxString\& }{s}, \param{wxMBConv\&}{ conv = wxConvUTF8}}
\func{bool}{Write}{\param{const wxString\& }{s}, \param{const wxMBConv\&}{ conv = wxConvUTF8}}
Writes the contents of the string to the file, returns true on success.

View File

@@ -34,7 +34,7 @@ Windows.
\membersection{wxFileConfig::wxFileConfig}\label{wxfileconfigctor}
\func{}{wxFileConfig}{\param{wxInputStream\& }{is}, \param{wxMBConv\& }{conv = wxConvUTF8}}
\func{}{wxFileConfig}{\param{wxInputStream\& }{is}, \param{const wxMBConv\& }{conv = wxConvAuto()}}
Read the config data from the specified stream instead of the associated file,
as usual.
@@ -72,7 +72,7 @@ path name.
\membersection{wxFileConfig::Save}\label{wxfileconfigsave}
\func{bool}{Save}{\param{wxOutputStream\& }{os}, \param{wxMBConv\& }{conv = wxConvUTF8}}
\func{bool}{Save}{\param{wxOutputStream\& }{os}, \param{const wxMBConv\& }{conv = wxConvAuto()}}
Saves all config data to the given stream, returns \true if data was saved
successfully or \false on error.

View File

@@ -107,7 +107,7 @@ Write to the file, return {\tt true} on success, {\tt false} on failure.
\membersection{wxTempFile::Write}\label{wxtempfilewrites}
\func{bool}{Write}{\param{const wxString\& }{str}, \param{wxMBConv\&}{ conv = wxConvLibc}}
\func{bool}{Write}{\param{const wxString\& }{str}, \param{const wxMBConv\&}{ conv = wxConvUTF8}}
Write to the file, return {\tt true} on success, {\tt false} on failure.

View File

@@ -262,9 +262,9 @@ Insert a line before the line number {\it n}.
\membersection{wxTextFile::Open}\label{wxtextfileopen}
\constfunc{bool}{Open}{\param{wxMBConv\&}{ conv = wxConvUTF8}}
\constfunc{bool}{Open}{\param{const wxMBConv\&}{ conv = wxConvAuto()}}
\constfunc{bool}{Open}{\param{const wxString\& }{strFile}, \param{wxMBConv\&}{ conv = wxConvUTF8}}
\constfunc{bool}{Open}{\param{const wxString\& }{strFile}, \param{const wxMBConv\&}{ conv = wxConvAuto()}}
Open() opens the file with the given name or the name which was given in the
\helpref{constructor}{wxtextfilector} and also loads file in memory on
@@ -288,7 +288,7 @@ Delete all lines from the file, set current line number to 0.
\membersection{wxTextFile::Write}\label{wxtextfilewrite}
\constfunc{bool}{Write}{\param{wxTextFileType }{typeNew = wxTextFileType\_None}, \param{wxMBConv\&}{ conv = wxConvUTF8}}
\constfunc{bool}{Write}{\param{wxTextFileType }{typeNew = wxTextFileType\_None}, \param{const wxMBConv\&}{ conv = wxConvAuto()}}
Change the file on disk. The {\it typeNew} parameter allows you to change the
file format (default argument means "don't change type") and may be used to

View File

@@ -45,7 +45,7 @@ For example:
\membersection{wxTextInputStream::wxTextInputStream}\label{wxtextinputstreamctor}
\func{}{wxTextInputStream}{\param{wxInputStream\&}{ stream}, \param{const wxString\&}{ sep=" $\backslash$t"},
\param{wxMBConv\&}{ conv = wxConvUTF8} }
\param{const wxMBConv\&}{ conv = wxConvAuto()} }
Constructs a text stream associated to the given input stream.
@@ -216,7 +216,7 @@ and Unix in their native formats (concerning the line ending).
\membersection{wxTextOutputStream::wxTextOutputStream}\label{wxtextoutputstreamctor}
\func{}{wxTextOutputStream}{\param{wxOutputStream\&}{ stream}, \param{wxEOL}{ mode = wxEOL\_NATIVE}, \param{wxMBConv\&}{ conv = wxConvUTF8}}
\func{}{wxTextOutputStream}{\param{wxOutputStream\&}{ stream}, \param{wxEOL}{ mode = wxEOL\_NATIVE}, \param{const wxMBConv\&}{ conv = wxConvAuto()}}
Constructs a text stream object associated to the given output stream.

View File

@@ -454,7 +454,7 @@ For ANSI builds only (note the use of {\tt char} instead of {\tt wxChar}).
The following constructors allow you to construct wxString from a wide string
in ANSI build or from a C string in Unicode build.
\func{}{wxString}{\param{const wchar\_t*}{ psz}, \param{wxMBConv\&}{ conv}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
\func{}{wxString}{\param{const wchar\_t*}{ psz}, \param{const wxMBConv\&}{ conv}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
Initializes the string from first \arg{nLength} characters of wide string.
The default value of {\tt wxSTRING\_MAXLEN} means take all the string.
@@ -462,7 +462,7 @@ In ANSI build, \arg{conv}'s
\helpref{WC2MB}{wxmbconvwc2mb} method is called to
convert \arg{psz} to wide string. It is ignored in Unicode build.
\func{}{wxString}{\param{const char*}{ psz}, \param{wxMBConv\&}{ conv = wxConvLibc}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
\func{}{wxString}{\param{const char*}{ psz}, \param{const wxMBConv\&}{ conv = wxConvLibc}, \param{size\_t}{ nLength = wxSTRING\_MAXLEN}}
Initializes the string from first \arg{nLength} characters of C string.
The default value of {\tt wxSTRING\_MAXLEN} means take all the string.
@@ -586,7 +586,7 @@ to a function expecting non-const pointer.
\membersection{wxString::char\_str}\label{wxstringcharstr}
\constfunc{wxWritableCharBuffer}{char\_str}{\param{wxMBConv\&}{ conv = wxConvLibc}}
\constfunc{wxWritableCharBuffer}{char\_str}{\param{const wxMBConv\&}{ conv = wxConvLibc}}
Returns an object with string data that is implicitly convertible to
{\tt char*} pointer. Note that any change to the returned buffer is lost and so
@@ -980,9 +980,9 @@ Returns \true if the string contents matches a mask containing '*' and '?'.
\membersection{wxString::mb\_str}\label{wxstringmbstr}
\constfunc{const char*}{mb\_str}{\param{wxMBConv\&}{ conv = wxConvLibc}}
\constfunc{const char*}{mb\_str}{\param{const wxMBConv\&}{ conv = wxConvLibc}}
\constfunc{const wxCharBuffer}{mb\_str}{\param{wxMBConv\&}{ conv = wxConvLibc}}
\constfunc{const wxCharBuffer}{mb\_str}{\param{const wxMBConv\&}{ conv = wxConvLibc}}
Returns multibyte (C string) representation of the string.
In Unicode build, converts using \arg{conv}'s \helpref{cWC2MB}{wxmbconvcwc2mb}
@@ -1350,9 +1350,9 @@ UTF-8 build.
\membersection{wxString::wc\_str}\label{wxstringwcstr}
\constfunc{const wchar\_t*}{wc\_str}{\param{wxMBConv\&}{ conv}}
\constfunc{const wchar\_t*}{wc\_str}{\param{const wxMBConv\&}{ conv}}
\constfunc{const wxWCharBuffer}{wc\_str}{\param{wxMBConv\&}{ conv}}
\constfunc{const wxWCharBuffer}{wc\_str}{\param{const wxMBConv\&}{ conv}}
Returns wide character representation of the string.
In ANSI build, converts using \arg{conv}'s \helpref{cMB2WC}{wxmbconvcmb2wc}

View File

@@ -341,6 +341,8 @@ public:
const wxString& name,
wxPathFormat format = wxPATH_NATIVE) const = 0;
// FIXME-UTF8: remove these from this file, they are used for ANSI
// build only
void SetConv(wxMBConv& conv) { m_pConv = &conv; }
wxMBConv& GetConv() const
{ if (m_pConv) return *m_pConv; else return wxConvLocal; }

View File

@@ -97,7 +97,7 @@ public:
// returns the number of bytes written
size_t Write(const void *pBuf, size_t nCount);
// returns true on success
bool Write(const wxString& s, const wxMBConv& conv = wxConvUTF8);
bool Write(const wxString& s, const wxMBConv& conv = wxMBConvUTF8());
// flush data not yet written
bool Flush();
@@ -167,7 +167,7 @@ public:
// I/O (both functions return true on success, false on failure)
bool Write(const void *p, size_t n) { return m_file.Write(p, n) == n; }
bool Write(const wxString& str, const wxMBConv& conv = wxConvUTF8)
bool Write(const wxString& str, const wxMBConv& conv = wxMBConvUTF8())
{ return m_file.Write(str, conv); }
// different ways to close the file

View File

@@ -41,7 +41,7 @@ protected:
{ return true; }
virtual bool OnWrite(wxTextFileType WXUNUSED(typeNew),
const wxMBConv& WXUNUSED(conv) = wxConvUTF8)
const wxMBConv& WXUNUSED(conv) = wxMBConvUTF8())
{ return true; }
private:

View File

@@ -485,9 +485,9 @@ private:
{ return ConvertStr(str, n, conv); }
static wxCharBuffer ImplStr(const wchar_t* str)
{ return ConvertStr(str, npos, wxConvUTF8).data; }
{ return ConvertStr(str, npos, wxMBConvUTF8()).data; }
static SubstrBufFromWC ImplStr(const wchar_t* str, size_t n)
{ return ConvertStr(str, n, wxConvUTF8); }
{ return ConvertStr(str, n, wxMBConvUTF8()); }
size_t PosToImpl(size_t pos) const
{
@@ -1144,21 +1144,22 @@ public:
const char* ToUTF8() const { return wx_str(); }
#elif wxUSE_UNICODE_WCHAR
static wxString FromUTF8(const char *utf8)
{ return wxString(utf8, wxConvUTF8); }
{ return wxString(utf8, wxMBConvUTF8()); }
static wxString FromUTF8(const char *utf8, size_t len)
{ return wxString(utf8, wxConvUTF8, len); }
const wxCharBuffer utf8_str() const { return mb_str(wxConvUTF8); }
{ return wxString(utf8, wxMBConvUTF8(), len); }
const wxCharBuffer utf8_str() const { return mb_str(wxMBConvUTF8()); }
const wxCharBuffer ToUTF8() const { return utf8_str(); }
#else // ANSI
static wxString FromUTF8(const char *utf8)
{ return wxString(wxConvUTF8.cMB2WC(utf8)); }
{ return wxString(wxMBConvUTF8().cMB2WC(utf8)); }
static wxString FromUTF8(const char *utf8, size_t len)
{
size_t wlen;
wxWCharBuffer buf(wxConvUTF8.cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen));
wxWCharBuffer buf(wxMBConvUTF8().cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen));
return wxString(buf.data(), wlen);
}
const wxCharBuffer utf8_str() const { return wxConvUTF8.cWC2MB(wc_str()); }
const wxCharBuffer utf8_str() const
{ return wxMBConvUTF8().cWC2MB(wc_str()); }
const wxCharBuffer ToUTF8() const { return utf8_str(); }
#endif

View File

@@ -2035,12 +2035,12 @@ public:
// http://msdn.microsoft.com/library/en-us/intl/unicode_17si.asp
if ( m_CodePage == CP_UTF8 )
{
return wxConvUTF8.MB2WC(buf, psz, n);
return wxMBConvUTF8().MB2WC(buf, psz, n);
}
if ( m_CodePage == CP_UTF7 )
{
return wxConvUTF7.MB2WC(buf, psz, n);
return wxMBConvUTF7().MB2WC(buf, psz, n);
}
int flags = 0;
@@ -3626,7 +3626,7 @@ wxWCharBuffer wxSafeConvertMB2WX(const char *s)
wxWCharBuffer wbuf(wxConvLibc.cMB2WX(s));
if ( !wbuf )
wbuf = wxConvUTF8.cMB2WX(s);
wbuf = wxMBConvUTF8().cMB2WX(s);
if ( !wbuf )
wbuf = wxConvISO8859_1.cMB2WX(s);

View File

@@ -340,7 +340,7 @@ wxString::SubstrBufFromMB wxString::ConvertStr(const char *psz, size_t nLength,
return SubstrBufFromMB("", 0);
// and then to UTF-8:
SubstrBufFromMB buf(ConvertStr(wcBuf, wcLen, wxConvUTF8));
SubstrBufFromMB buf(ConvertStr(wcBuf, wcLen, wxMBConvUTF8()));
// widechar -> UTF-8 conversion isn't supposed to ever fail:
wxASSERT_MSG( buf.data, _T("conversion to UTF-8 failed") );
@@ -382,7 +382,7 @@ const wxCharBuffer wxString::mb_str(const wxMBConv& conv) const
const wxWCharBuffer wxString::wc_str() const
{
return wxConvUTF8.cMB2WC(m_impl.c_str(),
return wxMBConvUTF8().cMB2WC(m_impl.c_str(),
m_impl.length() + 1 /* size, not length */,
NULL);
}
@@ -396,7 +396,7 @@ const wxCharBuffer wxString::mb_str(const wxMBConv& conv) const
size_t wcLen;
wxWCharBuffer wcBuf(
wxConvUTF8.cMB2WC(m_impl.c_str(),
wxMBConvUTF8().cMB2WC(m_impl.c_str(),
m_impl.length() + 1 /* size, not length */,
&wcLen));
if ( !wcLen )