STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Macros | Enumerations | Functions
xlocale File Reference
#include <climits>
#include <cstring>
#include <stdexcept>
#include <typeinfo>
#include <xlocinfo>
#include <xfacet>

Classes

class  _Locbase< _Dummy >
 
class  collate< _Elem >
 
struct  _Crt_new_delete
 
class  locale
 
class  locale::id
 
class  locale::facet
 
class  locale::_Locimp
 
struct  _Facetptr< _Facet >
 
class  codecvt_base
 
class  codecvt< _Elem, _Byte, _Statype >
 
class  codecvt< char16_t, char, _Mbstatet >
 
class  codecvt< char32_t, char, _Mbstatet >
 
class  codecvt< wchar_t, char, _Mbstatet >
 
class  codecvt_byname< _Elem, _Byte, _Statype >
 
struct  ctype_base
 
class  ctype< _Elem >
 
class  ctype< char >
 
class  ctype< wchar_t >
 
class  ctype_byname< _Elem >
 
class  ctype_byname< char >
 

Macros

#define _XLOCALE_
 
#define _ADDFAC(loc, pfac)   locale(loc, pfac) /* add facet to locale */
 
#define _USE(loc, fac)   use_facet< fac >(loc) /* get facet reference from locale */
 
#define _MAKLOCBYTE(Elem, chr, cvt)   _Maklocbyte((_Elem)chr, cvt) /* convert Elem to char */
 
#define _MAKLOCCHR(Elem, chr, cvt)   _Maklocchr(chr, (Elem *)0, cvt) /* convert char to Elem */
 
#define _MAKLOCSTR(Elem, str, cvt)   _Maklocstr(str, (Elem *)0, cvt) /* convert C string to Elem sequence */
 

Enumerations

enum  _Codecvt_mode { _Consume_header = 4, _Generate_header = 2 }
 

Functions

template<class _Facet >
const _Facet &__CRTDECL use_facet (const locale &)
 
template<class _Elem , class _InIt >
int __CRTDECL _Getloctxt (_InIt &_First, _InIt &_Last, size_t _Numfields, const _Elem *_Ptr)
 
template<class _Elem >
char __CRTDECL _Maklocbyte (_Elem _Char, const _Locinfo::_Cvtvec &)
 
template<>
char __CRTDECL _Maklocbyte (wchar_t _Char, const _Locinfo::_Cvtvec &_Cvt)
 
template<class _Elem >
_Elem __CRTDECL _Maklocchr (char _Byte, _Elem *, const _Locinfo::_Cvtvec &)
 
template<>
wchar_t __CRTDECL _Maklocchr (char _Byte, wchar_t *, const _Locinfo::_Cvtvec &_Cvt)
 
template<class _Elem >
_Elem *__CRTDECL _Maklocstr (const char *_Ptr, _Elem *, const _Locinfo::_Cvtvec &)
 
template<>
wchar_t *__CRTDECL _Maklocstr (const char *_Ptr, wchar_t *, const _Locinfo::_Cvtvec &_Cvt)
 

Macro Definition Documentation

#define _ADDFAC (   loc,
  pfac 
)    locale(loc, pfac) /* add facet to locale */
#define _MAKLOCBYTE (   Elem,
  chr,
  cvt 
)    _Maklocbyte((_Elem)chr, cvt) /* convert Elem to char */
#define _MAKLOCCHR (   Elem,
  chr,
  cvt 
)    _Maklocchr(chr, (Elem *)0, cvt) /* convert char to Elem */
#define _MAKLOCSTR (   Elem,
  str,
  cvt 
)    _Maklocstr(str, (Elem *)0, cvt) /* convert C string to Elem sequence */
#define _USE (   loc,
  fac 
)    use_facet< fac >(loc) /* get facet reference from locale */
#define _XLOCALE_

Enumeration Type Documentation

Enumerator
_Consume_header 
_Generate_header 
934  {
935  _Consume_header = 4,
936  _Generate_header = 2
937  };
Definition: xlocale:936
Definition: xlocale:935

Function Documentation

