git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46391
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
51 files changed:
\membersection{wxFilterClassFactory::CanHandle}\label{wxfilterclassfactorycanhandle}
\membersection{wxFilterClassFactory::CanHandle}\label{wxfilterclassfactorycanhandle}
-\constfunc{bool}{CanHandle}{\param{const wxChar* }{protocol}, \param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}}
+\constfunc{bool}{CanHandle}{\param{const wxString\& }{protocol}, \param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}}
Returns true if this factory can handle the given protocol, MIME type, HTTP
encoding or file extension.
Returns true if this factory can handle the given protocol, MIME type, HTTP
encoding or file extension.
\membersection{wxFilterClassFactory::Find}\label{wxfilterclassfactoryfind}
\membersection{wxFilterClassFactory::Find}\label{wxfilterclassfactoryfind}
-\func{static const wxFilterClassFactory*}{Find}{\param{const wxChar* }{protocol}, \param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}}
+\func{static const wxFilterClassFactory*}{Find}{\param{const wxString\& }{protocol}, \param{wxStreamProtocolType }{type = wxSTREAM\_PROTOCOL}}
A static member that finds a factory that can handle a given protocol, MIME
type, HTTP encoding or file extension. Returns a pointer to the class
A static member that finds a factory that can handle a given protocol, MIME
type, HTTP encoding or file extension. Returns a pointer to the class
\membersection{::wxFindFirstFile}\label{wxfindfirstfile}
\membersection{::wxFindFirstFile}\label{wxfindfirstfile}
-\func{wxString}{wxFindFirstFile}{\param{const char *}{spec}, \param{int}{ flags = 0}}
+\func{wxString}{wxFindFirstFile}{\param{const wxString\& }{spec}, \param{int}{ flags = 0}}
This function does directory searching; returns the first file
that matches the path {\it spec}, or the empty string. Use \helpref{wxFindNextFile}{wxfindnextfile} to
This function does directory searching; returns the first file
that matches the path {\it spec}, or the empty string. Use \helpref{wxFindNextFile}{wxfindnextfile} to
\membersection{::wxSplitPath}\label{wxsplitfunction}
\membersection{::wxSplitPath}\label{wxsplitfunction}
-\func{void}{wxSplitPath}{\param{const char *}{ fullname}, \param{wxString *}{ path}, \param{wxString *}{ name}, \param{wxString *}{ ext}}
+\func{void}{wxSplitPath}{\param{const wxString\&}{ fullname}, \param{wxString *}{ path}, \param{wxString *}{ name}, \param{wxString *}{ ext}}
{\bf NB:} This function is obsolete, please use
\helpref{wxFileName::SplitPath}{wxfilenamesplitpath} instead.
{\bf NB:} This function is obsolete, please use
\helpref{wxFileName::SplitPath}{wxfilenamesplitpath} instead.
wxMBConv& GetConv() const
{ if (m_pConv) return *m_pConv; else return wxConvLocal; }
wxMBConv& GetConv() const
{ if (m_pConv) return *m_pConv; else return wxConvLocal; }
- static const wxArchiveClassFactory *Find(const wxChar *protocol,
+ static const wxArchiveClassFactory *Find(const wxString& protocol,
wxStreamProtocolType type
= wxSTREAM_PROTOCOL);
wxStreamProtocolType type
= wxSTREAM_PROTOCOL);
wxArrayString(size_t sz, const wxChar** a);
wxArrayString(size_t sz, const wxString* a);
wxArrayString(size_t sz, const wxChar** a);
wxArrayString(size_t sz, const wxString* a);
- int Index(const wxChar* sz, bool bCase = true, bool bFromEnd = false) const;
+ int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const;
void Sort(bool reverseOrder = false);
void Sort(CompareFunction function);
void Sort(bool reverseOrder = false);
void Sort(CompareFunction function);
- int Index(const wxChar* sz, bool bCase = true, bool bFromEnd = false) const;
+ int Index(const wxString& str, bool bCase = true, bool bFromEnd = false) const;
};
#else // if !wxUSE_STL
};
#else // if !wxUSE_STL
// bFromEnd is false or from end otherwise. If bCase, comparison is case
// sensitive (default). Returns index of the first item matched or
// wxNOT_FOUND
// bFromEnd is false or from end otherwise. If bCase, comparison is case
// sensitive (default). Returns index of the first item matched or
// wxNOT_FOUND
- int Index (const wxChar *sz, bool bCase = true, bool bFromEnd = false) const;
+ int Index (const wxString& str, bool bCase = true, bool bFromEnd = false) const;
// add new element at the end (if the array is not sorted), return its
// index
size_t Add(const wxString& str, size_t nInsert = 1);
// add new element at the end (if the array is not sorted), return its
// index
size_t Add(const wxString& str, size_t nInsert = 1);
void Reset();
// break down the command line in arguments
void Reset();
// break down the command line in arguments
- static wxArrayString ConvertStringToArgs(const wxChar *cmdline);
+ static wxArrayString ConvertStringToArgs(const wxString& cmdline);
private:
// get usage string
private:
// get usage string
class WXDLLIMPEXP_BASE wxCmdLineParser
{
public:
class WXDLLIMPEXP_BASE wxCmdLineParser
{
public:
- static wxArrayString ConvertStringToArgs(const wxChar *cmdline);
+ static wxArrayString ConvertStringToArgs(const wxString& cmdline);
};
#endif // wxUSE_CMDLINE_PARSER/!wxUSE_CMDLINE_PARSER
};
#endif // wxUSE_CMDLINE_PARSER/!wxUSE_CMDLINE_PARSER
/*
Split path into parts removing '..' in progress
*/
/*
Split path into parts removing '..' in progress
*/
-WXDLLIMPEXP_BASE void wxSplitPath(wxArrayString& aParts, const wxChar *sz);
+WXDLLIMPEXP_BASE void wxSplitPath(wxArrayString& aParts, const wxString& path);
#endif // _WX_CONFBASE_H_
#endif // _WX_CONFBASE_H_
// Calls that CLIENT can make
virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT ) = 0;
// Calls that CLIENT can make
virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT ) = 0;
- virtual bool Execute(const wxString& str) { return Execute(str, -1, wxIPC_TEXT); }
+ // FIXME-UTF8: review this code for compatibility implications, update
+ // accordingly, don' use c_str() below
+ virtual bool Execute(const wxString& str)
+ { return Execute(str.c_str(), -1, wxIPC_TEXT); }
virtual wxChar *Request(const wxString& item, int *size = (int *) NULL, wxIPCFormat format = wxIPC_TEXT) = 0;
virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0;
virtual bool StartAdvise(const wxString& item) = 0;
virtual wxChar *Request(const wxString& item, int *size = (int *) NULL, wxIPCFormat format = wxIPC_TEXT) = 0;
virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT) = 0;
virtual bool StartAdvise(const wxString& item) = 0;
void Compress(bool on);
// unhide the Execute overload from wxConnectionBase
void Compress(bool on);
// unhide the Execute overload from wxConnectionBase
+ // FIXME-UTF8: change Execute() to DoExecute() to avoid having to do this;
+ // don't use c_str() below after removing ANSI build
virtual bool Execute(const wxString& str)
virtual bool Execute(const wxString& str)
- { return Execute(str, -1, wxIPC_TEXT); }
+ { return Execute(str.c_str(), -1, wxIPC_TEXT); }
protected:
wxSocketBase *m_sock;
protected:
wxSocketBase *m_sock;
// ctor associates the stream with the given string which makes a copy of
// it
wxStringInputStream(const wxString& s);
// ctor associates the stream with the given string which makes a copy of
// it
wxStringInputStream(const wxString& s);
- virtual ~wxStringInputStream();
virtual wxFileOffset GetLength() const;
virtual wxFileOffset GetLength() const;
wxString m_str;
// the buffer we're reading from
wxString m_str;
// the buffer we're reading from
// length of the buffer we're reading from
size_t m_len;
// length of the buffer we're reading from
size_t m_len;
+class WXDLLIMPEXP_BASE wxString;
+
// the error value returned by wxMBConv methods
#define wxCONV_FAILED ((size_t)-1)
// the error value returned by wxMBConv methods
#define wxCONV_FAILED ((size_t)-1)
class WXDLLIMPEXP_BASE wxConvBrokenFileNames : public wxMBConv
{
public:
class WXDLLIMPEXP_BASE wxConvBrokenFileNames : public wxMBConv
{
public:
- wxConvBrokenFileNames(const wxChar *charset);
+ wxConvBrokenFileNames(const wxString& charset);
wxConvBrokenFileNames(const wxConvBrokenFileNames& conv)
: wxMBConv(),
m_conv(conv.m_conv ? conv.m_conv->Clone() : NULL)
wxConvBrokenFileNames(const wxConvBrokenFileNames& conv)
: wxMBConv(),
m_conv(conv.m_conv ? conv.m_conv->Clone() : NULL)
public:
// we can be created either from charset name or from an encoding constant
// but we can't have both at once
public:
// we can be created either from charset name or from an encoding constant
// but we can't have both at once
- wxCSConv(const wxChar *charset);
+ wxCSConv(const wxString& charset);
wxCSConv(wxFontEncoding encoding);
wxCSConv(const wxCSConv& conv);
wxCSConv(wxFontEncoding encoding);
wxCSConv(const wxCSConv& conv);
// set the name (may be only called when m_name == NULL), makes copy of
// charset string
// set the name (may be only called when m_name == NULL), makes copy of
// charset string
- void SetName(const wxChar *charset);
+ void SetName(const char *charset);
// note that we can't use wxString here because of compilation
// dependencies: we're included from wx/string.h
// note that we can't use wxString here because of compilation
// dependencies: we're included from wx/string.h
wxFontEncoding m_encoding;
// use CreateConvIfNeeded() before accessing m_convReal!
wxFontEncoding m_encoding;
// use CreateConvIfNeeded() before accessing m_convReal!
virtual const wxChar * const *GetProtocols(wxStreamProtocolType type
= wxSTREAM_PROTOCOL) const = 0;
virtual const wxChar * const *GetProtocols(wxStreamProtocolType type
= wxSTREAM_PROTOCOL) const = 0;
- bool CanHandle(const wxChar *protocol,
+ bool CanHandle(const wxString& protocol,
wxStreamProtocolType type
= wxSTREAM_PROTOCOL) const;
protected:
wxStreamProtocolType type
= wxSTREAM_PROTOCOL) const;
protected:
- wxString::size_type FindExtension(const wxChar *location) const;
+ wxString::size_type FindExtension(const wxString& location) const;
DECLARE_ABSTRACT_CLASS(wxFilterClassFactoryBase)
};
DECLARE_ABSTRACT_CLASS(wxFilterClassFactoryBase)
};
virtual wxFilterInputStream *NewStream(wxInputStream *stream) const = 0;
virtual wxFilterOutputStream *NewStream(wxOutputStream *stream) const = 0;
virtual wxFilterInputStream *NewStream(wxInputStream *stream) const = 0;
virtual wxFilterOutputStream *NewStream(wxOutputStream *stream) const = 0;
- static const wxFilterClassFactory *Find(const wxChar *protocol,
+ static const wxFilterClassFactory *Find(const wxString& protocol,
wxStreamProtocolType type
= wxSTREAM_PROTOCOL);
wxStreamProtocolType type
= wxSTREAM_PROTOCOL);
// the archive classes they use.
const wxArchiveClassFactory *
// the archive classes they use.
const wxArchiveClassFactory *
-wxArchiveClassFactory::Find(const wxChar *protocol, wxStreamProtocolType type)
+wxArchiveClassFactory::Find(const wxString& protocol, wxStreamProtocolType type)
{
for (const wxArchiveClassFactory *f = GetFirst(); f; f = f->GetNext())
if (f->CanHandle(protocol, type))
{
for (const wxArchiveClassFactory *f = GetFirst(); f; f = f->GetNext())
if (f->CanHandle(protocol, type))
}
// searches the array for an item (forward or backwards)
}
// searches the array for an item (forward or backwards)
-int wxArrayString::Index(const wxChar *sz, bool bCase, bool bFromEnd) const
+int wxArrayString::Index(const wxString& str, bool bCase, bool bFromEnd) const
{
if ( m_autoSort ) {
// use binary search in the sorted array
{
if ( m_autoSort ) {
// use binary search in the sorted array
while ( lo < hi ) {
i = (lo + hi)/2;
while ( lo < hi ) {
i = (lo + hi)/2;
- res = wxStrcmp(sz, m_pItems[i]);
+ res = str.compare(m_pItems[i]);
if ( res < 0 )
hi = i;
else if ( res > 0 )
if ( res < 0 )
hi = i;
else if ( res > 0 )
if ( m_nCount > 0 ) {
size_t ui = m_nCount;
do {
if ( m_nCount > 0 ) {
size_t ui = m_nCount;
do {
- if ( m_pItems[--ui].IsSameAs(sz, bCase) )
+ if ( m_pItems[--ui].IsSameAs(str, bCase) )
return ui;
}
while ( ui != 0 );
return ui;
}
while ( ui != 0 );
}
else {
for( size_t ui = 0; ui < m_nCount; ui++ ) {
}
else {
for( size_t ui = 0; ui < m_nCount; ui++ ) {
- if( m_pItems[ui].IsSameAs(sz, bCase) )
+ if( m_pItems[ui].IsSameAs(str, bCase) )
static wxString GetTypeName(wxCmdLineParamType type);
static wxString GetTypeName(wxCmdLineParamType type);
-static wxString GetOptionName(const wxChar *p, const wxChar *allowedChars);
+static wxString GetOptionName(wxString::const_iterator p,
+ wxString::const_iterator end,
+ const wxChar *allowedChars);
-static wxString GetShortOptionName(const wxChar *p);
+static wxString GetShortOptionName(wxString::const_iterator p,
+ wxString::const_iterator end);
-static wxString GetLongOptionName(const wxChar *p);
+static wxString GetLongOptionName(wxString::const_iterator p,
+ wxString::const_iterator end);
// ----------------------------------------------------------------------------
// private structs
// ----------------------------------------------------------------------------
// private structs
_T("option should have at least one name") );
wxASSERT_MSG
_T("option should have at least one name") );
wxASSERT_MSG
- (
- GetShortOptionName(shrt).Len() == shrt.Len(),
- wxT("Short option contains invalid characters")
- );
+ (
+ GetShortOptionName(shrt.begin(), shrt.end()).Len() == shrt.Len(),
+ wxT("Short option contains invalid characters")
+ );
- (
- GetLongOptionName(lng).Len() == lng.Len(),
- wxT("Long option contains invalid characters")
- );
+ (
+ GetLongOptionName(lng.begin(), lng.end()).Len() == lng.Len(),
+ wxT("Long option contains invalid characters")
+ );
// empty argument or just '-' is not an option but a parameter
if ( maybeOption && arg.length() > 1 &&
// empty argument or just '-' is not an option but a parameter
if ( maybeOption && arg.length() > 1 &&
- wxStrchr(m_data->m_switchChars, arg[0u]) )
+ // FIXME-UTF8: use wc_str() after removing ANSI build
+ wxStrchr(m_data->m_switchChars.c_str(), arg[0u]) )
{
bool isLong;
wxString name;
int optInd = wxNOT_FOUND; // init to suppress warnings
// an option or a switch: find whether it's a long or a short one
{
bool isLong;
wxString name;
int optInd = wxNOT_FOUND; // init to suppress warnings
// an option or a switch: find whether it's a long or a short one
- if ( arg[0u] == _T('-') && arg[1u] == _T('-') )
+ if ( arg.length() >= 3 && arg[0u] == _T('-') && arg[1u] == _T('-') )
{
// a long one
isLong = true;
// Skip leading "--"
{
// a long one
isLong = true;
// Skip leading "--"
- const wxChar *p = arg.c_str() + 2;
+ wxString::const_iterator p = arg.begin() + 2;
bool longOptionsEnabled = AreLongOptionsEnabled();
bool longOptionsEnabled = AreLongOptionsEnabled();
- name = GetLongOptionName(p);
+ name = GetLongOptionName(p, arg.end());
if (longOptionsEnabled)
{
if (longOptionsEnabled)
{
// a short one: as they can be cumulated, we try to find the
// longest substring which is a valid option
// a short one: as they can be cumulated, we try to find the
// longest substring which is a valid option
- const wxChar *p = arg.c_str() + 1;
+ wxString::const_iterator p = arg.begin() + 1;
- name = GetShortOptionName(p);
+ name = GetShortOptionName(p, arg.end());
size_t len = name.length();
do
size_t len = name.length();
do
// look at what follows:
// +1 for leading '-'
// look at what follows:
// +1 for leading '-'
- const wxChar *p = arg.c_str() + 1 + name.length();
+ wxString::const_iterator p = arg.begin() + 1 + name.length();
+ wxString::const_iterator end = arg.end();
+
- p++; // for another leading '-'
+ ++p; // for another leading '-'
wxCmdLineOption& opt = m_data->m_options[(size_t)optInd];
if ( opt.kind == wxCMD_LINE_SWITCH )
{
// we must check that there is no value following the switch
wxCmdLineOption& opt = m_data->m_options[(size_t)optInd];
if ( opt.kind == wxCMD_LINE_SWITCH )
{
// we must check that there is no value following the switch
{
errorMsg << wxString::Format(_("Unexpected characters following option '%s'."), name.c_str())
<< _T('\n');
{
errorMsg << wxString::Format(_("Unexpected characters following option '%s'."), name.c_str())
<< _T('\n');
+ switch ( (*p).GetValue() )
{
case _T('='):
case _T(':'):
// the value follows
{
case _T('='):
case _T(':'):
// the value follows
else
{
// ... take it from there
else
{
// ... take it from there
- p = m_data->m_arguments[n].c_str();
+ p = m_data->m_arguments[n].begin();
+ end = m_data->m_arguments[n].end();
+ wxString value(p, end);
switch ( opt.type )
{
default:
switch ( opt.type )
{
default:
case wxCMD_LINE_VAL_DATE:
{
wxDateTime dt;
case wxCMD_LINE_VAL_DATE:
{
wxDateTime dt;
- const wxChar *res = dt.ParseDate(value);
+ // FIXME-UTF8: ParseDate API will need changes
+ const wxChar *res = dt.ParseDate(value.c_str());
if ( !res || *res )
{
errorMsg << wxString::Format(_("Option '%s': '%s' cannot be converted to a date."),
if ( !res || *res )
{
errorMsg << wxString::Format(_("Option '%s': '%s' cannot be converted to a date."),
For example, if p points to "abcde-@-_", and allowedChars is "-_",
this function returns "abcde-".
*/
For example, if p points to "abcde-@-_", and allowedChars is "-_",
this function returns "abcde-".
*/
-static wxString GetOptionName(const wxChar *p,
- const wxChar *allowedChars)
+static wxString GetOptionName(wxString::const_iterator p,
+ wxString::const_iterator end,
+ const wxChar *allowedChars)
- while ( *p && (wxIsalnum(*p) || wxStrchr(allowedChars, *p)) )
+ while ( p != end && (wxIsalnum(*p) || wxStrchr(allowedChars, *p)) )
#define wxCMD_LINE_CHARS_ALLOWED_BY_LONG_OPTION \
wxCMD_LINE_CHARS_ALLOWED_BY_SHORT_OPTION wxT("-")
#define wxCMD_LINE_CHARS_ALLOWED_BY_LONG_OPTION \
wxCMD_LINE_CHARS_ALLOWED_BY_SHORT_OPTION wxT("-")
-static wxString GetShortOptionName(const wxChar *p)
+static wxString GetShortOptionName(wxString::const_iterator p,
+ wxString::const_iterator end)
- return GetOptionName(p, wxCMD_LINE_CHARS_ALLOWED_BY_SHORT_OPTION);
+ return GetOptionName(p, end, wxCMD_LINE_CHARS_ALLOWED_BY_SHORT_OPTION);
-static wxString GetLongOptionName(const wxChar *p)
+static wxString GetLongOptionName(wxString::const_iterator p,
+ wxString::const_iterator end)
- return GetOptionName(p, wxCMD_LINE_CHARS_ALLOWED_BY_LONG_OPTION);
+ return GetOptionName(p, end, wxCMD_LINE_CHARS_ALLOWED_BY_LONG_OPTION);
}
#endif // wxUSE_CMDLINE_PARSER
}
#endif // wxUSE_CMDLINE_PARSER
-wxArrayString wxCmdLineParser::ConvertStringToArgs(const wxChar *p)
+wxArrayString wxCmdLineParser::ConvertStringToArgs(const wxString& cmdline)
arg.reserve(1024);
bool isInsideQuotes = false;
arg.reserve(1024);
bool isInsideQuotes = false;
+
+ wxString::const_iterator p = cmdline.begin();
+
for ( ;; )
{
// skip white space
for ( ;; )
{
// skip white space
- while ( *p == _T(' ') || *p == _T('\t') )
- p++;
+ while ( p != cmdline.end() && (*p == _T(' ') || *p == _T('\t')) )
+ ++p;
+ if ( p == cmdline.end() )
break;
// parse this parameter
break;
// parse this parameter
bool lastBS = false;
for ( arg.clear(); !endParam; p++ )
{
bool lastBS = false;
for ( arg.clear(); !endParam; p++ )
{
+ switch ( (*p).GetValue() )
{
case _T('"'):
if ( !lastBS )
{
case _T('"'):
if ( !lastBS )
/* JACS: work around a memory bug that causes an assert
when using wxRegConfig, related to reference-counting.
/* JACS: work around a memory bug that causes an assert
when using wxRegConfig, related to reference-counting.
- Can be reproduced by removing (const wxChar*) below and
+ Can be reproduced by removing .wc_str() below and
adding the following code to the config sample OnInit under
Windows:
adding the following code to the config sample OnInit under
Windows:
int value;
pConfig->Read(_T("MainWindowX"), & value);
*/
int value;
pConfig->Read(_T("MainWindowX"), & value);
*/
- m_strOldPath = (const wxChar*) m_pContainer->GetPath();
+ m_strOldPath = m_pContainer->GetPath().wc_str();
if ( *m_strOldPath.c_str() != wxCONFIG_PATH_SEPARATOR )
m_strOldPath += wxCONFIG_PATH_SEPARATOR;
m_pContainer->SetPath(strPath);
if ( *m_strOldPath.c_str() != wxCONFIG_PATH_SEPARATOR )
m_strOldPath += wxCONFIG_PATH_SEPARATOR;
m_pContainer->SetPath(strPath);
wxString strVarName(str.c_str() + n + 1, m - n - 1);
#ifdef __WXWINCE__
wxString strVarName(str.c_str() + n + 1, m - n - 1);
#ifdef __WXWINCE__
- const wxChar *pszValue = NULL;
+ const bool expanded = false;
#else
// NB: use wxGetEnv instead of wxGetenv as otherwise variables
// set through wxSetEnv may not be read correctly!
#else
// NB: use wxGetEnv instead of wxGetenv as otherwise variables
// set through wxSetEnv may not be read correctly!
- const wxChar *pszValue = NULL;
wxString tmp;
if (wxGetEnv(strVarName, &tmp))
wxString tmp;
if (wxGetEnv(strVarName, &tmp))
- pszValue = tmp;
-#endif
- if ( pszValue != NULL ) {
- strResult += pszValue;
+ {
+ strResult += tmp;
+ expanded = true;
// variable doesn't exist => don't change anything
#ifdef __WXMSW__
if ( bracket != Bracket_Windows )
// variable doesn't exist => don't change anything
#ifdef __WXMSW__
if ( bracket != Bracket_Windows )
}
else {
// skip closing bracket unless the variables wasn't expanded
}
else {
// skip closing bracket unless the variables wasn't expanded
- if ( pszValue == NULL )
strResult << (wxChar)bracket;
m++;
}
strResult << (wxChar)bracket;
m++;
}
}
// this function is used to properly interpret '..' in path
}
// this function is used to properly interpret '..' in path
-void wxSplitPath(wxArrayString& aParts, const wxChar *sz)
+void wxSplitPath(wxArrayString& aParts, const wxString& path)
{
aParts.clear();
wxString strCurrent;
{
aParts.clear();
wxString strCurrent;
+ wxString::const_iterator pc = path.begin();
- if ( *pc == wxT('\0') || *pc == wxCONFIG_PATH_SEPARATOR ) {
+ if ( pc == path.end() || *pc == wxCONFIG_PATH_SEPARATOR ) {
if ( strCurrent == wxT(".") ) {
// ignore
}
else if ( strCurrent == wxT("..") ) {
// go up one level
if ( aParts.size() == 0 )
if ( strCurrent == wxT(".") ) {
// ignore
}
else if ( strCurrent == wxT("..") ) {
// go up one level
if ( aParts.size() == 0 )
- wxLogWarning(_("'%s' has extra '..', ignored."), sz);
+ wxLogWarning(_("'%s' has extra '..', ignored."), path);
else
aParts.erase(aParts.end() - 1);
else
aParts.erase(aParts.end() - 1);
//else:
// could log an error here, but we prefer to ignore extra '/'
//else:
// could log an error here, but we prefer to ignore extra '/'
- if ( *pc == wxT('\0') )
+ if ( pc == path.end() )
break;
}
else
strCurrent += *pc;
break;
}
else
strCurrent += *pc;
heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
wxString curLine;
heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
wxString curLine;
- for ( const wxChar *pc = text; ; pc++ )
+ for ( wxString::const_iterator pc = text.begin(); ; ++pc )
- if ( *pc == _T('\n') || *pc == _T('\0') )
+ if ( pc == text.end() || *pc == _T('\n') )
{
if ( curLine.empty() )
{
{
if ( curLine.empty() )
{
heightTextTotal += heightLine;
}
heightTextTotal += heightLine;
}
+ if ( pc == text.end() )
- // the end of string
- break;
// local functions
// ----------------------------------------------------------------------------
// local functions
// ----------------------------------------------------------------------------
-static wxString FindExtension(const wxChar *path)
+static wxString FindExtension(const wxString& path)
{
wxString ext;
wxSplitPath(path, NULL, NULL, &ext);
{
wxString ext;
wxSplitPath(path, NULL, NULL, &ext);
msgTitle = wxString(_("Warning"));
wxString prompt;
msgTitle = wxString(_("Warning"));
wxString prompt;
- prompt.Printf(_("Do you want to save changes to document %s?"),
- (const wxChar *)title);
+ prompt.Printf(_("Do you want to save changes to document %s?"), title);
int res = wxMessageBox(prompt, msgTitle,
wxYES_NO|wxCANCEL|wxICON_QUESTION,
GetDocumentWindow());
int res = wxMessageBox(prompt, msgTitle,
wxYES_NO|wxCANCEL|wxICON_QUESTION,
GetDocumentWindow());
// extern "C" functions and the functions with C++ linkage and ptr_fun and
// wxStringCompareLess can't take wxStrcmp/wxStricmp directly as arguments in
// this case, we need the wrappers below to make this work
// extern "C" functions and the functions with C++ linkage and ptr_fun and
// wxStringCompareLess can't take wxStrcmp/wxStricmp directly as arguments in
// this case, we need the wrappers below to make this work
-inline int wxStrcmpCppWrapper(const wxChar *p, const wxChar *q)
- return wxStrcmp(p, q);
-}
+ typedef wxString first_argument_type;
+ typedef wxString second_argument_type;
+ typedef int result_type;
+
+ int operator()(const wxString& s1, const wxString& s2) const
+ {
+ return s1.compare(s2);
+ }
+};
-inline int wxStricmpCppWrapper(const wxChar *p, const wxChar *q)
+struct wxStringCmpNoCase
- return wxStricmp(p, q);
-}
+ typedef wxString first_argument_type;
+ typedef wxString second_argument_type;
+ typedef int result_type;
-int wxArrayString::Index(const wxChar* sz, bool bCase, bool WXUNUSED(bFromEnd)) const
+ int operator()(const wxString& s1, const wxString& s2) const
+ {
+ return s1.CmpNoCase(s2);
+ }
+};
+
+int wxArrayString::Index(const wxString& str, bool bCase, bool WXUNUSED(bFromEnd)) const
{
wxArrayString::const_iterator it;
{
wxArrayString::const_iterator it;
it = std::find_if(begin(), end(),
std::not1(
std::bind2nd(
it = std::find_if(begin(), end(),
std::not1(
std::bind2nd(
- std::ptr_fun(wxStrcmpCppWrapper), sz)));
}
else // !bCase
{
it = std::find_if(begin(), end(),
std::not1(
std::bind2nd(
}
else // !bCase
{
it = std::find_if(begin(), end(),
std::not1(
std::bind2nd(
- std::ptr_fun(wxStricmpCppWrapper), sz)));
+ wxStringCmpNoCase(), str)));
}
return it == end() ? wxNOT_FOUND : it - begin();
}
return it == end() ? wxNOT_FOUND : it - begin();
{
public:
wxStringCompareLess(F f) : m_f(f) { }
{
public:
wxStringCompareLess(F f) : m_f(f) { }
- bool operator()(const wxChar* s1, const wxChar* s2)
- { return m_f(s1, s2) < 0; }
bool operator()(const wxString& s1, const wxString& s2)
{ return m_f(s1, s2) < 0; }
private:
bool operator()(const wxString& s1, const wxString& s2)
{ return m_f(s1, s2) < 0; }
private:
-int wxSortedArrayString::Index(const wxChar* sz, bool bCase, bool WXUNUSED(bFromEnd)) const
+int wxSortedArrayString::Index(const wxString& str, bool bCase, bool WXUNUSED(bFromEnd)) const
{
wxSortedArrayString::const_iterator it;
{
wxSortedArrayString::const_iterator it;
- it = std::lower_bound(begin(), end(), s,
- wxStringCompare(wxStrcmpCppWrapper));
+ it = std::lower_bound(begin(), end(), str,
+ wxStringCompare(wxStringCmp()));
- it = std::lower_bound(begin(), end(), s,
- wxStringCompare(wxStricmpCppWrapper));
+ it = std::lower_bound(begin(), end(), str,
+ wxStringCompare(wxStringCmpNoCase()));
if (it == end())
return wxNOT_FOUND;
if (bCase)
{
if (it == end())
return wxNOT_FOUND;
if (bCase)
{
- if (wxStrcmp(it->c_str(), sz) != 0)
return wxNOT_FOUND;
}
else
{
return wxNOT_FOUND;
}
else
{
- if (wxStricmp(it->c_str(), sz) != 0)
+ if (str.CmpNoCase(*it) != 0)
return wxNOT_FOUND;
}
return it - begin();
}
return wxNOT_FOUND;
}
return it - begin();
}
bool IsEmpty() const { return Entries().IsEmpty() && Groups().IsEmpty(); }
// find entry/subgroup (NULL if not found)
bool IsEmpty() const { return Entries().IsEmpty() && Groups().IsEmpty(); }
// find entry/subgroup (NULL if not found)
- wxFileConfigGroup *FindSubgroup(const wxChar *szName) const;
- wxFileConfigEntry *FindEntry (const wxChar *szName) const;
+ wxFileConfigGroup *FindSubgroup(const wxString& name) const;
+ wxFileConfigEntry *FindEntry (const wxString& name) const;
// delete entry/subgroup, return false if doesn't exist
// delete entry/subgroup, return false if doesn't exist
- bool DeleteSubgroupByName(const wxChar *szName);
- bool DeleteEntry(const wxChar *szName);
+ bool DeleteSubgroupByName(const wxString& name);
+ bool DeleteEntry(const wxString& name);
// create new entry/subgroup returning pointer to newly created element
wxFileConfigGroup *AddSubgroup(const wxString& strName);
// create new entry/subgroup returning pointer to newly created element
wxFileConfigGroup *AddSubgroup(const wxString& strName);
void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
{
void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
{
- const wxChar *pStart;
- const wxChar *pEnd;
- wxString strLine;
size_t nLineCount = buffer.GetLineCount();
for ( size_t n = 0; n < nLineCount; n++ )
{
size_t nLineCount = buffer.GetLineCount();
for ( size_t n = 0; n < nLineCount; n++ )
{
+ wxString strLine = buffer[n];
+ // FIXME-UTF8: rewrite using iterators, without this buffer
+ wxWxCharBuffer buf(strLine.c_str());
+ const wxChar *pStart;
+ const wxChar *pEnd;
// add the line to linked list
if ( bLocal )
// add the line to linked list
if ( bLocal )
- for ( pStart = strLine; wxIsspace(*pStart); pStart++ )
+ for ( pStart = buf; wxIsspace(*pStart); pStart++ )
;
// skip blank/comment lines
;
// skip blank/comment lines
bool wxFileConfig::RenameEntry(const wxString& oldName,
const wxString& newName)
{
bool wxFileConfig::RenameEntry(const wxString& oldName,
const wxString& newName)
{
- wxASSERT_MSG( !wxStrchr(oldName, wxCONFIG_PATH_SEPARATOR),
+ wxASSERT_MSG( oldName.find(wxCONFIG_PATH_SEPARATOR) == wxString::npos,
_T("RenameEntry(): paths are not supported") );
// check that the entry exists
_T("RenameEntry(): paths are not supported") );
// check that the entry exists
if ( m_fnLocalFile.IsOk() )
{
if ( m_fnLocalFile.IsOk() )
{
- if ( m_fnLocalFile.FileExists() && wxRemove(m_fnLocalFile.GetFullPath()) == -1 )
+ if ( m_fnLocalFile.FileExists() &&
+ !wxRemoveFile(m_fnLocalFile.GetFullPath()) )
{
wxLogSysError(_("can't delete user configuration file '%s'"),
m_fnLocalFile.GetFullPath().c_str());
{
wxLogSysError(_("can't delete user configuration file '%s'"),
m_fnLocalFile.GetFullPath().c_str());
// use binary search because the array is sorted
wxFileConfigEntry *
// use binary search because the array is sorted
wxFileConfigEntry *
-wxFileConfigGroup::FindEntry(const wxChar *szName) const
+wxFileConfigGroup::FindEntry(const wxString& name) const
pEntry = m_aEntries[i];
#if wxCONFIG_CASE_SENSITIVE
pEntry = m_aEntries[i];
#if wxCONFIG_CASE_SENSITIVE
- res = wxStrcmp(pEntry->Name(), szName);
+ res = pEntry->Name().compare(name);
- res = wxStricmp(pEntry->Name(), szName);
+ res = pEntry->Name().CmpNoCase(name);
-wxFileConfigGroup::FindSubgroup(const wxChar *szName) const
+wxFileConfigGroup::FindSubgroup(const wxString& name) const
pGroup = m_aSubgroups[i];
#if wxCONFIG_CASE_SENSITIVE
pGroup = m_aSubgroups[i];
#if wxCONFIG_CASE_SENSITIVE
- res = wxStrcmp(pGroup->Name(), szName);
+ res = pGroup->Name().compare(name);
- res = wxStricmp(pGroup->Name(), szName);
+ res = pGroup->Name().CmpNoCase(name);
delete several of them.
*/
delete several of them.
*/
-bool wxFileConfigGroup::DeleteSubgroupByName(const wxChar *szName)
+bool wxFileConfigGroup::DeleteSubgroupByName(const wxString& name)
- wxFileConfigGroup * const pGroup = FindSubgroup(szName);
+ wxFileConfigGroup * const pGroup = FindSubgroup(name);
return pGroup ? DeleteSubgroup(pGroup) : false;
}
return pGroup ? DeleteSubgroup(pGroup) : false;
}
-bool wxFileConfigGroup::DeleteEntry(const wxChar *szName)
+bool wxFileConfigGroup::DeleteEntry(const wxString& name)
- wxFileConfigEntry *pEntry = FindEntry(szName);
+ wxFileConfigEntry *pEntry = FindEntry(name);
if ( !pEntry )
{
// entry doesn't exist, nothing to do
if ( !pEntry )
{
// entry doesn't exist, nothing to do
int CompareEntries(wxFileConfigEntry *p1, wxFileConfigEntry *p2)
{
#if wxCONFIG_CASE_SENSITIVE
int CompareEntries(wxFileConfigEntry *p1, wxFileConfigEntry *p2)
{
#if wxCONFIG_CASE_SENSITIVE
- return wxStrcmp(p1->Name(), p2->Name());
+ return p1->Name().compare(p2->Name());
- return wxStricmp(p1->Name(), p2->Name());
+ return p1->Name().CmpNoCase(p2->Name());
#endif
}
int CompareGroups(wxFileConfigGroup *p1, wxFileConfigGroup *p2)
{
#if wxCONFIG_CASE_SENSITIVE
#endif
}
int CompareGroups(wxFileConfigGroup *p1, wxFileConfigGroup *p2)
{
#if wxCONFIG_CASE_SENSITIVE
- return wxStrcmp(p1->Name(), p2->Name());
+ return p1->Name().compare(p2->Name());
- return wxStricmp(p1->Name(), p2->Name());
+ return p1->Name().CmpNoCase(p2->Name());
path += _T("XXXXXX");
// we need to copy the path to the buffer in which mkstemp() can modify it
path += _T("XXXXXX");
// we need to copy the path to the buffer in which mkstemp() can modify it
- wxCharBuffer buf( wxConvFile.cWX2MB( path ) );
+ wxCharBuffer buf(path.fn_str());
// cast is safe because the string length doesn't change
int fdTemp = mkstemp( (char*)(const char*) buf );
// cast is safe because the string length doesn't change
int fdTemp = mkstemp( (char*)(const char*) buf );
// the filter classes they use.
const wxFilterClassFactory *
// the filter classes they use.
const wxFilterClassFactory *
-wxFilterClassFactory::Find(const wxChar *protocol, wxStreamProtocolType type)
+wxFilterClassFactory::Find(const wxString& protocol, wxStreamProtocolType type)
{
for (const wxFilterClassFactory *f = GetFirst(); f; f = f->GetNext())
if (f->CanHandle(protocol, type))
{
for (const wxFilterClassFactory *f = GetFirst(); f; f = f->GetNext())
if (f->CanHandle(protocol, type))
}
else // subsequent line of multiline reply
{
}
else // subsequent line of multiline reply
{
- if ( wxStrncmp(line, code, LEN_CODE) == 0 )
+ if ( line.compare(0, LEN_CODE, code) == 0 )
{
if ( chMarker == _T(' ') )
{
{
if ( chMarker == _T(' ') )
{
if ( !DoSimpleCommand(_T("TYPE"), mode) )
{
if ( !DoSimpleCommand(_T("TYPE"), mode) )
{
- wxLogError(_("Failed to set FTP transfer mode to %s."), (const wxChar*)
+ wxLogError(_("Failed to set FTP transfer mode to %s."),
(transferMode == ASCII ? _("ASCII") : _("binary")));
return false;
(transferMode == ASCII ? _("ASCII") : _("binary")));
return false;
- const wxChar *addrStart = wxStrchr(m_lastResult, _T('('));
- const wxChar *addrEnd = addrStart ? wxStrchr(addrStart, _T(')')) : NULL;
- if ( !addrEnd )
+ size_t addrStart = m_lastResult.find(_T('('));
+ size_t addrEnd = (addrStart == wxString::npos)
+ ? wxString::npos
+ : m_lastResult.find(_T(')'), addrStart);
+
+ if ( addrEnd == wxString::npos )
{
m_lastError = wxPROTO_PROTERR;
{
m_lastError = wxPROTO_PROTERR;
return NULL;
}
// get the port number and address
int a[6];
return NULL;
}
// get the port number and address
int a[6];
- wxString straddr(addrStart + 1, addrEnd);
+ wxString straddr(m_lastResult, addrStart + 1, addrEnd - (addrStart + 1));
wxSscanf(straddr, wxT("%d,%d,%d,%d,%d,%d"),
&a[2],&a[3],&a[4],&a[5],&a[0],&a[1]);
wxSscanf(straddr, wxT("%d,%d,%d,%d,%d,%d"),
&a[2],&a[3],&a[4],&a[5],&a[0],&a[1]);
wxHeaderIterator it = m_headers.begin();
for ( wxHeaderIterator en = m_headers.end(); it != en; ++it )
{
wxHeaderIterator it = m_headers.begin();
for ( wxHeaderIterator en = m_headers.end(); it != en; ++it )
{
- if ( wxStricmp(it->first, header) == 0 )
+ if ( header.CmpNoCase(it->first) == 0 )
wxHeaderConstIterator it = m_headers.begin();
for ( wxHeaderConstIterator en = m_headers.end(); it != en; ++it )
{
wxHeaderConstIterator it = m_headers.begin();
for ( wxHeaderConstIterator en = m_headers.end(); it != en; ++it )
{
- if ( wxStricmp(it->first, header) == 0 )
+ if ( header.CmpNoCase(it->first) == 0 )
wxString buf;
buf.Printf(wxT("%s %s HTTP/1.0\r\n"), request, path.c_str());
wxString buf;
buf.Printf(wxT("%s %s HTTP/1.0\r\n"), request, path.c_str());
- const wxWX2MBbuf pathbuf = wxConvLocal.cWX2MB(buf);
- Write(pathbuf, strlen(wxMBSTRINGCAST pathbuf));
+ const wxWX2MBbuf pathbuf = buf.mb_str();
+ Write(pathbuf, strlen(pathbuf));
SendHeaders();
Write("\r\n", 2);
SendHeaders();
Write("\r\n", 2);
inp_stream = new wxHTTPStream(this);
if (!GetHeader(wxT("Content-Length")).empty())
inp_stream = new wxHTTPStream(this);
if (!GetHeader(wxT("Content-Length")).empty())
- inp_stream->m_httpsize = wxAtoi(WXSTRINGCAST GetHeader(wxT("Content-Length")));
+ inp_stream->m_httpsize = wxAtoi(GetHeader(wxT("Content-Length")));
else
inp_stream->m_httpsize = (size_t)-1;
else
inp_stream->m_httpsize = (size_t)-1;
if (stream.IsSeekable() && !handler->CanRead(stream))
{
if (stream.IsSeekable() && !handler->CanRead(stream))
{
- wxLogError(_("Image file is not of type %s."), (const wxChar*) mimetype);
+ wxLogError(_("Image file is not of type %s."), mimetype);
// TODO: Do we want to include the null char in the stream? If so then
// just add +1 to m_len in the ctor
// TODO: Do we want to include the null char in the stream? If so then
// just add +1 to m_len in the ctor
-wxStringInputStream::wxStringInputStream(const wxString& s)
+wxStringInputStream::wxStringInputStream(const wxString& s)
- : m_str(s), m_buf(wxMBConvUTF8().cWX2MB(s).release()), m_len(strlen(m_buf))
+ // FIXME-UTF8: use wxCharBufferWithLength if we have it
+ : m_str(s), m_buf(s.utf8_str()), m_len(strlen(m_buf))
- : m_str(s), m_buf((char*)(const char*)s.c_str()), m_len(s.length())
+ : m_str(s), m_buf(s.mb_str()), m_len(s.length())
#endif
{
#if wxUSE_UNICODE
#endif
{
#if wxUSE_UNICODE
- wxASSERT_MSG(m_buf != NULL, _T("Could not convert string to UTF8!"));
+ wxASSERT_MSG(m_buf.data() != NULL, _T("Could not convert string to UTF8!"));
-wxStringInputStream::~wxStringInputStream()
-{
-#if wxUSE_UNICODE
- // Note: wx[W]CharBuffer uses malloc()/free()
- free(m_buf);
-#endif
-}
-
// ----------------------------------------------------------------------------
// getlength
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// getlength
// ----------------------------------------------------------------------------
- memcpy(buffer, m_buf + m_pos, size);
+ memcpy(buffer, m_buf.data() + m_pos, size);
m_pos += size;
return size;
m_pos += size;
return size;
-wxConvBrokenFileNames::wxConvBrokenFileNames(const wxChar *charset)
+wxConvBrokenFileNames::wxConvBrokenFileNames(const wxString& charset)
- if ( !charset || wxStricmp(charset, _T("UTF-8")) == 0
- || wxStricmp(charset, _T("UTF8")) == 0 )
+ if ( wxStricmp(charset, _T("UTF-8")) == 0 ||
+ wxStricmp(charset, _T("UTF8")) == 0 )
m_conv = new wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_PUA);
else
m_conv = new wxCSConv(charset);
m_conv = new wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_PUA);
else
m_conv = new wxCSConv(charset);
class wxMBConv_iconv : public wxMBConv
{
public:
class wxMBConv_iconv : public wxMBConv
{
public:
- wxMBConv_iconv(const wxChar *name);
+ wxMBConv_iconv(const char *name);
virtual ~wxMBConv_iconv();
virtual size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const;
virtual ~wxMBConv_iconv();
virtual size_t MB2WC(wchar_t *buf, const char *psz, size_t n) const;
virtual wxMBConv *Clone() const
{
virtual wxMBConv *Clone() const
{
- wxMBConv_iconv *p = new wxMBConv_iconv(m_name);
+ wxMBConv_iconv *p = new wxMBConv_iconv(m_name.ToAscii());
p->m_minMBCharWidth = m_minMBCharWidth;
return p;
}
p->m_minMBCharWidth = m_minMBCharWidth;
return p;
}
};
// make the constructor available for unit testing
};
// make the constructor available for unit testing
-WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name )
+WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const char* name )
{
wxMBConv_iconv* result = new wxMBConv_iconv( name );
if ( !result->IsOk() )
{
wxMBConv_iconv* result = new wxMBConv_iconv( name );
if ( !result->IsOk() )
wxString wxMBConv_iconv::ms_wcCharsetName;
bool wxMBConv_iconv::ms_wcNeedsSwap = false;
wxString wxMBConv_iconv::ms_wcCharsetName;
bool wxMBConv_iconv::ms_wcNeedsSwap = false;
-wxMBConv_iconv::wxMBConv_iconv(const wxChar *name)
+wxMBConv_iconv::wxMBConv_iconv(const char *name)
: m_name(name)
{
m_minMBCharWidth = 0;
: m_name(name)
{
m_minMBCharWidth = 0;
- // iconv operates with chars, not wxChars, but luckily it uses only ASCII
- // names for the charsets
- const wxCharBuffer cname(wxString(name).ToAscii());
-
// check for charset that represents wchar_t:
if ( ms_wcCharsetName.empty() )
{
// check for charset that represents wchar_t:
if ( ms_wcCharsetName.empty() )
{
wxLogTrace(TRACE_STRCONV, _T(" trying charset \"%s\""),
nameXE.c_str());
wxLogTrace(TRACE_STRCONV, _T(" trying charset \"%s\""),
nameXE.c_str());
- m2w = iconv_open(nameXE.ToAscii(), cname);
+ m2w = iconv_open(nameXE.ToAscii(), name);
if ( m2w == ICONV_T_INVALID )
{
// try charset w/o bytesex info (e.g. "UCS4")
wxLogTrace(TRACE_STRCONV, _T(" trying charset \"%s\""),
nameCS.c_str());
if ( m2w == ICONV_T_INVALID )
{
// try charset w/o bytesex info (e.g. "UCS4")
wxLogTrace(TRACE_STRCONV, _T(" trying charset \"%s\""),
nameCS.c_str());
- m2w = iconv_open(nameCS.ToAscii(), cname);
+ m2w = iconv_open(nameCS.ToAscii(), name);
// and check for bytesex ourselves:
if ( m2w != ICONV_T_INVALID )
// and check for bytesex ourselves:
if ( m2w != ICONV_T_INVALID )
}
else // we already have ms_wcCharsetName
{
}
else // we already have ms_wcCharsetName
{
- m2w = iconv_open(ms_wcCharsetName.ToAscii(), cname);
+ m2w = iconv_open(ms_wcCharsetName.ToAscii(), name);
}
if ( ms_wcCharsetName.empty() )
}
if ( ms_wcCharsetName.empty() )
- w2m = iconv_open(cname, ms_wcCharsetName.ToAscii());
+ w2m = iconv_open(name, ms_wcCharsetName.ToAscii());
if ( w2m == ICONV_T_INVALID )
{
wxLogTrace(TRACE_STRCONV,
wxT("\"%s\" -> \"%s\" works but not the converse!?"),
if ( w2m == ICONV_T_INVALID )
{
wxLogTrace(TRACE_STRCONV,
wxT("\"%s\" -> \"%s\" works but not the converse!?"),
- ms_wcCharsetName.c_str(), cname.data());
+ ms_wcCharsetName.c_str(), name);
#if wxUSE_UNICODE_UTF8
bool wxMBConv_iconv::IsUTF8() const
{
#if wxUSE_UNICODE_UTF8
bool wxMBConv_iconv::IsUTF8() const
{
- return wxStricmp(m_name, _T("UTF-8")) == 0 ||
- wxStricmp(m_name, _T("UTF8")) == 0;
+ return wxStricmp(m_name, "UTF-8") == 0 ||
+ wxStricmp(m_name, "UTF8") == 0;
// from utils.cpp
#if wxUSE_FONTMAP
// from utils.cpp
#if wxUSE_FONTMAP
-extern WXDLLIMPEXP_BASE long wxCharsetToCodepage(const wxChar *charset);
+extern WXDLLIMPEXP_BASE long wxCharsetToCodepage(const char *charset);
extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding);
#endif
extern WXDLLIMPEXP_BASE long wxEncodingToCodepage(wxFontEncoding encoding);
#endif
- wxMBConv_win32(const wxChar* name)
+ wxMBConv_win32(const char* name)
{
m_CodePage = wxCharsetToCodepage(name);
m_minMBCharWidth = 0;
{
m_CodePage = wxCharsetToCodepage(name);
m_minMBCharWidth = 0;
public:
// temporarily just use wxEncodingConverter stuff,
// so that it works while a better implementation is built
public:
// temporarily just use wxEncodingConverter stuff,
// so that it works while a better implementation is built
- wxMBConv_wxwin(const wxChar* name)
+ wxMBConv_wxwin(const char* name)
{
if (name)
m_enc = wxFontMapperBase::Get()->CharsetToEncoding(name, false);
{
if (name)
m_enc = wxFontMapperBase::Get()->CharsetToEncoding(name, false);
};
// make the constructors available for unit testing
};
// make the constructors available for unit testing
-WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const wxChar* name )
+WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const char* name )
{
wxMBConv_wxwin* result = new wxMBConv_wxwin( name );
if ( !result->IsOk() )
{
wxMBConv_wxwin* result = new wxMBConv_wxwin( name );
if ( !result->IsOk() )
-wxCSConv::wxCSConv(const wxChar *charset)
+wxCSConv::wxCSConv(const wxString& charset)
+ if ( !charset.empty() )
+ SetName(charset.ToAscii());
-void wxCSConv::SetName(const wxChar *charset)
+void wxCSConv::SetName(const char *charset)
- m_name = wxStrdup(charset);
+ m_name = strdup(charset);
wxLogTrace(TRACE_STRCONV,
wxT("creating conversion for %s"),
(m_name ? m_name
wxLogTrace(TRACE_STRCONV,
wxT("creating conversion for %s"),
(m_name ? m_name
- : (const wxChar*)wxFontMapperBase::GetEncodingName(m_encoding).c_str()));
+ : (const char*)wxFontMapperBase::GetEncodingName(m_encoding).mb_str()));
#endif // wxUSE_FONTMAP
// check for the special case of ASCII or ISO8859-1 charset: as we have
#endif // wxUSE_FONTMAP
// check for the special case of ASCII or ISO8859-1 charset: as we have
if ( m_name )
#endif // !wxUSE_FONTMAP
{
if ( m_name )
#endif // !wxUSE_FONTMAP
{
#if wxUSE_FONTMAP
wxFontEncoding encoding(m_encoding);
#endif
#if wxUSE_FONTMAP
wxFontEncoding encoding(m_encoding);
#endif
- wxMBConv_iconv *conv = new wxMBConv_iconv(name);
+ wxMBConv_iconv *conv = new wxMBConv_iconv(m_name);
if ( conv->IsOk() )
return conv;
if ( conv->IsOk() )
return conv;
#if wxUSE_FONTMAP
encoding =
#if wxUSE_FONTMAP
encoding =
- wxFontMapperBase::Get()->CharsetToEncoding(name, false);
+ wxFontMapperBase::Get()->CharsetToEncoding(m_name, false);
#endif // wxUSE_FONTMAP
}
#if wxUSE_FONTMAP
#endif // wxUSE_FONTMAP
}
#if wxUSE_FONTMAP
if ( it->second.empty() )
return NULL;
if ( it->second.empty() )
return NULL;
- wxMBConv_iconv *conv = new wxMBConv_iconv(it->second);
+ wxMBConv_iconv *conv = new wxMBConv_iconv(it->second.ToAscii());
if ( conv->IsOk() )
return conv;
if ( conv->IsOk() )
return conv;
}
const wxChar** names = wxFontMapperBase::GetAllEncodingNames(encoding);
}
const wxChar** names = wxFontMapperBase::GetAllEncodingNames(encoding);
- // CS : in case this does not return valid names (eg for MacRoman) encoding
- // got a 'failure' entry in the cache all the same, although it just has to
- // be created using a different method, so only store failed iconv creation
- // attempts (or perhaps we shoulnd't do this at all ?)
+ // CS : in case this does not return valid names (eg for MacRoman)
+ // encoding got a 'failure' entry in the cache all the same,
+ // although it just has to be created using a different method, so
+ // only store failed iconv creation attempts (or perhaps we
+ // shoulnd't do this at all ?)
if ( names[0] != NULL )
{
for ( ; *names; ++names )
{
if ( names[0] != NULL )
{
for ( ; *names; ++names )
{
- wxMBConv_iconv *conv = new wxMBConv_iconv(*names);
+ // FIXME-UTF8: wxFontMapperBase::GetAllEncodingNames()
+ // will need changes that will obsolete this
+ wxString name(*names);
+ wxMBConv_iconv *conv = new wxMBConv_iconv(name.ToAscii());
if ( conv->IsOk() )
{
gs_nameCache[encoding] = *names;
if ( conv->IsOk() )
{
gs_nameCache[encoding] = *names;
m_name ? m_name
:
#if wxUSE_FONTMAP
m_name ? m_name
:
#if wxUSE_FONTMAP
- (const wxChar*)wxFontMapperBase::GetEncodingDescription(m_encoding).c_str()
+ (const char*)wxFontMapperBase::GetEncodingDescription(m_encoding).ToAscii()
- (const wxChar*)wxString::Format(_("encoding %i"), m_encoding).c_str()
+ (const char*)wxString::Format(_("encoding %i"), m_encoding).ToAscii()
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
);
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
);
}
wxString::size_type wxFilterClassFactoryBase::FindExtension(
}
wxString::size_type wxFilterClassFactoryBase::FindExtension(
- const wxChar *location) const
+ const wxString& location) const
- size_t len = wxStrlen(location);
-
for (const wxChar *const *p = GetProtocols(wxSTREAM_FILEEXT); *p; p++)
{
for (const wxChar *const *p = GetProtocols(wxSTREAM_FILEEXT); *p; p++)
{
- size_t l = wxStrlen(*p);
-
- if (l <= len && wxStrcmp(*p, location + len - l) == 0)
- return len - l;
+ if ( location.EndsWith(*p) )
+ return location.length() - wxStrlen(*p);
}
return wxString::npos;
}
}
return wxString::npos;
}
-bool wxFilterClassFactoryBase::CanHandle(const wxChar *protocol,
+bool wxFilterClassFactoryBase::CanHandle(const wxString& protocol,
wxStreamProtocolType type) const
{
if (type == wxSTREAM_FILEEXT)
return FindExtension(protocol) != wxString::npos;
else
for (const wxChar *const *p = GetProtocols(type); *p; p++)
wxStreamProtocolType type) const
{
if (type == wxSTREAM_FILEEXT)
return FindExtension(protocol) != wxString::npos;
else
for (const wxChar *const *p = GetProtocols(type); *p; p++)
- if (wxStrcmp(*p, protocol) == 0)
return true;
return false;
return true;
return false;
if ((value = GetExtendedHeader(m_hdr->Name(id))) != wxEmptyString) {
wxTarNumber n = 0;
if ((value = GetExtendedHeader(m_hdr->Name(id))) != wxEmptyString) {
wxTarNumber n = 0;
- const wxChar *p = value;
- while (*p == ' ')
+ wxString::const_iterator p = value.begin();
+ while (*p == ' ' && p != value.end())
p++;
while (isdigit(*p))
n = n * 10 + (*p++ - '0');
p++;
while (isdigit(*p))
n = n * 10 + (*p++ - '0');
- wxCharBuffer buffer = m_conv->cWC2MB(out, out.length(), &len);
+ // FIXME-UTF8: use wxCharBufferWithLength if/when we have it
+ wxCharBuffer buffer = m_conv->cWC2MB(out.wc_str(), out.length(), &len);
m_output.Write(buffer, len);
#else
m_output.Write(out.c_str(), out.length() );
m_output.Write(buffer, len);
#else
m_output.Write(out.c_str(), out.length() );
+ // FIXME-UTF8: rewrite ParseXXX() methods using iterators
+ // NB: using wxWxCharBuffer instead of just c_str() avoids keeping
+ // converted string in memory for longer than needed
+ return Parse(wxWxCharBuffer(uri.c_str()));
}
// ---------------------------------------------------------------------------
}
// ---------------------------------------------------------------------------
// URI-reference = URI / relative
// ---------------------------------------------------------------------------
// URI-reference = URI / relative
// ---------------------------------------------------------------------------
-const wxChar* wxURI::Parse(const wxChar* uri)
+const wxChar* wxURI::Parse(const wxChar *uri)
{
uri = ParseScheme(uri);
uri = ParseAuthority(uri);
{
uri = ParseScheme(uri);
uri = ParseAuthority(uri);
// Individual parsers for each URI component
// ---------------------------------------------------------------------------
// Individual parsers for each URI component
// ---------------------------------------------------------------------------
-const wxChar* wxURI::ParseScheme(const wxChar* uri)
+const wxChar* wxURI::ParseScheme(const wxChar *uri)
size_t wxZipEntry::WriteLocal(wxOutputStream& stream, wxMBConv& conv) const
{
wxString unixName = GetName(wxPATH_UNIX);
size_t wxZipEntry::WriteLocal(wxOutputStream& stream, wxMBConv& conv) const
{
wxString unixName = GetName(wxPATH_UNIX);
- const wxWX2MBbuf name_buf = conv.cWX2MB(unixName);
+ const wxWX2MBbuf name_buf = unixName.mb_str(conv);
const char *name = name_buf;
if (!name) name = "";
wxUint16 nameLen = wx_truncate_cast(wxUint16, strlen(name));
const char *name = name_buf;
if (!name) name = "";
wxUint16 nameLen = wx_truncate_cast(wxUint16, strlen(name));
size_t wxZipEntry::WriteCentral(wxOutputStream& stream, wxMBConv& conv) const
{
wxString unixName = GetName(wxPATH_UNIX);
size_t wxZipEntry::WriteCentral(wxOutputStream& stream, wxMBConv& conv) const
{
wxString unixName = GetName(wxPATH_UNIX);
- const wxWX2MBbuf name_buf = conv.cWX2MB(unixName);
+ const wxWX2MBbuf name_buf = unixName.mb_str(conv);
const char *name = name_buf;
if (!name) name = "";
wxUint16 nameLen = wx_truncate_cast(wxUint16, strlen(name));
const char *name = name_buf;
if (!name) name = "";
wxUint16 nameLen = wx_truncate_cast(wxUint16, strlen(name));
- const wxWX2MBbuf comment_buf = conv.cWX2MB(m_Comment);
+ const wxWX2MBbuf comment_buf = m_Comment.mb_str(conv);
const char *comment = comment_buf;
if (!comment) comment = "";
wxUint16 commentLen = wx_truncate_cast(wxUint16, strlen(comment));
const char *comment = comment_buf;
if (!comment) comment = "";
wxUint16 commentLen = wx_truncate_cast(wxUint16, strlen(comment));
bool wxZipEndRec::Write(wxOutputStream& stream, wxMBConv& conv) const
{
bool wxZipEndRec::Write(wxOutputStream& stream, wxMBConv& conv) const
{
- const wxWX2MBbuf comment_buf = conv.cWX2MB(m_Comment);
+ const wxWX2MBbuf comment_buf = m_Comment.mb_str(conv);
const char *comment = comment_buf;
if (!comment) comment = "";
wxUint16 commentLen = (wxUint16)strlen(comment);
const char *comment = comment_buf;
if (!comment) comment = "";
wxUint16 commentLen = (wxUint16)strlen(comment);
bool wxAnimation::LoadFile(const wxString &name, wxAnimationType WXUNUSED(type))
{
UnRef();
bool wxAnimation::LoadFile(const wxString &name, wxAnimationType WXUNUSED(type))
{
UnRef();
- m_pixbuf = gdk_pixbuf_animation_new_from_file(
- wxConvFileName->cWX2MB(name), NULL);
+ m_pixbuf = gdk_pixbuf_animation_new_from_file(name.fn_str(), NULL);
if ( !defaultPath.empty() )
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
if ( !defaultPath.empty() )
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
- wxConvFileName->cWX2MB(defaultPath) );
+ defaultPath.fn_str() );
}
else
wxGenericDirDialog::Create(parent, title, defaultPath, style, pos, sz, name);
}
else
wxGenericDirDialog::Create(parent, title, defaultPath, style, pos, sz, name);
{
if (wxDirExists(dir))
{
{
if (wxDirExists(dir))
{
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(dir));
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
+ dir.fn_str());
if (!gtk_check_version(2,4,0))
{
wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
if (!gtk_check_version(2,4,0))
{
wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
- return wxConvFileName->cMB2WX(str);
+ return wxString(str, *wxConvFileName);
}
return wxGenericDirDialog::GetPath();
}
return wxGenericDirDialog::GetPath();
msg.Printf(
_("File '%s' already exists, do you really want to overwrite it?"),
msg.Printf(
_("File '%s' already exists, do you really want to overwrite it?"),
- wxString(wxConvFileName->cMB2WX(filename)).c_str());
+ wxString(filename, *wxConvFileName));
wxMessageDialog dlg(dialog, msg, _("Confirm"),
wxYES_NO | wxICON_QUESTION);
wxMessageDialog dlg(dialog, msg, _("Confirm"),
wxYES_NO | wxICON_QUESTION);
if (!gtk_check_version(2,4,0))
{
wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
if (!gtk_check_version(2,4,0))
{
wxGtkString str(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(m_widget)));
- return wxConvFileName->cMB2WX(str);
+ return wxString(str, *wxConvFileName);
}
return wxGenericFileDialog::GetPath();
}
return wxGenericFileDialog::GetPath();
GSList *gpaths = gpathsi;
while (gpathsi)
{
GSList *gpaths = gpathsi;
while (gpathsi)
{
- wxString file(wxConvFileName->cMB2WX((gchar*) gpathsi->data));
+ wxString file((gchar*) gpathsi->data, *wxConvFileName);
paths.Add(file);
g_free(gpathsi->data);
gpathsi = gpathsi->next;
paths.Add(file);
g_free(gpathsi->data);
gpathsi = gpathsi->next;
{
if (path.empty()) return;
{
if (path.empty()) return;
- gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(path));
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), path.fn_str());
}
else
wxGenericFileDialog::SetPath( path );
}
else
wxGenericFileDialog::SetPath( path );
{
if (wxDirExists(dir))
{
{
if (wxDirExists(dir))
{
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), wxConvFileName->cWX2MB(dir));
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), dir.fn_str());
if (!gtk_check_version(2,4,0))
{
wxGtkString str(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(m_widget)));
if (!gtk_check_version(2,4,0))
{
wxGtkString str(gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(m_widget)));
- return wxConvFileName->cMB2WX(str);
+ return wxString(str, *wxConvFileName);
}
return wxGenericFileDialog::GetDirectory();
}
return wxGenericFileDialog::GetDirectory();
if ( UseNative() )
{
const gchar *str = gtk_link_button_get_uri(GTK_LINK_BUTTON(m_widget));
if ( UseNative() )
{
const gchar *str = gtk_link_button_get_uri(GTK_LINK_BUTTON(m_widget));
- return wxConvFileName->cMB2WX(str);
+ return wxString(str, *wxConvFileName);
}
return wxGenericHyperlinkCtrl::GetURL();
}
return wxGenericHyperlinkCtrl::GetURL();
static wxString wxReplaceUnderscore( const wxString& title )
{
static wxString wxReplaceUnderscore( const wxString& title )
{
// GTK 1.2 wants to have "_" instead of "&" for accelerators
wxString str;
// GTK 1.2 wants to have "_" instead of "&" for accelerators
wxString str;
- pc = title;
- while (*pc != wxT('\0'))
+
+ for ( wxString::const_iterator pc = title.begin(); pc != title.end(); ++pc )
- if ((*pc == wxT('&')) && (*(pc+1) == wxT('&')))
+ if ((*pc == wxT('&')) && (pc+1 != title.end()) && (*(pc+1) == wxT('&')))
{
// "&" is doubled to indicate "&" instead of accelerator
++pc;
{
// "&" is doubled to indicate "&" instead of accelerator
++pc;
}
// wxPrintf( wxT("before %s after %s\n"), title.c_str(), str.c_str() );
}
// wxPrintf( wxT("before %s after %s\n"), title.c_str(), str.c_str() );
radio_button_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON(rbtn) );
label.Empty();
radio_button_group = gtk_radio_button_get_group( GTK_RADIO_BUTTON(rbtn) );
label.Empty();
- for ( const wxChar *pc = choices[i]; *pc; pc++ )
+ for ( wxString::const_iterator pc = choices[i].begin();
+ pc != choices[i].end(); ++pc )
{
if ( *pc != wxT('&') )
label += *pc;
{
if ( *pc != wxT('&') )
label += *pc;
-extern long wxCharsetToCodepage(const wxChar *name)
+extern long wxCharsetToCodepage(const char *name)
{
// first get the font encoding for this charset
if ( !name )
{
// first get the font encoding for this charset
if ( !name )
#include "wx/msw/registry.h"
// this should work if Internet Exploiter is installed
#include "wx/msw/registry.h"
// this should work if Internet Exploiter is installed
-extern long wxCharsetToCodepage(const wxChar *name)
+extern long wxCharsetToCodepage(const char *name)
{
if (!name)
return GetACP();
{
if (!name)
return GetACP();
if (image->GetImage().Ok())
{
wxString ext(image->GetImageBlock().GetExtension());
if (image->GetImage().Ok())
{
wxString ext(image->GetImageBlock().GetExtension());
- wxString tempFilename(wxString::Format(wxT("image%d.%s"), sm_fileCounter, (const wxChar*) ext));
+ wxString tempFilename(wxString::Format(wxT("image%d.%s"), sm_fileCounter, ext));
wxMemoryFSHandler::AddFile(tempFilename, image->GetImage(), image->GetImageBlock().GetImageType());
m_imageLocations.Add(tempFilename);
wxMemoryFSHandler::AddFile(tempFilename, image->GetImage(), image->GetImageBlock().GetImageType());
m_imageLocations.Add(tempFilename);
tempDir = wxFileName::GetTempDir();
wxString ext(image->GetImageBlock().GetExtension());
tempDir = wxFileName::GetTempDir();
wxString ext(image->GetImageBlock().GetExtension());
- wxString tempFilename(wxString::Format(wxT("%s/image%d.%s"), (const wxChar*) tempDir, sm_fileCounter, (const wxChar*) ext));
+ wxString tempFilename(wxString::Format(wxT("%s/image%d.%s"), tempDir, sm_fileCounter, ext));
image->GetImageBlock().Write(tempFilename);
m_imageLocations.Add(tempFilename);
image->GetImageBlock().Write(tempFilename);
m_imageLocations.Add(tempFilename);
{
wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel);
wxString name(def->GetName());
{
wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel);
wxString name(def->GetName());
- if (wxYES == wxMessageBox(wxString::Format(_("Delete style %s?"), (const wxChar*) name), _("Delete Style"), wxYES_NO|wxICON_QUESTION, this))
+ if (wxYES == wxMessageBox(wxString::Format(_("Delete style %s?"), name), _("Delete Style"), wxYES_NO|wxICON_QUESTION, this))
{
m_stylesListBox->GetStyleListBox()->SetItemCount(0);
{
m_stylesListBox->GetStyleListBox()->SetItemCount(0);
wxString s ;
s.Printf(wxT("<?xml version=\"%s\" encoding=\"%s\"?>\n"),
wxString s ;
s.Printf(wxT("<?xml version=\"%s\" encoding=\"%s\"?>\n"),
- (const wxChar*) version, (const wxChar*) fileEncoding );
+ version, fileEncoding);
OutputString(stream, s, NULL, NULL);
OutputString(stream, wxT("<richtext version=\"1.0.0.0\" xmlns=\"http://www.wxwidgets.org\">") , NULL, NULL);
OutputString(stream, s, NULL, NULL);
OutputString(stream, wxT("<richtext version=\"1.0.0.0\" xmlns=\"http://www.wxwidgets.org\">") , NULL, NULL);
return false;
#if wxUSE_UNICODE
return false;
#if wxUSE_UNICODE
- de_d_name = wxConvFileName->cMB2WC( de->d_name );
+ de_d_name = wxString(de->d_name, *wxConvFileName);
#else
de_d_name = de->d_name;
#endif
#else
de_d_name = de->d_name;
#endif
bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
{
bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
{
- wxString strExtensions = m_manager->GetExtension(m_index[0]);
+ const wxString strExtensions = m_manager->GetExtension(m_index[0]);
extensions.Empty();
// one extension in the space or comma-delimited list
wxString strExt;
extensions.Empty();
// one extension in the space or comma-delimited list
wxString strExt;
- for ( const wxChar *p = strExtensions; /* nothing */; p++ )
+ wxString::const_iterator end = strExtensions.end();
+ for ( wxString::const_iterator p = strExtensions.begin(); /* nothing */; ++p )
- if ( *p == wxT(' ') || *p == wxT(',') || *p == wxT('\0') )
+ if ( p == end || *p == wxT(' ') || *p == wxT(',') )
{
if ( !strExt.empty() )
{
{
if ( !strExt.empty() )
{
//else: repeated spaces
// (shouldn't happen, but it's not that important if it does happen)
//else: repeated spaces
// (shouldn't happen, but it's not that important if it does happen)
break;
}
else if ( *p == wxT('.') )
break;
}
else if ( *p == wxT('.') )
}
// is this something of the form foo=bar?
}
// is this something of the form foo=bar?
- const wxChar *pEq = wxStrchr(curField, wxT('='));
- if ( pEq != NULL )
+ if ( curField.find('=') != wxString::npos )
{
// split "LHS = RHS" in 2
wxString lhs = curField.BeforeFirst(wxT('=')),
{
// split "LHS = RHS" in 2
wxString lhs = curField.BeforeFirst(wxT('=')),
// get OS version
int major, minor;
wxString release = wxGetCommandOutput(wxT("uname -r"));
// get OS version
int major, minor;
wxString release = wxGetCommandOutput(wxT("uname -r"));
- if ( release.empty() || wxSscanf(release, wxT("%d.%d"), &major, &minor) != 2 )
+ if ( release.empty() ||
+ wxSscanf(release.c_str(), wxT("%d.%d"), &major, &minor) != 2 )
{
// failed to get version string or unrecognized format
major =
{
// failed to get version string or unrecognized format
major =
bool wxGetEnv(const wxString& var, wxString *value)
{
// wxGetenv is defined as getenv()
bool wxGetEnv(const wxString& var, wxString *value)
{
// wxGetenv is defined as getenv()
- wxChar *p = wxGetenv(var);
+ char *p = wxGetenv(var);
// We must build conversion table for expat. The easiest way to do so
// is to let wxCSConv convert as string containing all characters to
// wide character representation:
// We must build conversion table for expat. The easiest way to do so
// is to let wxCSConv convert as string containing all characters to
// wide character representation:
- wxString str(name, wxConvLibc);
- wxCSConv conv(str.c_str());
char mbBuf[2];
wchar_t wcBuf[10];
size_t i;
char mbBuf[2];
wchar_t wcBuf[10];
size_t i;
static size_t GetNumber() { return ms_bars; }
static size_t GetNumber() { return ms_bars; }
- const wxChar *GetName() const { return m_name; }
+ const wxChar *GetName() const { return m_name.c_str(); }
private:
wxString m_name;
private:
wxString m_name;
// convert back
wxDateTime dt2;
// convert back
wxDateTime dt2;
- const wxChar *result = dt2.ParseFormat(s, fmt);
+ const wxChar *result = dt2.ParseFormat(s.c_str(), fmt);
if ( !result )
{
// converion failed - should it have?
if ( !result )
{
// converion failed - should it have?
void FormatConverterTestCase::check(const wxString& input,
const wxString& expected)
{
void FormatConverterTestCase::check(const wxString& input,
const wxString& expected)
{
- wxString result = wxConvertFormat(input);
+ wxString result = wxConvertFormat(input.wc_str());
wxString msg = _T("input: '") + input +
_T("', result: '") + result +
_T("', expected: '") + expected + _T("'");
wxString msg = _T("input: '") + input +
_T("', result: '") + result +
_T("', expected: '") + expected + _T("'");
static size_t GetNumber() { return ms_bars; }
static size_t GetNumber() { return ms_bars; }
- const wxChar *GetName() const { return m_name; }
+ const wxChar *GetName() const { return m_name.c_str(); }
private:
wxString m_name;
private:
wxString m_name;
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
- wxMBConv* converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence
+ wxMBConv& converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence
int sizeofNull // number of bytes occupied by terminating null in this encoding
);
int sizeofNull // number of bytes occupied by terminating null in this encoding
);
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
- wxMBConv* converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence
+ wxMBConv& converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence
int sizeofNull // number of bytes occupied by terminating null in this encoding
);
int sizeofNull // number of bytes occupied by terminating null in this encoding
);
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
- wxMBConv* converter // the wxMBConv object that can decode multiBuffer into a wide character sequence
+ wxMBConv& converter // the wxMBConv object that can decode multiBuffer into a wide character sequence
);
// use wxTextOutputStream to exercise wxMBConv interface
);
// use wxTextOutputStream to exercise wxMBConv interface
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
- wxMBConv* converter // the wxMBConv object that can decode multiBuffer into a wide character sequence
+ wxMBConv& converter // the wxMBConv object that can decode multiBuffer into a wide character sequence
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
const char* utf8Buffer, // the same character sequence as multiBuffer, encoded as UTF-8
size_t utf8Bytes, // the byte length of the UTF-8 encoded character sequence
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
const char* utf8Buffer, // the same character sequence as multiBuffer, encoded as UTF-8
size_t utf8Bytes, // the byte length of the UTF-8 encoded character sequence
- wxMBConv* converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence
+ wxMBConv& converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence
int sizeofNull // the number of bytes occupied by a terminating null in the converter's encoding
);
int sizeofNull // the number of bytes occupied by a terminating null in the converter's encoding
);
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_iconv,
sizeof(welcome_utf7_iconv),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_iconv,
sizeof(welcome_utf7_iconv),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_wx,
sizeof(welcome_utf7_wx),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_wx,
sizeof(welcome_utf7_wx),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_iconv,
sizeof(welcome_utf7_iconv),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_iconv,
sizeof(welcome_utf7_iconv),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_wx,
sizeof(welcome_utf7_wx),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_wx,
sizeof(welcome_utf7_wx),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf8,
sizeof(welcome_utf8),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf8,
sizeof(welcome_utf8),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf8,
sizeof(welcome_utf8),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf8,
sizeof(welcome_utf8),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16le,
sizeof(welcome_utf16le),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16le,
sizeof(welcome_utf16le),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16le,
sizeof(welcome_utf16le),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16le,
sizeof(welcome_utf16le),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16be,
sizeof(welcome_utf16be),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16be,
sizeof(welcome_utf16be),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16be,
sizeof(welcome_utf16be),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16be,
sizeof(welcome_utf16be),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32le,
sizeof(welcome_utf32le),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32le,
sizeof(welcome_utf32le),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32le,
sizeof(welcome_utf32le),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32le,
sizeof(welcome_utf32le),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32be,
sizeof(welcome_utf32be),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32be,
sizeof(welcome_utf32be),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32be,
sizeof(welcome_utf32be),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32be,
sizeof(welcome_utf32be),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_cp932,
sizeof(welcome_cp932),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_cp932,
sizeof(welcome_cp932),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_cp932,
sizeof(welcome_cp932),
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_cp932,
sizeof(welcome_cp932),
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
const char* utf8Buffer, // the same character sequence as multiBuffer, encoded as UTF-8
size_t utf8Bytes, // the byte length of the UTF-8 encoded character sequence
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
const char* utf8Buffer, // the same character sequence as multiBuffer, encoded as UTF-8
size_t utf8Bytes, // the byte length of the UTF-8 encoded character sequence
- wxMBConv* converter, // the wxMBConv object thta can decode multiBuffer into a wide character sequence
+ wxMBConv& converter, // the wxMBConv object thta can decode multiBuffer into a wide character sequence
int sizeofNull // the number of bytes occupied by a terminating null in the converter's encoding
)
{
int sizeofNull // the number of bytes occupied by a terminating null in the converter's encoding
)
{
-WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const wxChar* name );
+WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const char* name );
void MBConvTestCase::FontmapTests()
{
#ifdef wxUSE_FONTMAP
void MBConvTestCase::FontmapTests()
{
#ifdef wxUSE_FONTMAP
- wxMBConv* converter = new_wxMBConv_wxwin( _T("CP1252") );
+ wxMBConv* converter = new_wxMBConv_wxwin("CP1252");
if ( !converter )
{
return;
if ( !converter )
{
return;
sizeof(CP1252),
(const char*)CP1252_utf8,
sizeof(CP1252_utf8),
sizeof(CP1252),
(const char*)CP1252_utf8,
sizeof(CP1252_utf8),
-WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name );
+WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const char* name );
void MBConvTestCase::IconvTests()
{
#ifdef HAVE_ICONV
void MBConvTestCase::IconvTests()
{
#ifdef HAVE_ICONV
- wxMBConv* converter = new_wxMBConv_iconv( _T("CP932") );
+ wxMBConv* converter = new_wxMBConv_iconv("CP932");
if ( !converter )
{
return;
if ( !converter )
{
return;
sizeof(welcome_cp932),
(const char*)welcome_utf8,
sizeof(welcome_utf8),
sizeof(welcome_cp932),
(const char*)welcome_utf8,
sizeof(welcome_utf8),
sizeof(CP1252),
(const char*)CP1252_utf8,
sizeof(CP1252_utf8),
sizeof(CP1252),
(const char*)CP1252_utf8,
sizeof(CP1252_utf8),
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
- wxMBConv* converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence
+ wxMBConv& converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence
int sizeofNull // number of bytes occupied by terminating null in this encoding
)
{
int sizeofNull // number of bytes occupied by terminating null in this encoding
)
{
memset( &inputCopy.data()[multiBytes], 0, sizeofNull );
// calculate the output size
memset( &inputCopy.data()[multiBytes], 0, sizeofNull );
// calculate the output size
- size_t outputWritten = converter->MB2WC
+ size_t outputWritten = converter.MB2WC
(
0,
(const char*)inputCopy.data(),
(
0,
(const char*)inputCopy.data(),
wxWCharBuffer outputBuffer(outputBufferChars);
memset( outputBuffer.data(), UNINITIALIZED, outputBufferChars*sizeof(wchar_t) );
wxWCharBuffer outputBuffer(outputBufferChars);
memset( outputBuffer.data(), UNINITIALIZED, outputBufferChars*sizeof(wchar_t) );
- outputWritten = converter->MB2WC
+ outputWritten = converter.MB2WC
(
outputBuffer.data(),
(const char*)inputCopy.data(),
(
outputBuffer.data(),
(const char*)inputCopy.data(),
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
- wxMBConv* converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence
+ wxMBConv& converter, // the wxMBConv object that can decode multiBuffer into a wide character sequence
int sizeofNull // number of bytes occupied by terminating null in this encoding
)
{
int sizeofNull // number of bytes occupied by terminating null in this encoding
)
{
inputCopy.data()[wideChars] = 0;
// calculate the output size
inputCopy.data()[wideChars] = 0;
// calculate the output size
- size_t outputWritten = converter->WC2MB
+ size_t outputWritten = converter.WC2MB
(
0,
(const wchar_t*)inputCopy.data(),
(
0,
(const wchar_t*)inputCopy.data(),
wxCharBuffer outputBuffer(outputBufferSize);
memset( outputBuffer.data(), UNINITIALIZED, outputBufferSize );
wxCharBuffer outputBuffer(outputBufferSize);
memset( outputBuffer.data(), UNINITIALIZED, outputBufferSize );
- outputWritten = converter->WC2MB
+ outputWritten = converter.WC2MB
(
outputBuffer.data(),
(const wchar_t*)inputCopy.data(),
(
outputBuffer.data(),
(const wchar_t*)inputCopy.data(),
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
- wxMBConv* converter // the wxMBConv object that can decode multiBuffer into a wide character sequence
+ wxMBConv& converter // the wxMBConv object that can decode multiBuffer into a wide character sequence
)
{
// this isn't meant to test wxMemoryInputStream or wxTextInputStream
// it's meant to test the way wxTextInputStream uses wxMBConv
// (which has exposed some problems with wxMBConv)
wxMemoryInputStream memoryInputStream( multiBuffer, multiBytes );
)
{
// this isn't meant to test wxMemoryInputStream or wxTextInputStream
// it's meant to test the way wxTextInputStream uses wxMBConv
// (which has exposed some problems with wxMBConv)
wxMemoryInputStream memoryInputStream( multiBuffer, multiBytes );
- wxTextInputStream textInputStream( memoryInputStream, wxT(""), *converter );
+ wxTextInputStream textInputStream( memoryInputStream, wxT(""), converter );
for ( size_t i = 0; i < wideChars; i++ )
{
wxChar wc = textInputStream.GetChar();
for ( size_t i = 0; i < wideChars; i++ )
{
wxChar wc = textInputStream.GetChar();
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
size_t wideChars, // the number of wide characters at wideBuffer
const char* multiBuffer, // a multibyte encoded character sequence that can be decoded by "converter"
size_t multiBytes, // the byte length of the multibyte character sequence that can be decoded by "converter"
- wxMBConv* converter // the wxMBConv object that can decode multiBuffer into a wide character sequence
+ wxMBConv& converter // the wxMBConv object that can decode multiBuffer into a wide character sequence
)
{
// this isn't meant to test wxMemoryOutputStream or wxTextOutputStream
)
{
// this isn't meant to test wxMemoryOutputStream or wxTextOutputStream
// (which has exposed some problems with wxMBConv)
wxMemoryOutputStream memoryOutputStream;
// wxEOL_UNIX will pass \n \r unchanged
// (which has exposed some problems with wxMBConv)
wxMemoryOutputStream memoryOutputStream;
// wxEOL_UNIX will pass \n \r unchanged
- wxTextOutputStream textOutputStream( memoryOutputStream, wxEOL_UNIX, *converter );
+ wxTextOutputStream textOutputStream( memoryOutputStream, wxEOL_UNIX, converter );
for ( size_t i = 0; i < wideChars; i++ )
{
textOutputStream.PutChar( wideBuffer[i] );
for ( size_t i = 0; i < wideChars; i++ )
{
textOutputStream.PutChar( wideBuffer[i] );
//
void RegExTestCase::parseFlags(const wxString& flags)
{
//
void RegExTestCase::parseFlags(const wxString& flags)
{
- for (const wxChar *p = flags; *p; p++) {
- switch (*p) {
+ for ( wxString::const_iterator p = flags.begin(); p != flags.end(); ++p )
+ {
+ switch ( (*p).GetValue() ) {