|
|
|
@ -72,16 +72,14 @@ public:
|
|
|
|
|
public:
|
|
|
|
|
inline void operator++()
|
|
|
|
|
{
|
|
|
|
|
m_Char = m_View.m_Iterator(&m_Addr);
|
|
|
|
|
if ((ptrdiff_t)m_Addr > ((ptrdiff_t)m_View.m_Str + m_View.m_Size))
|
|
|
|
|
{
|
|
|
|
|
m_Addr = 0;
|
|
|
|
|
m_Char = 0;
|
|
|
|
|
}
|
|
|
|
|
if ((ptrdiff_t)m_Next > ((ptrdiff_t)m_View.m_Str + m_View.m_Size))
|
|
|
|
|
m_Next = (void *)((ptrdiff_t)m_View.m_Str + m_View.m_Size);
|
|
|
|
|
m_Addr = m_Next;
|
|
|
|
|
m_Char = m_View.m_Iterator(&m_Next);
|
|
|
|
|
}
|
|
|
|
|
inline void operator+=(ptrdiff_t a)
|
|
|
|
|
{
|
|
|
|
|
while (m_Addr)
|
|
|
|
|
while ((ptrdiff_t)m_Addr < ((ptrdiff_t)m_View.m_Str + m_View.m_Size))
|
|
|
|
|
{
|
|
|
|
|
++(*this);
|
|
|
|
|
}
|
|
|
|
@ -93,7 +91,7 @@ public:
|
|
|
|
|
|
|
|
|
|
const_iterator &operator=(const const_iterator &other)
|
|
|
|
|
{
|
|
|
|
|
if(this == &other) return *this;
|
|
|
|
|
if (this == &other) return *this;
|
|
|
|
|
this->~const_iterator();
|
|
|
|
|
return *new(this) const_iterator(other);
|
|
|
|
|
}
|
|
|
|
@ -101,23 +99,22 @@ public:
|
|
|
|
|
const void *ptr() const { return m_Addr; }
|
|
|
|
|
private:
|
|
|
|
|
friend class CUtfStringView;
|
|
|
|
|
inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Char(addr ? view.m_Iterator(&m_Addr) : 0)
|
|
|
|
|
inline const_iterator(const CUtfStringView &view, const void *addr) : m_View(view), m_Addr(addr), m_Next(addr), m_Char(view.m_Iterator(&m_Next))
|
|
|
|
|
{
|
|
|
|
|
if ((ptrdiff_t)m_Addr > ((ptrdiff_t)m_View.m_Str + m_View.m_Size))
|
|
|
|
|
{
|
|
|
|
|
m_Addr = 0;
|
|
|
|
|
m_Char = 0;
|
|
|
|
|
}
|
|
|
|
|
if ((ptrdiff_t)m_Next > ((ptrdiff_t)m_View.m_Str + m_View.m_Size))
|
|
|
|
|
m_Next = (void *)((ptrdiff_t)m_View.m_Str + m_View.m_Size);
|
|
|
|
|
}
|
|
|
|
|
inline const_iterator(const CUtfStringView &view) : m_View(view), m_Addr((char *)view.m_Str + view.m_Size), m_Next((char *)view.m_Str + view.m_Size + 1), m_Char(0) { }
|
|
|
|
|
const CUtfStringView &m_View;
|
|
|
|
|
const void *m_Addr; // Next address
|
|
|
|
|
const void *m_Addr; // Current address
|
|
|
|
|
const void *m_Next; // Next address
|
|
|
|
|
u32char m_Char;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef const_iterator iterator;
|
|
|
|
|
|
|
|
|
|
iterator begin() const { return iterator(*this, m_Str); }
|
|
|
|
|
inline iterator end() const { return iterator(*this, NULL); }
|
|
|
|
|
inline iterator end() const { return iterator(*this); }
|
|
|
|
|
|
|
|
|
|
/// Largest possible number of characters in this string.
|
|
|
|
|
/// Number of actual characters may be less or equal.
|
|
|
|
|