template<class _Elem , class _InIt >
int __CRTDECL _Getloctxt ( _InIt &  _First,
_InIt &  _Last,
size_t  _Numfields,
const _Elem *  _Ptr 
)
inline
552  { // find field at _Ptr that matches longest in [_First, _Last)
553  for (size_t _Off = 0; _Ptr[_Off] != (_Elem)0; ++_Off)
554  if (_Ptr[_Off] == _Ptr[0])
555  ++_Numfields; // add fields with leading mark to initial count
556  string _Str(_Numfields, '\0'); // one column counter for each field
557 
558  int _Ans = -2; // no candidates so far
559  for (size_t _Column = 1; ; ++_Column, (void)++_First, _Ans = -1)
560  { // test each element against all viable fields
561  bool _Prefix = false; // seen at least one valid prefix
562  size_t _Off = 0; // offset into fields
563  size_t _Field = 0; // current field number
564 
565  for (; _Field < _Numfields; ++_Field)
566  { // test element at _Column in field _Field
567  for (; _Ptr[_Off] != (_Elem)0 && _Ptr[_Off] != _Ptr[0]; ++_Off)
568  ; // find beginning of field
569 
570  if (_Str[_Field] != '\0')
571  _Off += _Str[_Field]; // skip tested columns in field
572  else if (_Ptr[_Off += _Column] == _Ptr[0]
573  || _Ptr[_Off] == (_Elem)0)
574  { // matched all of field, save as possible answer
575  _Str[_Field] = (char)(_Column < 127
576  ? _Column : 127); // save skip count if small enough
577  _Ans = (int)_Field; // save answer
578  }
579  else if (_First == _Last || _Ptr[_Off] != *_First)
580  _Str[_Field] = (char)(_Column < 127
581  ? _Column : 127); // no match, just save skip count
582  else
583  _Prefix = true; // still a valid prefix
584  }
585 
586  if (!_Prefix || _First == _Last)
587  break; // no pending prefixes or no input, give up
588  }
589  return (_Ans); // return field number or negative value on failure
590  }
unsigned char
Definition: mbstring.h:107
_CRT_BEGIN_C_HEADER typedef void(__CRTDECL *terminate_handler)()
char int *typedef int(__CRTDECL *_CRT_REPORT_HOOKW)(int
Definition: crtdbg.h:45
_FwdIt _Last
Definition: algorithm:1936
template<class _Elem >
char __CRTDECL _Maklocbyte ( _Elem  _Char,
const _Locinfo::_Cvtvec  
)
inline
599  { // convert _Elem to char using _Cvtvec
600  return ((char)(unsigned char)_Char);
601  }
template<>
char __CRTDECL _Maklocbyte ( wchar_t  _Char,
const _Locinfo::_Cvtvec _Cvt 
)
inline
606  { // convert wchar_t to char using _Cvtvec
607  char _Byte = '\0';
608  _Mbstinit(_Mbst1);
609  _Wcrtomb(&_Byte, _Char, &_Mbst1, &_Cvt);
610  return (_Byte);
611  }
_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Wcrtomb(_Out_ char *, wchar_t, mbstate_t *, const _Cvtvec *)
#define _Mbstinit(x)
Definition: yvals.h:765
template<class _Elem >
_Elem __CRTDECL _Maklocchr ( char  _Byte,
_Elem *  ,
const _Locinfo::_Cvtvec  
)
inline
632  { // convert char to _Elem using _Cvtvec
633  return ((_Elem)(unsigned char)_Byte);
634  }
template<>
wchar_t __CRTDECL _Maklocchr ( char  _Byte,
wchar_t ,
const _Locinfo::_Cvtvec _Cvt 
)
inline
639  { // convert char to wchar_t using _Cvtvec
640  wchar_t _Wc = L'\0';
641  _Mbstinit(_Mbst1);
642  _Mbrtowc(&_Wc, &_Byte, 1, &_Mbst1, &_Cvt);
643  return (_Wc);
644  }
_MRTIMP2 int __cdecl _Mbrtowc(_Out_opt_ wchar_t *, const char *, size_t, mbstate_t *, const _Cvtvec *)
#define _Mbstinit(x)
Definition: yvals.h:765
template<class _Elem >
_Elem* __CRTDECL _Maklocstr ( const char _Ptr,
_Elem *  ,
const _Locinfo::_Cvtvec  
)
inline
665  { // convert C string to _Elem sequence using _Cvtvec
666  size_t _Count = _CSTD strlen(_Ptr) + 1;
667 
668  _Elem *_Ptrdest = (_Elem *)_calloc_dbg(_Count, sizeof (_Elem),
669  _CRT_BLOCK, __FILE__, __LINE__);
670 
671  if (!_Ptrdest)
672  _Xbad_alloc();
673 
674  for (_Elem *_Ptrnext = _Ptrdest; 0 < _Count; --_Count, ++_Ptrnext, ++_Ptr)
675  *_Ptrnext = (_Elem)(unsigned char)*_Ptr;
676 
677  return (_Ptrdest);
678  }
_Check_return_ size_t __cdecl strlen(_In_z_ char const *_Str)
unsigned char
Definition: mbstring.h:107
#define _CRT_BLOCK
Definition: crtdbg.h:95
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xbad_alloc()
#define _calloc_dbg(c, s, t, f, l)
Definition: crtdbg.h:244
_Diff _Count
Definition: algorithm:1941
#define _CSTD
Definition: yvals.h:570
template<>
wchar_t* __CRTDECL _Maklocstr ( const char _Ptr,
wchar_t ,
const _Locinfo::_Cvtvec _Cvt 
)
inline
683  { // convert C string to wchar_t sequence using _Cvtvec
684  size_t _Count, _Count1;
685  size_t _Wchars;
686  const char *_Ptr1;
687  int _Bytes;
688  wchar_t _Wc;
689  _Mbstinit(_Mbst1);
690 
691  _Count1 = _CSTD strlen(_Ptr) + 1;
692  for (_Count = _Count1, _Wchars = 0, _Ptr1 = _Ptr; 0 < _Count;
693  _Count -= _Bytes, _Ptr1 += _Bytes, ++_Wchars)
694  if ((_Bytes = _Mbrtowc(&_Wc, _Ptr1, _Count, &_Mbst1, &_Cvt)) <= 0)
695  break;
696  ++_Wchars; // count terminating nul
697 
698  wchar_t *_Ptrdest = (wchar_t *)_calloc_dbg(_Wchars, sizeof (wchar_t),
699  _CRT_BLOCK, __FILE__, __LINE__);
700 
701  if (!_Ptrdest)
702  _Xbad_alloc();
703  wchar_t *_Ptrnext = _Ptrdest;
704  _Mbstinit(_Mbst2);
705 
706  for (; 0 < _Wchars;
707  _Count -= _Bytes, _Ptr += _Bytes, --_Wchars, ++_Ptrnext)
708  if ((_Bytes = _Mbrtowc(_Ptrnext, _Ptr, _Count1, &_Mbst2, &_Cvt)) <= 0)
709  break;
710  *_Ptrnext = L'\0';
711 
712  return (_Ptrdest);
713  }
_Check_return_ size_t __cdecl strlen(_In_z_ char const *_Str)
#define _CRT_BLOCK
Definition: crtdbg.h:95
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xbad_alloc()
_MRTIMP2 int __cdecl _Mbrtowc(_Out_opt_ wchar_t *, const char *, size_t, mbstate_t *, const _Cvtvec *)
#define _calloc_dbg(c, s, t, f, l)
Definition: crtdbg.h:244
_Diff _Count
Definition: algorithm:1941
#define _CSTD
Definition: yvals.h:570
#define _Mbstinit(x)
Definition: yvals.h:765
template<class _Facet >
const _Facet &__CRTDECL use_facet ( const locale _Loc)
inline
505  { // get facet reference from locale
506  _BEGIN_LOCK(_LOCK_LOCALE) // the thread lock, make get atomic
507  const locale::facet *_Psave =
508  _Facetptr<_Facet>::_Psave; // static pointer to lazy facet
509 
510  size_t _Id = _Facet::id;
511  const locale::facet *_Pf = _Loc._Getfacet(_Id);
512 
513  if (_Pf != 0)
514  ; // got facet from locale
515  else if (_Psave != 0)
516  _Pf = _Psave; // lazy facet already allocated
517  else if (_Facet::_Getcat(&_Psave, &_Loc) == (size_t)(-1))
518 
519  #if _HAS_EXCEPTIONS
520 
521  _THROW_NCEE(bad_cast, _EMPTY_ARGUMENT); // lazy disallowed
522 
523  #else /* _HAS_EXCEPTIONS */
524  abort(); // lazy disallowed
525  #endif /* _HAS_EXCEPTIONS */
526 
527  else
528  { // queue up lazy facet for destruction
529  _Pf = _Psave;
530  _Facetptr<_Facet>::_Psave = _Psave;
531 
532  locale::facet *_Pfmod = (_Facet *)_Psave;
533  _Pfmod->_Incref();
534 
535  #if defined(_M_CEE)
536  _Facet_Register_m(_Pfmod);
537 
538  #else /* defined(_M_CEE) */
539  _Facet_Register(_Pfmod);
540  #endif /* defined(_M_CEE) */
541  }
542 
543  return ((const _Facet&)(*_Pf)); // should be dynamic_cast
544  _END_LOCK()
545  } // end of use_facet body
Definition: typeinfo:43
void __CLRCALL_OR_CDECL _Facet_Register(_Facet_base *)
if(_Source==NULL||_DestinationSize< _SourceSize)
Definition: corecrt_memcpy_s.h:48
Definition: xlocale:97
virtual void __CLR_OR_THIS_CALL _Incref()
Definition: xlocale:147
else
Definition: variant:945
#define _THROW_NCEE(x, y)
Definition: xstddef:51
Definition: xlocale:137
Definition: xlocale:488
#define _EMPTY_ARGUMENT
Definition: xstddef:77
#define _LOCK_LOCALE
Definition: yvals.h:591