\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.
\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
\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
\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.
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);
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);
Add(src[n]);
}
- 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
// 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);
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
class WXDLLIMPEXP_BASE wxCmdLineParser
{
public:
- static wxArrayString ConvertStringToArgs(const wxChar *cmdline);
+ static wxArrayString ConvertStringToArgs(const wxString& cmdline);
};
#endif // wxUSE_CMDLINE_PARSER/!wxUSE_CMDLINE_PARSER
/*
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_
// 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;
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)
- { return Execute(str, -1, wxIPC_TEXT); }
+ { return Execute(str.c_str(), -1, wxIPC_TEXT); }
protected:
wxSocketBase *m_sock;
// ctor associates the stream with the given string which makes a copy of
// it
wxStringInputStream(const wxString& s);
- virtual ~wxStringInputStream();
virtual wxFileOffset GetLength() const;
wxString m_str;
// the buffer we're reading from
- char* m_buf;
+ wxCharBuffer m_buf;
// length of the buffer we're reading from
size_t m_len;
#if wxUSE_WCHAR_T
+class WXDLLIMPEXP_BASE wxString;
+
// the error value returned by wxMBConv methods
#define wxCONV_FAILED ((size_t)-1)
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)
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);
// 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
- wxChar *m_name;
+ char *m_name;
wxFontEncoding m_encoding;
// use CreateConvIfNeeded() before accessing m_convReal!
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:
- wxString::size_type FindExtension(const wxChar *location) const;
+ wxString::size_type FindExtension(const wxString& location) const;
DECLARE_ABSTRACT_CLASS(wxFilterClassFactoryBase)
};
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);
// 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))
}
// 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
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 ( 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 );
}
else {
for( size_t ui = 0; ui < m_nCount; ui++ ) {
- if( m_pItems[ui].IsSameAs(sz, bCase) )
+ if( m_pItems[ui].IsSameAs(str, bCase) )
return ui;
}
}
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
_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")
+ );
wxASSERT_MSG
- (
- 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")
+ );
kind = k;
// 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
- if ( arg[0u] == _T('-') && arg[1u] == _T('-') )
+ if ( arg.length() >= 3 && arg[0u] == _T('-') && arg[1u] == _T('-') )
{
// a long one
isLong = true;
// Skip leading "--"
- const wxChar *p = arg.c_str() + 2;
+ wxString::const_iterator p = arg.begin() + 2;
bool longOptionsEnabled = AreLongOptionsEnabled();
- name = GetLongOptionName(p);
+ name = GetLongOptionName(p, arg.end());
if (longOptionsEnabled)
{
// 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
// 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();
+
if ( isLong )
- 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
- if ( *p != _T('\0') )
+ if ( p != arg.end() )
{
errorMsg << wxString::Format(_("Unexpected characters following option '%s'."), name.c_str())
<< _T('\n');
}
else // short option
{
- switch ( *p )
+ switch ( (*p).GetValue() )
{
case _T('='):
case _T(':'):
// the value follows
- p++;
+ ++p;
break;
case 0:
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();
}
break;
if ( ok )
{
- wxString value = p;
+ wxString value(p, end);
switch ( opt.type )
{
default:
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."),
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)
{
wxString argName;
- while ( *p && (wxIsalnum(*p) || wxStrchr(allowedChars, *p)) )
+ while ( p != end && (wxIsalnum(*p) || wxStrchr(allowedChars, *p)) )
{
argName += *p++;
}
#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
*/
/* static */
-wxArrayString wxCmdLineParser::ConvertStringToArgs(const wxChar *p)
+wxArrayString wxCmdLineParser::ConvertStringToArgs(const wxString& cmdline)
{
wxArrayString args;
arg.reserve(1024);
bool isInsideQuotes = false;
+
+ wxString::const_iterator p = cmdline.begin();
+
for ( ;; )
{
// skip white space
- while ( *p == _T(' ') || *p == _T('\t') )
- p++;
+ while ( p != cmdline.end() && (*p == _T(' ') || *p == _T('\t')) )
+ ++p;
// anything left?
- if ( *p == _T('\0') )
+ if ( p == cmdline.end() )
break;
// parse this parameter
bool lastBS = false;
for ( arg.clear(); !endParam; p++ )
{
- switch ( *p )
+ switch ( (*p).GetValue() )
{
case _T('"'):
if ( !lastBS )
/* 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:
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);
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!
- const wxChar *pszValue = NULL;
+ bool expanded = false;
wxString tmp;
if (wxGetEnv(strVarName, &tmp))
- pszValue = tmp;
-#endif
- if ( pszValue != NULL ) {
- strResult += pszValue;
+ {
+ strResult += tmp;
+ expanded = true;
}
- else {
+ else
+#endif
+ {
// variable doesn't exist => don't change anything
#ifdef __WXMSW__
if ( bracket != Bracket_Windows )
}
else {
// skip closing bracket unless the variables wasn't expanded
- if ( pszValue == NULL )
+ if ( !expanded )
strResult << (wxChar)bracket;
m++;
}
}
// 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;
- const wxChar *pc = sz;
+ wxString::const_iterator pc = path.begin();
for ( ;; ) {
- 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 )
- wxLogWarning(_("'%s' has extra '..', ignored."), sz);
+ wxLogWarning(_("'%s' has extra '..', ignored."), path);
else
aParts.erase(aParts.end() - 1);
//else:
// could log an error here, but we prefer to ignore extra '/'
- if ( *pc == wxT('\0') )
+ if ( pc == path.end() )
break;
}
else
strCurrent += *pc;
- pc++;
+ ++pc;
}
}
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() )
{
heightTextTotal += heightLine;
}
- if ( *pc == _T('\n') )
+ if ( pc == text.end() )
{
- curLine.clear();
+ break;
}
- else
+ else // '\n'
{
- // the end of string
- break;
+ curLine.clear();
}
}
else
// local functions
// ----------------------------------------------------------------------------
-static wxString FindExtension(const wxChar *path)
+static wxString FindExtension(const wxString& path)
{
wxString ext;
wxSplitPath(path, NULL, NULL, &ext);
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());
// 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)
+struct wxStringCmp
{
- 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;
it = std::find_if(begin(), end(),
std::not1(
std::bind2nd(
- std::ptr_fun(wxStrcmpCppWrapper), sz)));
+ wxStringCmp(), str)));
}
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();
{
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:
}
}
-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;
- wxString s(sz);
if (bCase)
- it = std::lower_bound(begin(), end(), s,
- wxStringCompare(wxStrcmpCppWrapper));
+ it = std::lower_bound(begin(), end(), str,
+ wxStringCompare(wxStringCmp()));
else
- 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 (wxStrcmp(it->c_str(), sz) != 0)
+ if (str.Cmp(*it) != 0)
return wxNOT_FOUND;
}
else
{
- if (wxStricmp(it->c_str(), sz) != 0)
+ if (str.CmpNoCase(*it) != 0)
return wxNOT_FOUND;
}
return it - begin();
}
-#endif
+#endif // wxUSE_STL
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
- 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);
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++ )
{
- strLine = buffer[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 )
// skip leading spaces
- for ( pStart = strLine; wxIsspace(*pStart); pStart++ )
+ for ( pStart = buf; wxIsspace(*pStart); pStart++ )
;
// skip blank/comment lines
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
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());
// use binary search because the array is sorted
wxFileConfigEntry *
-wxFileConfigGroup::FindEntry(const wxChar *szName) const
+wxFileConfigGroup::FindEntry(const wxString& name) const
{
size_t i,
lo = 0,
pEntry = m_aEntries[i];
#if wxCONFIG_CASE_SENSITIVE
- res = wxStrcmp(pEntry->Name(), szName);
+ res = pEntry->Name().compare(name);
#else
- res = wxStricmp(pEntry->Name(), szName);
+ res = pEntry->Name().CmpNoCase(name);
#endif
if ( res > 0 )
}
wxFileConfigGroup *
-wxFileConfigGroup::FindSubgroup(const wxChar *szName) const
+wxFileConfigGroup::FindSubgroup(const wxString& name) const
{
size_t i,
lo = 0,
pGroup = m_aSubgroups[i];
#if wxCONFIG_CASE_SENSITIVE
- res = wxStrcmp(pGroup->Name(), szName);
+ res = pGroup->Name().compare(name);
#else
- res = wxStricmp(pGroup->Name(), szName);
+ res = pGroup->Name().CmpNoCase(name);
#endif
if ( res > 0 )
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 true;
}
-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
int CompareEntries(wxFileConfigEntry *p1, wxFileConfigEntry *p2)
{
#if wxCONFIG_CASE_SENSITIVE
- return wxStrcmp(p1->Name(), p2->Name());
+ return p1->Name().compare(p2->Name());
#else
- return wxStricmp(p1->Name(), p2->Name());
+ return p1->Name().CmpNoCase(p2->Name());
#endif
}
int CompareGroups(wxFileConfigGroup *p1, wxFileConfigGroup *p2)
{
#if wxCONFIG_CASE_SENSITIVE
- return wxStrcmp(p1->Name(), p2->Name());
+ return p1->Name().compare(p2->Name());
#else
- return wxStricmp(p1->Name(), p2->Name());
+ return p1->Name().CmpNoCase(p2->Name());
#endif
}
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 );
// 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))
}
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 ( !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;
return NULL;
}
- 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;
-
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]);
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 )
break;
}
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 )
break;
}
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);
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;
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);
return false;
}
else
// 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)
#if wxUSE_UNICODE
- : 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))
#else
- : 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
- 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!"));
#endif
m_pos = 0;
}
-wxStringInputStream::~wxStringInputStream()
-{
-#if wxUSE_UNICODE
- // Note: wx[W]CharBuffer uses malloc()/free()
- free(m_buf);
-#endif
-}
-
// ----------------------------------------------------------------------------
// getlength
// ----------------------------------------------------------------------------
size = sizeMax;
}
- memcpy(buffer, m_buf + m_pos, size);
+ memcpy(buffer, m_buf.data() + m_pos, size);
m_pos += size;
return size;
#ifdef __UNIX__
-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);
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 *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;
}
};
// 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() )
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;
- // 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() )
{
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());
- m2w = iconv_open(nameCS.ToAscii(), cname);
+ m2w = iconv_open(nameCS.ToAscii(), name);
// and check for bytesex ourselves:
if ( m2w != ICONV_T_INVALID )
}
else // we already have ms_wcCharsetName
{
- m2w = iconv_open(ms_wcCharsetName.ToAscii(), cname);
+ m2w = iconv_open(ms_wcCharsetName.ToAscii(), name);
}
if ( ms_wcCharsetName.empty() )
}
else
{
- 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!?"),
- ms_wcCharsetName.c_str(), cname.data());
+ ms_wcCharsetName.c_str(), name);
}
}
}
#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;
}
#endif
// 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
}
#if wxUSE_FONTMAP
- wxMBConv_win32(const wxChar* name)
+ wxMBConv_win32(const char* name)
{
m_CodePage = wxCharsetToCodepage(name);
m_minMBCharWidth = 0;
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);
};
// 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() )
m_deferred = true;
}
-wxCSConv::wxCSConv(const wxChar *charset)
+wxCSConv::wxCSConv(const wxString& charset)
{
Init();
- if ( charset )
+ if ( !charset.empty() )
{
- SetName(charset);
+ SetName(charset.ToAscii());
}
#if wxUSE_FONTMAP
m_convReal = NULL;
}
-void wxCSConv::SetName(const wxChar *charset)
+void wxCSConv::SetName(const char *charset)
{
if (charset)
{
- m_name = wxStrdup(charset);
+ m_name = strdup(charset);
m_deferred = true;
}
}
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
if ( m_name )
#endif // !wxUSE_FONTMAP
{
- wxString name(m_name);
#if wxUSE_FONTMAP
wxFontEncoding encoding(m_encoding);
#endif
- if ( !name.empty() )
+ if ( m_name )
{
- wxMBConv_iconv *conv = new wxMBConv_iconv(name);
+ wxMBConv_iconv *conv = new wxMBConv_iconv(m_name);
if ( conv->IsOk() )
return conv;
#if wxUSE_FONTMAP
encoding =
- wxFontMapperBase::Get()->CharsetToEncoding(name, false);
+ wxFontMapperBase::Get()->CharsetToEncoding(m_name, false);
#endif // wxUSE_FONTMAP
}
#if wxUSE_FONTMAP
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;
}
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 )
{
- 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;
m_name ? m_name
:
#if wxUSE_FONTMAP
- (const wxChar*)wxFontMapperBase::GetEncodingDescription(m_encoding).c_str()
+ (const char*)wxFontMapperBase::GetEncodingDescription(m_encoding).ToAscii()
#else // !wxUSE_FONTMAP
- (const wxChar*)wxString::Format(_("encoding %i"), m_encoding).c_str()
+ (const char*)wxString::Format(_("encoding %i"), m_encoding).ToAscii()
#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP
);
}
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++)
{
- 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;
}
-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++)
- if (wxStrcmp(*p, protocol) == 0)
+ if (protocol == *p)
return true;
return false;
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');
}
#if wxUSE_UNICODE
- 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() );
if (m_fields)
Clear();
- return Parse(uri);
+ // 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
// ---------------------------------------------------------------------------
-const wxChar* wxURI::Parse(const wxChar* uri)
+const wxChar* wxURI::Parse(const wxChar *uri)
{
uri = ParseScheme(uri);
uri = ParseAuthority(uri);
// Individual parsers for each URI component
// ---------------------------------------------------------------------------
-const wxChar* wxURI::ParseScheme(const wxChar* uri)
+const wxChar* wxURI::ParseScheme(const wxChar *uri)
{
wxASSERT(uri != NULL);
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));
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 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));
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);
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);
return IsOk();
}
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);
{
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());
}
}
else
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();
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);
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();
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;
{
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 );
{
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());
}
}
else
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();
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();
static wxString wxReplaceUnderscore( const wxString& title )
{
- const wxChar *pc;
-
// 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;
str << *pc;
}
- ++pc;
}
// 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();
- 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;
return (long) ret;
}
-extern long wxCharsetToCodepage(const wxChar *name)
+extern long wxCharsetToCodepage(const char *name)
{
// first get the font encoding for this charset
if ( !name )
#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 (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);
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);
{
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);
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);
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
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;
- 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() )
{
//else: repeated spaces
// (shouldn't happen, but it's not that important if it does happen)
- if ( *p == wxT('\0') )
+ if ( p == end )
break;
}
else if ( *p == wxT('.') )
}
// 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('=')),
// 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 =
bool wxGetEnv(const wxString& var, wxString *value)
{
// wxGetenv is defined as getenv()
- wxChar *p = wxGetenv(var);
+ char *p = wxGetenv(var);
if ( !p )
return false;
// 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());
+ wxCSConv conv(name);
char mbBuf[2];
wchar_t wcBuf[10];
size_t i;
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;
// 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?
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("'");
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;
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
);
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
);
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
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
);
#endif
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
);
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_iconv,
sizeof(welcome_utf7_iconv),
- &wxConvUTF7,
+ wxConvUTF7,
1
);
TestDecoder
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_wx,
sizeof(welcome_utf7_wx),
- &wxConvUTF7,
+ wxConvUTF7,
1
);
#if 0
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_iconv,
sizeof(welcome_utf7_iconv),
- &wxConvUTF7,
+ wxConvUTF7,
1
);
#endif
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf7_wx,
sizeof(welcome_utf7_wx),
- &wxConvUTF7,
+ wxConvUTF7,
1
);
}
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf8,
sizeof(welcome_utf8),
- &wxConvUTF8,
+ wxConvUTF8,
1
);
TestEncoder
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf8,
sizeof(welcome_utf8),
- &wxConvUTF8,
+ wxConvUTF8,
1
);
}
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16le,
sizeof(welcome_utf16le),
- &convUTF16LE,
+ convUTF16LE,
2
);
TestEncoder
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16le,
sizeof(welcome_utf16le),
- &convUTF16LE,
+ convUTF16LE,
2
);
}
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16be,
sizeof(welcome_utf16be),
- &convUTF16BE,
+ convUTF16BE,
2
);
TestEncoder
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf16be,
sizeof(welcome_utf16be),
- &convUTF16BE,
+ convUTF16BE,
2
);
}
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32le,
sizeof(welcome_utf32le),
- &convUTF32LE,
+ convUTF32LE,
4
);
TestEncoder
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32le,
sizeof(welcome_utf32le),
- &convUTF32LE,
+ convUTF32LE,
4
);
}
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32be,
sizeof(welcome_utf32be),
- &convUTF32BE,
+ convUTF32BE,
4
);
TestEncoder
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_utf32be,
sizeof(welcome_utf32be),
- &convUTF32BE,
+ convUTF32BE,
4
);
}
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_cp932,
sizeof(welcome_cp932),
- &convCP932,
+ convCP932,
1
);
TestEncoder
sizeof(welcome_wchar_t)/sizeof(wchar_t),
(const char*)welcome_cp932,
sizeof(welcome_cp932),
- &convCP932,
+ convCP932,
1
);
}
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
)
{
}
-WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const wxChar* name );
+WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_wxwin( const char* name );
void MBConvTestCase::FontmapTests()
{
#ifdef wxUSE_FONTMAP
- wxMBConv* converter = new_wxMBConv_wxwin( _T("CP1252") );
+ wxMBConv* converter = new_wxMBConv_wxwin("CP1252");
if ( !converter )
{
return;
sizeof(CP1252),
(const char*)CP1252_utf8,
sizeof(CP1252_utf8),
- converter,
+ *converter,
1
);
delete converter;
}
-WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const wxChar* name );
+WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_iconv( const char* name );
void MBConvTestCase::IconvTests()
{
#ifdef HAVE_ICONV
- wxMBConv* converter = new_wxMBConv_iconv( _T("CP932") );
+ wxMBConv* converter = new_wxMBConv_iconv("CP932");
if ( !converter )
{
return;
sizeof(welcome_cp932),
(const char*)welcome_utf8,
sizeof(welcome_utf8),
- converter,
+ *converter,
1
);
delete converter;
sizeof(CP1252),
(const char*)CP1252_utf8,
sizeof(CP1252_utf8),
- &convCP1252,
+ convCP1252,
1
);
}
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
)
{
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(),
wxWCharBuffer outputBuffer(outputBufferChars);
memset( outputBuffer.data(), UNINITIALIZED, outputBufferChars*sizeof(wchar_t) );
- outputWritten = converter->MB2WC
+ outputWritten = converter.MB2WC
(
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"
- 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
)
{
inputCopy.data()[wideChars] = 0;
// calculate the output size
- size_t outputWritten = converter->WC2MB
+ size_t outputWritten = converter.WC2MB
(
0,
(const wchar_t*)inputCopy.data(),
wxCharBuffer outputBuffer(outputBufferSize);
memset( outputBuffer.data(), UNINITIALIZED, outputBufferSize );
- outputWritten = converter->WC2MB
+ outputWritten = converter.WC2MB
(
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"
- 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 );
- wxTextInputStream textInputStream( memoryInputStream, wxT(""), *converter );
+ wxTextInputStream textInputStream( memoryInputStream, wxT(""), converter );
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"
- 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
// (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] );
//
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() ) {
// noop
case '-': break;