File Index Symbol Index

// xlocinfo internal header for Microsoft
#pragma once
#ifndef _XLOCINFO_
#define _XLOCINFO_
#ifndef RC_INVOKED #include <xlocinfo.h>
#include <cstdlib>
#include <xstddef>
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
// CLASS _Timevec
{
// smart pointer to information used by _Strftime
public
: : _Timeptr(
_Ptr
) {
// construct from ptr
} {
// construct from _Right
*
this
=
_Right
; } {
// destroy the object
free
(
_Timeptr
); } {
// transfer ownership of _Timeptr from _Right
_Timeptr
=
_Right
.
_Timeptr
; ((
_Timevec
*)&
_Right
)->
_Timeptr
=
nullptr
;
return
(*
this
); } {
// return pointer to time information
return
(
_Timeptr
); }
private
:
void
*
_Timeptr
;
// pointer to time information
};
// CLASS _Locinfo
{
// summary of all stuff peculiar to a locale used by standard facets
public
:
typedef
::
_Collvec
_Collvec
;
typedef
::
_Ctypevec
_Ctypevec
;
typedef
::
_Cvtvec
_Cvtvec
;
_Locinfo
*,
const
char
*);
_Locinfo
*,
int
,
const
char
*);
_Locinfo
*);
_Locinfo
*,
int
,
const
char
*);
#ifndef _M_CEE
{
// construct from NTBS
if
(
_Pch
==
nullptr
)
_Locinfo_ctor
(
this
,
_Pch
); }
#ifndef _M_CEE
{
// construct from category mask and NTBS
if
(
_Pch
==
nullptr
)
_Locinfo_ctor
(
this
,
_Cat
,
_Pch
); } {
// destroy the object
_Locinfo_dtor
(
this
); } {
// add facets matching category mask and NTBS
if
(
_Pch
==
nullptr
)
return
(
_Locinfo_Addcats
(
this
,
_Cat
,
_Pch
)); } {
// return the new locale name
return
(
_Newlocname
.
_C_str
()); } {
// return collation stuff
return
(::
_Getcoll
()); } {
// return ctype stuff
return
(::
_Getctype
()); } {
// return codecvt stuff
return
(::
_Getcvt
()); } {
// return localeconv stuff
return
(
localeconv
()); } {
// return names used by _Strftime
return
(
_Timevec
(::
_Gettnames
())); } {
// return names for weekdays
const
char
*
_Ptr
= ::
_Getdays
();
if
(
_Ptr
!=
nullptr
) {
// capture names and free allocated C string
((
_Locinfo
*)
this
)->
_Days
=
_Ptr
;
free
((
void
*)
_Ptr
); }
return
(!
_Days
.
_Empty
() ?
_Days
.
_C_str
() :
":Sun:Sunday:Mon:Monday:Tue:Tuesday:Wed:Wednesday"
":Thu:Thursday:Fri:Friday:Sat:Saturday"
); } {
// return names for months
const
char
*
_Ptr
= ::
_Getmonths
();
if
(
_Ptr
!=
nullptr
) {
// capture names and free allocated C string
((
_Locinfo
*)
this
)->
_Months
=
_Ptr
;
free
((
void
*)
_Ptr
); }
return
(!
_Months
.
_Empty
() ?
_Months
.
_C_str
() :
":Jan:January:Feb:February:Mar:March"
":Apr:April:May:May:Jun:June"
":Jul:July:Aug:August:Sep:September"
":Oct:October:Nov:November:Dec:December"
); } {
// return false name (no C source)
return
(
"false"
); } {
// return true name (no C source)
return
(
"true"
); } {
// return date order
return
(::
_Getdateorder
()); } {
// return names used by _Wcsftime
return
(
_Timevec
(::
_W_Gettnames
())); } {
// return names for weekdays
const
wchar_t
*
_Ptr
= ::
_W_Getdays
();
if
(
_Ptr
!=
nullptr
) {
// capture names and free allocated C string
((
_Locinfo
*)
this
)->
_W_Days
=
_Ptr
;
free
((
void
*)
_Ptr
); }
return
((
const
unsigned
short
*)(!
_W_Days
.
_Empty
() ?
_W_Days
.
_C_str
() :
L":Sun:Sunday:Mon:Monday:Tue:Tuesday:Wed:Wednesday"
L":Thu:Thursday:Fri:Friday:Sat:Saturday"
)); } {
// return names for months
const
wchar_t
*
_Ptr
= ::
_W_Getmonths
();
if
(
_Ptr
!=
nullptr
) {
// capture names and free allocated C string
((
_Locinfo
*)
this
)->
_W_Months
=
_Ptr
;
free
((
void
*)
_Ptr
); }
return
((
const
unsigned
short
*)(!
_W_Months
.
_Empty
() ?
_W_Months
.
_C_str
() :
L":Jan:January:Feb:February:Mar:March"
L":Apr:April:May:May:Jun:June"
L":Jul:July:Aug:August:Sep:September"
L":Oct:October:Nov:November:Dec:December"
)); }
_Locinfo
(
const
_Locinfo
&) =
delete
;
_Locinfo
&
operator
=
(
const
_Locinfo
&) =
delete
;
private
:
#ifdef _M_CEE
_EmptyLockit _Empty_lock; // to maintain same size
#else /* _M_CEE */
_Lockit
_Lock
;
// thread lock, because global locale is altered
#endif /* _M_CEE */
_Yarn
<
char
>
_Days
;
// weekday names
_Yarn
<
char
>
_Months
;
// month names
_Yarn
<
wchar_t
>
_W_Days
;
// wide weekday names
_Yarn
<
wchar_t
>
_W_Months
;
// wide month names
_Yarn
<
char
>
_Oldlocname
;
// old locale name to revert to on destruction
_Yarn
<
char
>
_Newlocname
;
// new locale name for this object
};
// FUNCTION TEMPLATE _LStrcoll
template
<
class
_Elem
>
inline
const
_Elem
*
_First2
,
const
_Elem
*
_Last2
,
const
_Locinfo
::
_Collvec
*) {
// perform locale-specific comparison of _Elem sequences
for
(;
_First1
!
=
_Last1
&&
_First2
!
=
_Last2
; ++
_First1
, ++
_First2
)
if
(*
_First1
< *
_First2
)
return
(-
1
);
// [_First1, _Last1) < [_First2, _Last2)
else
if
(*
_First2
< *
_First1
)
return
(+
1
);
// [_First1, _Last1) > [_First2, _Last2)
return
(
_First2
!
=
_Last2
? -
1
:
_First1
!
=
_Last1
? +
1
:
0
); }
template
<>
inline
const
char
*
_First2
,
const
char
*
_Last2
,
const
_Locinfo
::
_Collvec
*
_Vector
) {
// perform locale-specific comparison of char sequences
return
(
_Strcoll
(
_First1
,
_Last1
,
_First2
,
_Last2
,
_Vector
)); }
template
<>
inline
const
wchar_t
*
_First2
,
const
wchar_t
*
_Last2
,
const
_Locinfo
::
_Collvec
*
_Vector
) {
// perform locale-specific comparison of wchar_t sequences
return
(
_Wcscoll
(
_First1
,
_Last1
,
_First2
,
_Last2
,
_Vector
)); }
// FUNCTION TEMPLATE _LStrxfrm
template
<
class
_Elem
>
inline
const
_Elem
*
_First2
,
const
_Elem
*
_Last2
,
const
_Locinfo
::
_Collvec
*) {
// perform locale-specific transform of _Elems [_First1, _Last1)
const
ptrdiff_t
_Count
=
_Last2
-
_First2
;
if
(
_Count
<=
_Last1
-
_First1
) { }
return
(
_Count
); }
template
<>
inline
const
char
*
_First2
,
const
char
*
_Last2
,
const
_Locinfo
::
_Collvec
*
_Vector
) {
// perform locale-specific transform of chars [_First1, _Last1)
return
(
_Strxfrm
(
_First1
,
_Last1
,
_First2
,
_Last2
,
_Vector
)); }
template
<>
inline
const
wchar_t
*
_First2
,
const
wchar_t
*
_Last2
,
const
_Locinfo
::
_Collvec
*
_Vector
) {
// perform locale-specific transform of wchar_ts [_First1, _Last1)
return
(
_Wcsxfrm
(
_First1
,
_Last1
,
_First2
,
_Last2
,
_Vector
)); }
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
/* * Copyright (c) by P.J. Plauger. All rights reserved. * Consult your license regarding permissions and restrictions. V6.50:0009 */