forked from 0ad/0ad
fixed wchar_t issues; now correctly separates utf16, CStrW and jschar.
NOTE: wchar_t should be defined as a built-in type; no more need to define manually or change project settings. adts: disambiguate iterator type; add operator- as required by VC8 std::equal() implementation precompiled: squelch stupid warning (that informs us that array members are now actually default-initialized as called for by C++) file_cache: remove debug variable This was SVN commit r3464.
This commit is contained in:
parent
41f08eecb8
commit
987a6b7d4e
@ -48,7 +48,7 @@ namespace I18n
|
||||
}
|
||||
|
||||
// On non-MSVC, or on MSVC with a native wchar_t type, define jschar separately
|
||||
#if !MSC_VERSION || !defined(_WCHAR_T_DEFINED)
|
||||
#if !MSC_VERSION || defined(_NATIVE_WCHAR_T_DEFINED)
|
||||
StrImW(const jschar* s)
|
||||
{
|
||||
ref = new strImW_data;
|
||||
|
@ -76,7 +76,8 @@ static void test_ringbuf()
|
||||
}
|
||||
}
|
||||
TEST(buf.size() == deq.size());
|
||||
TEST(equal(buf.begin(), buf.end(), deq.begin()));
|
||||
RingBuf<int, N>::iterator begin = buf.begin(), end = buf.end();
|
||||
TEST(equal(begin, end, deq.begin()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -501,7 +501,7 @@ public:
|
||||
debug_warn("underflow");
|
||||
}
|
||||
|
||||
|
||||
#include <vector>
|
||||
class iterator
|
||||
{
|
||||
public:
|
||||
@ -512,25 +512,35 @@ public:
|
||||
typedef T& reference;
|
||||
|
||||
iterator() : data(0), pos(0)
|
||||
{}
|
||||
{}
|
||||
iterator(T* data_, size_t pos_) : data(data_), pos(pos_)
|
||||
{}
|
||||
{}
|
||||
T& operator[](int idx) const
|
||||
{ return data[(pos+idx) % n]; }
|
||||
{ return data[(pos+idx) % n]; }
|
||||
T& operator*() const
|
||||
{ return data[pos % n]; }
|
||||
{ return data[pos % n]; }
|
||||
T* operator->() const
|
||||
{ return &**this; }
|
||||
{ return &**this; }
|
||||
iterator& operator++() // pre
|
||||
{ ++pos; return (*this); }
|
||||
{ ++pos; return (*this); }
|
||||
iterator operator++(int) // post
|
||||
{ iterator tmp = *this; ++*this; return tmp; }
|
||||
{ iterator tmp = *this; ++*this; return tmp; }
|
||||
bool operator==(const iterator& rhs) const
|
||||
{ return data == rhs.data && pos == rhs.pos; }
|
||||
{ return data == rhs.data && pos == rhs.pos; }
|
||||
bool operator!=(const iterator& rhs) const
|
||||
{ return !(*this == rhs); }
|
||||
{ return !(*this == rhs); }
|
||||
bool operator<(const iterator& rhs) const
|
||||
{ return (pos < rhs.pos); }
|
||||
{ return (pos < rhs.pos); }
|
||||
iterator& operator+=(difference_type ofs)
|
||||
{ pos += ofs; return *this; }
|
||||
iterator& operator-=(difference_type ofs)
|
||||
{ return (*this += -ofs); }
|
||||
iterator operator+(difference_type ofs) const
|
||||
{ iterator tmp = *this; return (tmp += ofs); }
|
||||
iterator operator-(difference_type ofs) const
|
||||
{ iterator tmp = *this; return (tmp -= ofs); }
|
||||
difference_type operator-(const iterator right) const
|
||||
{ return (difference_type)(pos - right.pos); }
|
||||
|
||||
protected:
|
||||
T* data;
|
||||
@ -567,6 +577,16 @@ public:
|
||||
{ return !(*this == rhs); }
|
||||
bool operator<(const const_iterator& rhs) const
|
||||
{ return (pos < rhs.pos); }
|
||||
iterator& operator+=(difference_type ofs)
|
||||
{ pos += ofs; return *this; }
|
||||
iterator& operator-=(difference_type ofs)
|
||||
{ return (*this += -ofs); }
|
||||
iterator operator+(difference_type ofs) const
|
||||
{ iterator tmp = *this; return (tmp += ofs); }
|
||||
iterator operator-(difference_type ofs) const
|
||||
{ iterator tmp = *this; return (tmp -= ofs); }
|
||||
difference_type operator-(const iterator right) const
|
||||
{ return (difference_type)(pos - right.pos); }
|
||||
|
||||
protected:
|
||||
const T* data;
|
||||
|
@ -21,6 +21,7 @@
|
||||
# pragma warning(disable:4127) // conditional expression is constant; rationale: see STMT in lib.h.
|
||||
# pragma warning(disable:4996) // function is deprecated
|
||||
# pragma warning(disable:4786) // identifier truncated to 255 chars
|
||||
# pragma warning(disable:4351) // yes, default init of array entries is desired
|
||||
// .. disabled only for the precompiled headers
|
||||
# pragma warning(disable:4702) // unreachable code (frequent in STL)
|
||||
// .. VS2005 code analysis (very frequent ones)
|
||||
|
@ -23,8 +23,6 @@
|
||||
// to remain valid.
|
||||
//
|
||||
|
||||
static uint block_epoch;
|
||||
|
||||
class BlockMgr
|
||||
{
|
||||
static const size_t MAX_BLOCKS = 32;
|
||||
|
@ -92,11 +92,10 @@ public:
|
||||
// Named constructor, to avoid overload overload.
|
||||
static CStr Repeat(CStr String, size_t Reps);
|
||||
|
||||
// CStr(8|W) construction from utf16strings, except on MSVC CStrW where
|
||||
// CStrW === utf16string
|
||||
#if !(MSC_VERSION && defined(_UNICODE))
|
||||
CStr(utf16string String) : std::tstring(String.begin(), String.end()) {}
|
||||
#endif
|
||||
// CStr(8|W) construction from utf16strings.
|
||||
// allowed on MSVC as of 2006-02-03 because utf16string is
|
||||
// now distinct from CStrW.
|
||||
CStr(utf16string String) : std::tstring(String.begin(), String.end()) {}
|
||||
|
||||
// Transparent CStrW/8 conversion. Non-ASCII characters are not
|
||||
// handled correctly.
|
||||
|
@ -5,17 +5,9 @@
|
||||
#ifndef utf16string_H
|
||||
#define utf16string_H
|
||||
|
||||
// On Windows, wchar_t is typedef'ed to unsigned short, which conflicts
|
||||
// with uint16_t (which is also an unsigned short), so just use std::wstring
|
||||
#if MSC_VERSION
|
||||
|
||||
typedef wchar_t utf16_t;
|
||||
typedef std::wstring utf16string;
|
||||
typedef std::wstringstream utf16stringstream;
|
||||
|
||||
// On Linux, wchar_t is 32-bit, so define a new version of it
|
||||
#else
|
||||
|
||||
// On Linux, wchar_t is 32-bit, so define a new version of it.
|
||||
// We now use this code on Windows as well, because wchar_t is a
|
||||
// native type and distinct from utf16_t.
|
||||
#include <string>
|
||||
#include "lib/types.h"
|
||||
|
||||
@ -100,6 +92,4 @@ namespace std {
|
||||
};
|
||||
}
|
||||
|
||||
#endif // #if MSC_VERSION / #else
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user