first phase of transition to unified Unicode build:

1. changed c_str() to return wxCStrData (implicitly convertible to wxChar*)
2. added template type-safe wrappers for vararg functions
3. added wxUniChar class representing single Unicode character
4. changed wxString::operator[] and wxString::iterator to return wxUniChar


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44865 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-03-17 10:26:10 +00:00
parent cd632a8617
commit c9f7896861
80 changed files with 2229 additions and 435 deletions

View File

@@ -109,26 +109,29 @@ const wxChar* wxURI::Create(const wxString& uri)
// Unescape unencodes all 3 character URL escape sequences in a wxString
// ---------------------------------------------------------------------------
wxChar wxURI::TranslateEscape(const wxChar* s)
wxUniChar wxURI::TranslateEscape(const wxString::const_iterator& s)
{
wxASSERT_MSG( IsHex(s[0]) && IsHex(s[1]), wxT("Invalid escape sequence!"));
wxChar c1(*s);
wxChar c2(*(s + 1));
return wx_truncate_cast(wxChar, (CharToHex(s[0]) << 4 ) | CharToHex(s[1]));
wxASSERT_MSG( IsHex(c1) && IsHex(c2), wxT("Invalid escape sequence!"));
return wx_truncate_cast(wxChar, (CharToHex(c1) << 4 ) | CharToHex(c2));
}
wxString wxURI::Unescape(const wxString& uri)
{
wxString new_uri;
for(size_t i = 0; i < uri.length(); ++i)
for (wxString::const_iterator i = uri.begin(); i != uri.end(); ++i)
{
if (uri[i] == wxT('%'))
if ( *i == wxT('%') )
{
new_uri += wxURI::TranslateEscape( &(uri.c_str()[i+1]) );
new_uri += wxURI::TranslateEscape(i + 1);
i += 2;
}
else
new_uri += uri[i];
new_uri += *i;
}
return new_uri;
@@ -870,18 +873,18 @@ void wxURI::Resolve(const wxURI& base, int flags)
if (m_path[0u] != wxT('/'))
{
//Merge paths
const wxChar* op = m_path.c_str();
const wxChar* bp = base.m_path.c_str() + base.m_path.Length();
wxString::const_iterator op = m_path.begin();
wxString::const_iterator bp = base.m_path.begin() + base.m_path.length();
//not a ending directory? move up
if (base.m_path[0] && *(bp-1) != wxT('/'))
UpTree(base.m_path, bp);
UpTree(base.m_path.begin(), bp);
//normalize directories
while(*op == wxT('.') && *(op+1) == wxT('.') &&
(*(op+2) == '\0' || *(op+2) == wxT('/')) )
{
UpTree(base.m_path, bp);
UpTree(base.m_path.begin(), bp);
if (*(op+2) == '\0')
op += 2;
@@ -889,8 +892,8 @@ void wxURI::Resolve(const wxURI& base, int flags)
op += 3;
}
m_path = base.m_path.substr(0, bp - base.m_path.c_str()) +
m_path.substr((op - m_path.c_str()), m_path.Length());
m_path = base.m_path.substr(0, bp - base.m_path.begin()) +
m_path.substr((op - m_path.begin()), m_path.length());
}
}
@@ -904,7 +907,8 @@ void wxURI::Resolve(const wxURI& base, int flags)
// ---------------------------------------------------------------------------
//static
void wxURI::UpTree(const wxChar* uristart, const wxChar*& uri)
void wxURI::UpTree(wxString::const_iterator uristart,
wxString::const_iterator& uri)
{
if (uri != uristart && *(uri-1) == wxT('/'))
{
@@ -926,6 +930,30 @@ void wxURI::UpTree(const wxChar* uristart, const wxChar*& uri)
//!!!//
}
// FIXME-UTF8: fix Normalize() to use iterators instead of having this method!
/*static*/ void wxURI::UpTree(const wxChar* uristart, const wxChar*& uri)
{
if (uri != uristart && *(uri-1) == wxT('/'))
{
uri -= 2;
}
for(;uri != uristart; --uri)
{
if (*uri == wxT('/'))
{
++uri;
break;
}
}
//!!!TODO:HACK!!!//
if (uri == uristart && *uri == wxT('/'))
++uri;
//!!!//
}
// end of FIXME-UTF8
// ---------------------------------------------------------------------------
// Normalize
//