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 
997  {
998  _Consume_header = 4,
999  _Generate_header = 2
1000  };
Definition: xlocale:999
Definition: xlocale:998

Function Documentation

template<class _Elem , class _InIt >
int __CRTDECL _Getloctxt ( _InIt &  _First,
_InIt &  _Last,
size_t  _Numfields,
const _Elem *  _Ptr 
)
inline
606  { // find field at _Ptr that matches longest in [_First, _Last)
607  for (size_t _Off = 0; _Ptr[_Off] != (_Elem)0; ++_Off)
608  if (_Ptr[_Off] == _Ptr[0])
609  ++_Numfields; // add fields with leading mark to initial count
610  string _Str(_Numfields, '\0'); // one column counter for each field
611 
612  int _Ans = -2; // no candidates so far
613  for (size_t _Column = 1; ; ++_Column, (void)++_First, _Ans = -1)
614  { // test each element against all viable fields
615  bool _Prefix = false; // seen at least one valid prefix
616  size_t _Off = 0; // offset into fields
617  size_t _Field = 0; // current field number
618 
619  for (; _Field < _Numfields; ++_Field)
620  { // test element at _Column in field _Field
621  for (; _Ptr[_Off] != (_Elem)0 && _Ptr[_Off] != _Ptr[0]; ++_Off)
622  ; // find beginning of field
623 
624  if (_Str[_Field] != '\0')
625  _Off += _Str[_Field]; // skip tested columns in field
626  else if (_Ptr[_Off += _Column] == _Ptr[0]
627  || _Ptr[_Off] == (_Elem)0)
628  { // matched all of field, save as possible answer
629  _Str[_Field] = (char)(_Column < 127
630  ? _Column : 127); // save skip count if small enough
631  _Ans = (int)_Field; // save answer
632  }
633  else if (_First == _Last || _Ptr[_Off] != *_First)
634  _Str[_Field] = (char)(_Column < 127
635  ? _Column : 127); // no match, just save skip count
636  else
637  _Prefix = true; // still a valid prefix
638  }
639 
640  if (!_Prefix || _First == _Last)
641  break; // no pending prefixes or no input, give up
642  }
643  return (_Ans); // return field number or negative value on failure
644  }
unsigned int
Definition: vccorlib.h:2468
_CRT_BEGIN_C_HEADER typedef void(__CRTDECL *unexpected_handler)()
_FwdIt _Last
Definition: algorithm:1936
template<class _Elem >
char __CRTDECL _Maklocbyte ( _Elem  _Char,
const _Locinfo::_Cvtvec  
)
inline
653  { // convert _Elem to char using _Cvtvec
654  return ((char)(unsigned char)_Char);
655  }
template<>
char __CRTDECL _Maklocbyte ( wchar_t  _Char,
const _Locinfo::_Cvtvec _Cvt 
)
inline
660  { // convert wchar_t to char using _Cvtvec
661  char _Byte = '\0';
662  _Mbstinit(_Mbst1);
663  _Wcrtomb(&_Byte, _Char, &_Mbst1, &_Cvt);
664  return (_Byte);
665  }
_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Wcrtomb(_Out_ char *, wchar_t, mbstate_t *, const _Cvtvec *)
#define _Mbstinit(x)
Definition: yvals.h:813
template<class _Elem >
_Elem __CRTDECL _Maklocchr ( char  _Byte,
_Elem *  ,
const _Locinfo::_Cvtvec  
)
inline
686  { // convert char to _Elem using _Cvtvec
687  return ((_Elem)(unsigned char)_Byte);
688  }
template<>
wchar_t __CRTDECL _Maklocchr ( char  _Byte,
wchar_t ,
const _Locinfo::_Cvtvec _Cvt 
)
inline
693  { // convert char to wchar_t using _Cvtvec
694  wchar_t _Wc = L'\0';
695  _Mbstinit(_Mbst1);
696  _Mbrtowc(&_Wc, &_Byte, 1, &_Mbst1, &_Cvt);
697  return (_Wc);
698  }
_MRTIMP2 int __cdecl _Mbrtowc(_Out_opt_ wchar_t *, const char *, size_t, mbstate_t *, const _Cvtvec *)
#define _Mbstinit(x)
Definition: yvals.h:813
template<class _Elem >
_Elem* __CRTDECL _Maklocstr ( const char *  _Ptr,
_Elem *  ,
const _Locinfo::_Cvtvec  
)
inline
719  { // convert C string to _Elem sequence using _Cvtvec
720  size_t _Count = _CSTD strlen(_Ptr) + 1;
721 
722  _Elem *_Ptrdest = (_Elem *)_calloc_dbg(_Count, sizeof (_Elem),
723  _CRT_BLOCK, __FILE__, __LINE__);
724 
725  if (!_Ptrdest)
726  _Xbad_alloc();
727 
728  #pragma warning(push)
729  #pragma warning(disable: 6011) /* quiet prefast noise */
730  for (_Elem *_Ptrnext = _Ptrdest; 0 < _Count; --_Count, ++_Ptrnext, ++_Ptr)
731  *_Ptrnext = (_Elem)(unsigned char)*_Ptr;
732  #pragma warning(pop)
733 
734  return (_Ptrdest);
735  }
unsigned int _Count
Definition: xcomplex:668
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xbad_alloc()
#define _CSTD
Definition: yvals.h:570
template<>
wchar_t* __CRTDECL _Maklocstr ( const char *  _Ptr,
wchar_t ,
const _Locinfo::_Cvtvec _Cvt 
)
inline
740  { // convert C string to wchar_t sequence using _Cvtvec
741  size_t _Count, _Count1;
742  size_t _Wchars;
743  const char *_Ptr1;
744  int _Bytes;
745  wchar_t _Wc;
746  _Mbstinit(_Mbst1);
747 
748  _Count1 = _CSTD strlen(_Ptr) + 1;
749  for (_Count = _Count1, _Wchars = 0, _Ptr1 = _Ptr; 0 < _Count;
750  _Count -= _Bytes, _Ptr1 += _Bytes, ++_Wchars)
751  if ((_Bytes = _Mbrtowc(&_Wc, _Ptr1, _Count, &_Mbst1, &_Cvt)) <= 0)
752  break;
753  ++_Wchars; // count terminating nul
754 
755  wchar_t *_Ptrdest = (wchar_t *)_calloc_dbg(_Wchars, sizeof (wchar_t),
756  _CRT_BLOCK, __FILE__, __LINE__);
757 
758  if (!_Ptrdest)
759  _Xbad_alloc();
760  wchar_t *_Ptrnext = _Ptrdest;
761  _Mbstinit(_Mbst2);
762 
763  #pragma warning(push)
764  #pragma warning(disable: 6011) /* quiet prefast noise */
765  for (; 0 < _Wchars;
766  _Count -= _Bytes, _Ptr += _Bytes, --_Wchars, ++_Ptrnext)
767  if ((_Bytes = _Mbrtowc(_Ptrnext, _Ptr, _Count1, &_Mbst2, &_Cvt)) <= 0)
768  break;
769  *_Ptrnext = L'\0';
770  #pragma warning(pop)
771 
772  return (_Ptrdest);
773  }
unsigned int _Count
Definition: xcomplex:668
_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 _CSTD
Definition: yvals.h:570
#define _Mbstinit(x)
Definition: yvals.h:813
template<class _Facet >
const _Facet &__CRTDECL use_facet ( const locale _Loc)
inline
553  { // get facet reference from locale
554  #if _NO_LOCALES
555  static _Wrap_facet<_Facet> _Wfac;
556  return (*(_Facet *)&_Wfac);
557 
558  #else /* _NO_LOCALES */
559  _BEGIN_LOCK(_LOCK_LOCALE) // the thread lock, make get atomic
560  const locale::facet *_Psave =
561  _Facetptr<_Facet>::_Psave; // static pointer to lazy facet
562 
563  size_t _Id = _Facet::id;
564  const locale::facet *_Pf = _Loc._Getfacet(_Id);
565 
566  if (_Pf != 0)
567  ; // got facet from locale
568  else if (_Psave != 0)
569  _Pf = _Psave; // lazy facet already allocated
570  else if (_Facet::_Getcat(&_Psave, &_Loc) == (size_t)(-1))
571 
572  #if _HAS_EXCEPTIONS
573 
574  _THROW_NCEE(_XSTD bad_cast, _EMPTY_ARGUMENT); // lazy disallowed
575 
576  #else /* _HAS_EXCEPTIONS */
577  abort(); // lazy disallowed
578  #endif /* _HAS_EXCEPTIONS */
579 
580  else
581  { // queue up lazy facet for destruction
582  _Pf = _Psave;
583  _Facetptr<_Facet>::_Psave = _Psave;
584 
585  locale::facet *_Pfmod = (_Facet *)_Psave;
586  _Pfmod->_Incref();
587 
588  #if defined(_M_CEE)
589  _Facet_Register_m(_Pfmod);
590 
591  #else /* defined(_M_CEE) */
592  _Facet_Register(_Pfmod);
593  #endif /* defined(_M_CEE) */
594  }
595 
596  return ((const _Facet&)(*_Pf)); // should be dynamic_cast
597  _END_LOCK()
598  #endif /* _NO_LOCALES */
599  } // end of use_facet body
else
Definition: vccorlib.h:1729
Definition: typeinfo:36
void __CLRCALL_OR_CDECL _Facet_Register(_Facet_base *)
#define _XSTD
Definition: xstddef:21
Definition: xlocale:98
virtual void __CLR_OR_THIS_CALL _Incref()
Definition: xlocale:148
#define _THROW_NCEE(x, y)
Definition: xstddef:78
Definition: xlocale:138
Definition: xlocale:536
#define _EMPTY_ARGUMENT
Definition: xstddef:82
if(__pUnknown!=*__ppTargetUnknown)
Definition: vccorlib.h:399
#define _LOCK_LOCALE
Definition: yvals.h:604