projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
introduced wxICON_DEFAULT_TYPE and wxBITMAP_DEFAULT_TYPE; documented these default...
[wxWidgets.git]
/
include
/
wx
/
stringops.h
diff --git
a/include/wx/stringops.h
b/include/wx/stringops.h
index 972b8327171a6b60afc08cb0738645bc689bcbf5..50aa1376ac30215f5c204395122c5b1d440e0416 100644
(file)
--- a/
include/wx/stringops.h
+++ b/
include/wx/stringops.h
@@
-15,6
+15,7
@@
#include "wx/chartype.h"
#include "wx/stringimpl.h"
#include "wx/unichar.h"
#include "wx/chartype.h"
#include "wx/stringimpl.h"
#include "wx/unichar.h"
+#include "wx/buffer.h"
// This header contains wxStringOperations "namespace" class that implements
// elementary operations on string data as static methods; wxString methods and
// This header contains wxStringOperations "namespace" class that implements
// elementary operations on string data as static methods; wxString methods and
@@
-35,19
+36,17
@@
struct WXDLLIMPEXP_BASE wxStringOperationsWchar
static void DecIter(wxStringImpl::const_iterator& i) { --i; }
// moves the iterator by n Unicode characters
static void DecIter(wxStringImpl::const_iterator& i) { --i; }
// moves the iterator by n Unicode characters
- static wxStringImpl::iterator AddToIter(const wxStringImpl::iterator& i,
in
t n)
+ static wxStringImpl::iterator AddToIter(const wxStringImpl::iterator& i,
ptrdiff_
t n)
{ return i + n; }
{ return i + n; }
- static wxStringImpl::const_iterator AddToIter(const wxStringImpl::const_iterator& i, int n)
- { return i + n; }
- static const wxChar* AddToIter(const wxChar *i, int n)
+ static wxStringImpl::const_iterator AddToIter(const wxStringImpl::const_iterator& i, ptrdiff_t n)
{ return i + n; }
// returns distance of the two iterators in Unicode characters
{ return i + n; }
// returns distance of the two iterators in Unicode characters
- static
in
t DiffIters(const wxStringImpl::iterator& i1,
- const wxStringImpl::iterator& i2)
+ static
ptrdiff_
t DiffIters(const wxStringImpl::iterator& i1,
+
const wxStringImpl::iterator& i2)
{ return i1 - i2; }
{ return i1 - i2; }
- static
in
t DiffIters(const wxStringImpl::const_iterator& i1,
- const wxStringImpl::const_iterator& i2)
+ static
ptrdiff_
t DiffIters(const wxStringImpl::const_iterator& i1,
+
const wxStringImpl::const_iterator& i2)
{ return i1 - i2; }
// encodes the character to a form used to represent it in internal
{ return i1 - i2; }
// encodes the character to a form used to represent it in internal
@@
-64,13
+63,14
@@
struct WXDLLIMPEXP_BASE wxStringOperationsWchar
struct WXDLLIMPEXP_BASE wxStringOperationsUtf8
{
// checks correctness of UTF-8 sequence
struct WXDLLIMPEXP_BASE wxStringOperationsUtf8
{
// checks correctness of UTF-8 sequence
- static bool IsValidUtf8String(const char *c);
+ static bool IsValidUtf8String(const char *c,
+ size_t len = wxStringImpl::npos);
#ifdef __WXDEBUG__
static bool IsValidUtf8LeadByte(unsigned char c);
#endif
// table of offsets to skip forward when iterating over UTF-8 sequence
#ifdef __WXDEBUG__
static bool IsValidUtf8LeadByte(unsigned char c);
#endif
// table of offsets to skip forward when iterating over UTF-8 sequence
- static unsigned char ms_utf8IterTable[256];
+ static
const
unsigned char ms_utf8IterTable[256];
template<typename Iterator>
template<typename Iterator>
@@
-97,18
+97,18
@@
struct WXDLLIMPEXP_BASE wxStringOperationsUtf8
}
template<typename Iterator>
}
template<typename Iterator>
- static Iterator AddToIter(const Iterator& i,
in
t n)
+ static Iterator AddToIter(const Iterator& i,
ptrdiff_
t n)
{
Iterator out(i);
if ( n > 0 )
{
{
Iterator out(i);
if ( n > 0 )
{
- for (
in
t j = 0; j < n; ++j )
+ for (
ptrdiff_
t j = 0; j < n; ++j )
IncIter(out);
}
else if ( n < 0 )
{
IncIter(out);
}
else if ( n < 0 )
{
- for (
in
t j = 0; j > n; --j )
+ for (
ptrdiff_
t j = 0; j > n; --j )
DecIter(out);
}
DecIter(out);
}
@@
-116,9
+116,9
@@
struct WXDLLIMPEXP_BASE wxStringOperationsUtf8
}
template<typename Iterator>
}
template<typename Iterator>
- static
in
t DiffIters(Iterator i1, Iterator i2)
+ static
ptrdiff_
t DiffIters(Iterator i1, Iterator i2)
{
{
-
in
t dist = 0;
+
ptrdiff_
t dist = 0;
if ( i1 < i2 )
{
if ( i1 < i2 )
{
@@
-140,15
+140,10
@@
struct WXDLLIMPEXP_BASE wxStringOperationsUtf8
return dist;
}
return dist;
}
- // buffer for single UTF-8 character
- struct Utf8CharBuffer
- {
- char data[5];
- operator const char*() const { return data; }
- };
-
// encodes the character as UTF-8:
// encodes the character as UTF-8:
- static Utf8CharBuffer EncodeChar(const wxUniChar& ch);
+ typedef wxUniChar::Utf8CharBuffer Utf8CharBuffer;
+ static Utf8CharBuffer EncodeChar(const wxUniChar& ch)
+ { return ch.AsUTF8(); }
// returns n copies of ch encoded in UTF-8 string
static wxCharBuffer EncodeNChars(size_t n, const wxUniChar& ch);
// returns n copies of ch encoded in UTF-8 string
static wxCharBuffer EncodeNChars(size_t n, const wxUniChar& ch);
@@
-161,7
+156,15
@@
struct WXDLLIMPEXP_BASE wxStringOperationsUtf8
}
// decodes single UTF-8 character from UTF-8 string
}
// decodes single UTF-8 character from UTF-8 string
- static wxUniChar DecodeChar(wxStringImpl::const_iterator i);
+ static wxUniChar DecodeChar(wxStringImpl::const_iterator i)
+ {
+ if ( (unsigned char)*i < 0x80 )
+ return (int)*i;
+ return DecodeNonAsciiChar(i);
+ }
+
+private:
+ static wxUniChar DecodeNonAsciiChar(wxStringImpl::const_iterator i);
};
#endif // wxUSE_UNICODE_UTF8
};
#endif // wxUSE_UNICODE_UTF8