mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-02 04:22:34 +02:00
Remove String::Stream and with it the locale hacks.
Also fixes the crash when compiled with -O
This commit is contained in:
@@ -437,135 +437,3 @@ String::Split String::SplitFloat(double &value, size_t pos, std::ios_base::fmtfl
|
|||||||
LocaleImpl.FlushWStream();
|
LocaleImpl.FlushWStream();
|
||||||
return split;
|
return split;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> std::ctype<char32_t>::~ctype()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
template<> std::numpunct<char32_t>::numpunct(size_t ref): std::locale::facet(ref)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
template<> std::numpunct<char32_t>::~numpunct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct Locale32Impl
|
|
||||||
{
|
|
||||||
std::ctype<wchar_t> const &ctype16;
|
|
||||||
std::numpunct<wchar_t> const &numpunct16;
|
|
||||||
Locale32Impl():
|
|
||||||
ctype16(std::use_facet<std::ctype<wchar_t> >(std::locale())),
|
|
||||||
numpunct16(std::use_facet<std::numpunct<wchar_t> >(std::locale()))
|
|
||||||
{
|
|
||||||
std::locale::global(std::locale(std::locale(), new std::ctype<char32_t>()));
|
|
||||||
std::locale::global(std::locale(std::locale(), new std::numpunct<char32_t>()));
|
|
||||||
std::locale::global(std::locale(std::locale(), new std::num_put<char32_t>()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Locale32Impl;
|
|
||||||
|
|
||||||
template<> bool std::ctype<char32_t>::do_is(mask m, char32_t ch) const
|
|
||||||
{
|
|
||||||
return ch <= 0xFFFF ? Locale32Impl.ctype16.is(m, ch) : (m & print);
|
|
||||||
}
|
|
||||||
template<> char32_t const *std::ctype<char32_t>::do_is(char32_t const *low, char32_t const *high, mask *vec) const
|
|
||||||
{
|
|
||||||
while(low < high)
|
|
||||||
{
|
|
||||||
if(*low <= 0xFFFF)
|
|
||||||
{
|
|
||||||
wchar_t l = *low;
|
|
||||||
Locale32Impl.ctype16.is(&l, &l + 1, vec);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*vec = print;
|
|
||||||
low++;
|
|
||||||
}
|
|
||||||
return high;
|
|
||||||
}
|
|
||||||
template<> char32_t const *std::ctype<char32_t>::do_scan_is(mask m, char32_t const *beg, char32_t const *end) const
|
|
||||||
{
|
|
||||||
while(beg < end)
|
|
||||||
if(do_is(m, *beg))
|
|
||||||
return beg;
|
|
||||||
else
|
|
||||||
beg++;
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
template<> char32_t const *std::ctype<char32_t>::do_scan_not(mask m, char32_t const *beg, char32_t const *end) const
|
|
||||||
{
|
|
||||||
while(beg < end)
|
|
||||||
if(!do_is(m, *beg))
|
|
||||||
return beg;
|
|
||||||
else
|
|
||||||
beg++;
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
template<> char32_t std::ctype<char32_t>::do_toupper(char32_t ch) const
|
|
||||||
{
|
|
||||||
return ch <= 0xFFFF ? Locale32Impl.ctype16.toupper(ch) : ch;
|
|
||||||
}
|
|
||||||
template<> char32_t const *std::ctype<char32_t>::do_toupper(char32_t *beg, char32_t const *end) const
|
|
||||||
{
|
|
||||||
while(beg < end)
|
|
||||||
{
|
|
||||||
*beg = do_toupper(*beg);
|
|
||||||
beg++;
|
|
||||||
}
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
template<> char32_t std::ctype<char32_t>::do_tolower(char32_t ch) const
|
|
||||||
{
|
|
||||||
return ch <= 0xFFFF ? Locale32Impl.ctype16.tolower(ch) : ch;
|
|
||||||
}
|
|
||||||
template<> char32_t const *std::ctype<char32_t>::do_tolower(char32_t *beg, char32_t const *end) const
|
|
||||||
{
|
|
||||||
while(beg < end)
|
|
||||||
{
|
|
||||||
*beg = do_tolower(*beg);
|
|
||||||
beg++;
|
|
||||||
}
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
template<> char32_t std::ctype<char32_t>::do_widen(char ch) const
|
|
||||||
{
|
|
||||||
return Locale32Impl.ctype16.widen(ch);
|
|
||||||
}
|
|
||||||
template<> char const *std::ctype<char32_t>::do_widen(char const *beg, char const *end, char32_t *dst) const
|
|
||||||
{
|
|
||||||
while(beg < end)
|
|
||||||
*(dst++) = do_widen(*(beg++));
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
template<> char std::ctype<char32_t>::do_narrow(char32_t ch, char dflt) const
|
|
||||||
{
|
|
||||||
return ch <= 0xFFFF ? Locale32Impl.ctype16.narrow(ch, dflt) : dflt;
|
|
||||||
}
|
|
||||||
template<> char32_t const *std::ctype<char32_t>::do_narrow(char32_t const *beg, char32_t const *end, char dflt, char *dst) const
|
|
||||||
{
|
|
||||||
while(beg < end)
|
|
||||||
*(dst++) = do_narrow(*(beg++), dflt);
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<> char32_t std::numpunct<char32_t>::do_decimal_point() const
|
|
||||||
{
|
|
||||||
return Locale32Impl.numpunct16.decimal_point();
|
|
||||||
}
|
|
||||||
template<> char32_t std::numpunct<char32_t>::do_thousands_sep() const
|
|
||||||
{
|
|
||||||
return Locale32Impl.numpunct16.thousands_sep();
|
|
||||||
}
|
|
||||||
template<> std::string std::numpunct<char32_t>::do_grouping() const
|
|
||||||
{
|
|
||||||
return Locale32Impl.numpunct16.grouping();
|
|
||||||
}
|
|
||||||
template<> std::basic_string<char32_t> std::numpunct<char32_t>::do_truename() const
|
|
||||||
{
|
|
||||||
std::basic_string<wchar_t> name = Locale32Impl.numpunct16.truename();
|
|
||||||
return std::basic_string<char32_t>(name.begin(), name.end());
|
|
||||||
}
|
|
||||||
template<> std::basic_string<char32_t> std::numpunct<char32_t>::do_falsename() const
|
|
||||||
{
|
|
||||||
std::basic_string<wchar_t> name = Locale32Impl.numpunct16.falsename();
|
|
||||||
return std::basic_string<char32_t>(name.begin(), name.end());
|
|
||||||
}
|
|
||||||
|
@@ -259,8 +259,6 @@ public:
|
|||||||
ByteString ToUtf8() const;
|
ByteString ToUtf8() const;
|
||||||
ByteString ToAscii() const;
|
ByteString ToAscii() const;
|
||||||
template<typename... Ts> static String Build(Ts&&... args);
|
template<typename... Ts> static String Build(Ts&&... args);
|
||||||
|
|
||||||
using Stream = std::basic_stringstream<value_type>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline String operator+(String const &lhs, String const &rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) + static_cast<std::basic_string<char32_t> const &>(rhs); }
|
inline String operator+(String const &lhs, String const &rhs) { return static_cast<std::basic_string<char32_t> const &>(lhs) + static_cast<std::basic_string<char32_t> const &>(rhs); }
|
||||||
|
Reference in New Issue
Block a user