24 #ifndef __UTF16TextCharTraits__ 25 #define __UTF16TextCharTraits__ 27 #if defined(WINDOWS) || defined(__GLIBCXX__) 28 #error This file is only for Mac libc++ 31 #if !defined(_LIBCPP_VERSION) 32 #error This file is only for Mac libc++ 42 struct char_traits<UTF16TextChar>
44 typedef UTF16TextChar char_type;
45 typedef unsigned short int_type;
46 typedef streampos pos_type;
47 typedef streamoff off_type;
48 typedef mbstate_t state_type;
51 assign(char_type& c1,
const char_type& c2)
55 eq(
const char_type& c1,
const char_type& c2)
59 lt(
const char_type& c1,
const char_type& c2)
64 compare(
const char_type* s1,
const char_type* s2,
size_t n)
66 for (
size_t i = 0; i < n; ++i)
70 else if (lt(s2[i], s1[i]))
77 length(
const char_type* s)
80 while (!eq(s[n], char_type()))
86 static const char_type*
87 find(
const char_type* s,
size_t n,
const char_type& a)
89 for (
size_t i = 0; i < n; ++i)
98 move(char_type* s1,
const char_type* s2,
size_t n)
102 for (
size_t i = 0; i < n; ++i)
103 assign(s1[n - i - 1], s2[n - i - 1]);
107 for (
size_t i = 0; i < n; ++i)
108 assign(s1[i], s2[i]);
114 copy(char_type* s1,
const char_type* s2,
size_t n)
116 for (
size_t i = 0; i < n; ++i)
117 assign(s1[i], s2[i]);
122 assign(char_type* s,
size_t n, char_type a)
124 for (
size_t i = 0; i < n; ++i)
130 not_eof(
const int_type& c)
132 if (eq_int_type(c, eof()))
138 to_char_type(
const int_type& c)
146 to_int_type(
const char_type& c)
152 eq_int_type(
const int_type& c1,
const int_type& c2)
157 eof() {
return static_cast<int_type
>(WEOF); }
162 class __attribute__((visibility("default"))) ctype<UTF16TextChar> :
public locale::facet,
public ctype_base
165 typedef UTF16TextChar char_type;
167 explicit ctype(
size_t refs = 0): locale::facet(refs) { }
178 bool is(mask m, char_type c)
const 179 {
return this->do_is(m,c); }
193 const char_type* is(
const char_type* low,
const char_type* high, mask* vec)
const 195 return this->do_is(low,high,vec);
209 const char_type* scan_is(mask m,
const char_type* low,
const char_type* high)
const 210 {
return this->do_scan_is(m,low,high);}
223 const char_type* scan_not(mask m,
const char_type* low,
const char_type* high)
const 224 {
return this->do_scan_not(m,low,high);}
235 char_type toupper(char_type c)
const 236 {
return this->do_toupper(c); }
248 const char_type* toupper(char_type* low,
const char_type* high)
const 249 {
return this->do_toupper(low, high); }
260 char_type tolower(char_type c)
const 261 {
return this->do_tolower(c); }
273 const char_type* tolower(char_type* low,
const char_type* high)
const 274 {
return this->do_tolower(low, high); }
289 char_type widen(
char c)
const 290 {
return this->do_widen(c); }
307 const char* widen(
const char* low,
const char* high, char_type* to)
const 308 {
return this->do_widen(low, high, to); }
325 char narrow(char_type c,
char dfault)
const 326 {
return this->do_narrow(c, dfault); }
346 const char_type* narrow(
const char_type* low,
const char_type* high,
char dfault,
char* to)
const 347 {
return this->do_narrow(low, high, dfault, to); }
349 static locale::id id;
354 virtual bool do_is(mask m, char_type c)
const;
356 virtual const char_type* do_is(
const char_type* low,
const char_type* high, mask* vec)
const;
358 virtual const char_type* do_scan_is(mask m,
const char_type* low,
const char_type* high)
const;
360 virtual const char_type* do_scan_not(mask m,
const char_type* low,
const char_type* high)
const;
362 virtual char_type do_toupper(char_type c)
const;
364 virtual const char_type* do_toupper(char_type* low,
const char_type* high)
const;
366 virtual char_type do_tolower(char_type c)
const;
368 virtual const char_type* do_tolower(char_type* low,
const char_type* high)
const;
370 virtual char_type do_widen(
char c)
const;
372 virtual const char* do_widen(
const char* low,
const char* high, char_type* dest)
const;
374 virtual char do_narrow(char_type,
char dfault)
const;
376 virtual const char_type* do_narrow(
const char_type* low,
const char_type* high,
377 char dfault,
char* dest)
const;
381 extern template class std::basic_string<UTF16TextChar>;
386 :
public locale::facet
389 typedef UTF16TextChar char_type;
390 typedef basic_string<char_type> string_type;
392 explicit numpunct(
size_t __refs = 0);
394 char_type decimal_point()
const {
return do_decimal_point();}
395 char_type thousands_sep()
const {
return do_thousands_sep();}
396 string grouping()
const {
return do_grouping();}
397 string_type truename()
const {
return do_truename();}
398 string_type falsename()
const {
return do_falsename();}
400 static locale::id id;
404 virtual char_type do_decimal_point()
const;
405 virtual char_type do_thousands_sep()
const;
406 virtual string do_grouping()
const;
407 virtual string_type do_truename()
const;
408 virtual string_type do_falsename()
const;
411 extern template class std::num_get<UTF16TextChar>;
412 extern template class std::num_put<UTF16TextChar>;
414 extern template class std::num_get<UTF16TextChar>;
415 extern template class std::num_put<UTF16TextChar>;
419 class __attribute__((visibility(
"default"))) codecvt<UTF16TextChar,
char, mbstate_t>
420 : public locale::facet,
424 typedef UTF16TextChar intern_type;
425 typedef char extern_type;
426 typedef mbstate_t state_type;
429 explicit codecvt(
size_t __refs = 0)
430 : locale::facet(__refs) {}
433 result out(state_type& __st,
434 const intern_type* __frm,
const intern_type* __frm_end,
const intern_type*& __frm_nxt,
435 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt)
const 437 return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
441 result unshift(state_type& __st,
442 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt)
const 444 return do_unshift(__st, __to, __to_end, __to_nxt);
448 result in(state_type& __st,
449 const extern_type* __frm,
const extern_type* __frm_end,
const extern_type*& __frm_nxt,
450 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt)
const 452 return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
456 int encoding() const _NOEXCEPT
458 return do_encoding();
462 bool always_noconv() const _NOEXCEPT
464 return do_always_noconv();
468 int length(state_type& __st,
const extern_type* __frm,
const extern_type* __end,
size_t __mx)
const 470 return do_length(__st, __frm, __end, __mx);
474 int max_length() const _NOEXCEPT
476 return do_max_length();
479 static locale::id id;
483 explicit codecvt(
const char*,
size_t __refs = 0)
484 : locale::facet(__refs) {}
488 virtual result do_out(state_type& __st,
489 const intern_type* __frm,
const intern_type* __frm_end,
const intern_type*& __frm_nxt,
490 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt)
const;
491 virtual result do_in(state_type& __st,
492 const extern_type* __frm,
const extern_type* __frm_end,
const extern_type*& __frm_nxt,
493 intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt)
const;
494 virtual result do_unshift(state_type& __st,
495 extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt)
const;
496 virtual int do_encoding() const _NOEXCEPT;
497 virtual
bool do_always_noconv() const _NOEXCEPT;
498 virtual
int do_length(state_type&, const extern_type* __frm, const extern_type* __end,
size_t __mx) const;
499 virtual
int do_max_length() const _NOEXCEPT;
504 #endif //__UTF16TextCharTraits__