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

Classes

class  _Locbase< _Dummy >
 
class  collate< _Elem >
 
class  locale
 
class  locale::id
 
class  locale::facet
 
class  locale::_Locimp
 
struct  _Facetptr< _Facet >
 
class  codecvt_base
 
class  codecvt< _Elem, _Byte, _Statype >
 
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 */
 

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_

Function Documentation

template<class _Elem , class _InIt >
int __CRTDECL _Getloctxt ( _InIt &  _First,
_InIt &  _Last,
size_t  _Numfields,
const _Elem *  _Ptr 
)
inline
614  { // find field at _Ptr that matches longest in [_First, _Last)
615  for (size_t _Off = 0; _Ptr[_Off] != (_Elem)0; ++_Off)
616  if (_Ptr[_Off] == _Ptr[0])
617  ++_Numfields; // add fields with leading mark to initial count
618  string _Str(_Numfields, '\0'); // one column counter for each field
619 
620  int _Ans = -2; // no candidates so far
621  for (size_t _Column = 1; ; ++_Column, ++_First, _Ans = -1)
622  { // test each element against all viable fields
623  bool _Prefix = false; // seen at least one valid prefix
624  size_t _Off = 0; // offset into fields
625  size_t _Field = 0; // current field number
626 
627  for (; _Field < _Numfields; ++_Field)
628  { // test element at _Column in field _Field
629  for (; _Ptr[_Off] != (_Elem)0 && _Ptr[_Off] != _Ptr[0]; ++_Off)
630  ; // find beginning of field
631 
632  if (_Str[_Field] != '\0')
633  _Off += _Str[_Field]; // skip tested columns in field
634  else if (_Ptr[_Off += _Column] == _Ptr[0]
635  || _Ptr[_Off] == (_Elem)0)
636  { // matched all of field, save as possible answer
637  _Str[_Field] = (char)(_Column < 127
638  ? _Column : 127); // save skip count if small enough
639  _Ans = (int)_Field; // save answer
640  }
641  else if (_First == _Last || _Ptr[_Off] != *_First)
642  _Str[_Field] = (char)(_Column < 127
643  ? _Column : 127); // no match, just save skip count
644  else
645  _Prefix = true; // still a valid prefix
646  }
647 
648  if (!_Prefix || _First == _Last)
649  break; // no pending prefixes or no input, give up
650  }
651  return (_Ans); // return field number or negative value on failure
652  }
_CRTIMP _In_opt_z_ const wchar_t _In_opt_z_ const wchar_t unsigned int
Definition: crtdefs.h:642
_FwdIt _Last
Definition: algorithm:1936
template<class _Elem >
char __CRTDECL _Maklocbyte ( _Elem  _Char,
const _Locinfo::_Cvtvec  
)
inline
661  { // convert _Elem to char using _Cvtvec
662  return ((char)(unsigned char)_Char);
663  }
template<>
char __CRTDECL _Maklocbyte ( wchar_t  _Char,
const _Locinfo::_Cvtvec _Cvt 
)
inline
668  { // convert wchar_t to char using _Cvtvec
669  char _Byte = '\0';
670  _Mbstinit(_Mbst1);
671  _Wcrtomb(&_Byte, _Char, &_Mbst1, &_Cvt);
672  return (_Byte);
673  }
#define _Mbstinit(x)
Definition: stdexcept:20
_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Wcrtomb(_Out_ char *, wchar_t, mbstate_t *, const _Cvtvec *)
template<class _Elem >
_Elem __CRTDECL _Maklocchr ( char  _Byte,
_Elem *  ,
const _Locinfo::_Cvtvec  
)
inline
694  { // convert char to _Elem using _Cvtvec
695  return ((_Elem)(unsigned char)_Byte);
696  }
template<>
wchar_t __CRTDECL _Maklocchr ( char  _Byte,
wchar_t ,
const _Locinfo::_Cvtvec _Cvt 
)
inline
701  { // convert char to wchar_t using _Cvtvec
702  wchar_t _Wc = L'\0';
703  _Mbstinit(_Mbst1);
704  _Mbrtowc(&_Wc, &_Byte, 1, &_Mbst1, &_Cvt);
705  return (_Wc);
706  }
#define _Mbstinit(x)
Definition: stdexcept:20
_MRTIMP2 int __cdecl _Mbrtowc(_Out_opt_ wchar_t *, const char *, size_t, mbstate_t *, const _Cvtvec *)
template<class _Elem >
_Elem* __CRTDECL _Maklocstr ( const char *  _Ptr,
_Elem *  ,
const _Locinfo::_Cvtvec  
)
inline
727  { // convert C string to _Elem sequence using _Cvtvec
728  size_t _Count = _CSTD strlen(_Ptr) + 1;
729  _Elem *_Ptrdest = _NEW_CRT _Elem[_Count];
730 
731  #pragma warning(push)
732  #pragma warning(disable: 6011) /* quiet prefast noise */
733  for (_Elem *_Ptrnext = _Ptrdest; 0 < _Count; --_Count, ++_Ptrnext, ++_Ptr)
734  *_Ptrnext = (_Elem)(unsigned char)*_Ptr;
735  #pragma warning(pop)
736 
737  return (_Ptrdest);
738  }
#define _NEW_CRT
Definition: xdebug:69
_Diff _Count
Definition: algorithm:1941
#define _CSTD
Definition: yvals.h:559
_Check_return_ size_t __cdecl strlen(_In_z_ const char *_Str)
template<>
wchar_t* __CRTDECL _Maklocstr ( const char *  _Ptr,
wchar_t ,
const _Locinfo::_Cvtvec _Cvt 
)
inline
743  { // convert C string to wchar_t sequence using _Cvtvec
744  size_t _Count, _Count1;
745  size_t _Wchars;
746  const char *_Ptr1;
747  int _Bytes;
748  wchar_t _Wc;
749  _Mbstinit(_Mbst1);
750 
751  _Count1 = _CSTD strlen(_Ptr) + 1;
752  for (_Count = _Count1, _Wchars = 0, _Ptr1 = _Ptr; 0 < _Count;
753  _Count -= _Bytes, _Ptr1 += _Bytes, ++_Wchars)
754  if ((_Bytes = _Mbrtowc(&_Wc, _Ptr1, _Count, &_Mbst1, &_Cvt)) <= 0)
755  break;
756  ++_Wchars; // count terminating nul
757 
758  wchar_t *_Ptrdest = _NEW_CRT wchar_t[_Wchars];
759  wchar_t *_Ptrnext = _Ptrdest;
760  _Mbstinit(_Mbst2);
761 
762  #pragma warning(push)
763  #pragma warning(disable: 6011) /* quiet prefast noise */
764  for (; 0 < _Wchars;
765  _Count -= _Bytes, _Ptr += _Bytes, --_Wchars, ++_Ptrnext)
766  if ((_Bytes = _Mbrtowc(_Ptrnext, _Ptr, _Count1, &_Mbst2, &_Cvt)) <= 0)
767  break;
768  *_Ptrnext = L'\0';
769  #pragma warning(pop)
770 
771  return (_Ptrdest);
772  }
#define _Mbstinit(x)
Definition: stdexcept:20
#define _NEW_CRT
Definition: xdebug:69
_MRTIMP2 int __cdecl _Mbrtowc(_Out_opt_ wchar_t *, const char *, size_t, mbstate_t *, const _Cvtvec *)
_Diff _Count
Definition: algorithm:1941
#define _CSTD
Definition: yvals.h:559
_Check_return_ size_t __cdecl strlen(_In_z_ const char *_Str)
template<class _Facet >
const _Facet &__CRTDECL use_facet ( const locale _Loc)
inline
561  { // get facet reference from locale
562  #if _NO_LOCALES
563  static _Wrap_facet<_Facet> _Wfac;
564  return (*(_Facet *)&_Wfac);
565 
566  #else /* _NO_LOCALES */
567  _BEGIN_LOCK(_LOCK_LOCALE) // the thread lock, make get atomic
568  const locale::facet *_Psave =
569  _Facetptr<_Facet>::_Psave; // static pointer to lazy facet
570 
571  size_t _Id = _Facet::id;
572  const locale::facet *_Pf = _Loc._Getfacet(_Id);
573 
574  if (_Pf != 0)
575  ; // got facet from locale
576  else if (_Psave != 0)
577  _Pf = _Psave; // lazy facet already allocated
578  else if (_Facet::_Getcat(&_Psave, &_Loc) == (size_t)(-1))
579 
580  #if _HAS_EXCEPTIONS
581 
582  _THROW_NCEE(_XSTD bad_cast, _EMPTY_ARGUMENT); // lazy disallowed
583 
584  #else /* _HAS_EXCEPTIONS */
585  abort(); // lazy disallowed
586  #endif /* _HAS_EXCEPTIONS */
587 
588  else
589  { // queue up lazy facet for destruction
590  _Pf = _Psave;
591  _Facetptr<_Facet>::_Psave = _Psave;
592 
593  locale::facet *_Pfmod = (_Facet *)_Psave;
594  _Pfmod->_Incref();
595 
596  #if defined(_M_CEE)
597  _Facet_Register_m(_Pfmod);
598 
599  #else /* defined(_M_CEE) */
600  _Facet_Register(_Pfmod);
601  #endif /* defined(_M_CEE) */
602  }
603 
604  return ((const _Facet&)(*_Pf)); // should be dynamic_cast
605  _END_LOCK()
606  #endif /* _NO_LOCALES */
607  } // end of use_facet body
else
Definition: vccorlib.h:1721
Definition: typeinfo:189
void __CLRCALL_OR_CDECL _Facet_Register(_Facet_base *)
#define _XSTD
Definition: xstddef:20
Definition: xlocale:62
virtual void __CLR_OR_THIS_CALL _Incref()
Definition: xlocale:143
#define _THROW_NCEE(x, y)
Definition: xstddef:79
Definition: xlocale:102
Definition: xlocale:544
#define _EMPTY_ARGUMENT
Definition: xstddef:83
if(__pUnknown!=*__ppTargetUnknown)
Definition: vccorlib.h:394
#define _LOCK_LOCALE
Definition: yvals.h:612