Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
src
use_facet.h
Go to the documentation of this file.
1
32
#ifndef _RWSTD_USE_FACET_H_INCLUDED
33
#define _RWSTD_USE_FACET_H_INCLUDED
34
35
36
#include <new>
37
#include <
rw/_defs.h
>
38
39
#include "
access.h
"
40
41
42
// helper macro _RWSTD_DEFINE_FACET_FACTORY() defines a facet factory
43
// function called to construct, on demand, objects of specializations
44
// of facet class templates
45
// _byname facets are constructed on the heap while ordinary facets
46
// are constructed in static memory for efficiency and to avoid leaks,
47
// and are not destroyed during program lifetime
48
49
#ifndef _RWSTD_NO_BYNAME_FACET
50
51
// definition for facets that come in both forms, plain and _byname
52
# define _RWSTD_DEFINE_FACET_FACTORY(Linkage, Facet, TArgs, fid) \
53
typedef _STD:: Facet TArgs __rw_ ## fid ## _facet; \
54
_RWSTD_NAMESPACE (__rw) \
55
{ \
56
Linkage __rw_facet* \
57
__rw_ct_ ## fid (_RWSTD_SIZE_T ref, const char *name) \
58
{ \
59
__rw_facet* pfacet; \
60
if (name) { \
61
/* construct a _byname facet on the heap */
\
62
pfacet = new _STD:: Facet ## _byname TArgs (name, ref); \
63
} \
64
else { \
65
/* construct an ordinary facet in static memory */
\
66
static union { \
67
void *align_; \
68
char data_ [sizeof (__rw_ ## fid ## _facet)]; \
69
} f; \
70
static __rw_facet* const pf = \
71
new (&f) __rw_ ## fid ## _facet (ref); \
72
pfacet = pf; \
73
} \
74
/* set the pointer to the facet id */
\
75
__rw_access::_C_get_pid (*pfacet) = \
76
&(__rw_access::_C_get_id (__rw_ ## fid ## _facet::id)); \
77
return pfacet; \
78
} \
79
}
/* namespace __rw */
\
80
typedef void __rw_unused_type
81
82
#else
// if defined (_RWSTD_NO_BYNAME_FACET)
83
84
// definition for facets such as num_get that do not have a _byname form
85
# define _RWSTD_DEFINE_FACET_FACTORY(Linkage, Facet, TArgs, fid) \
86
typedef _STD:: Facet TArgs __rw_ ## fid ## _facet; \
87
_RWSTD_NAMESPACE (__rw) \
88
{ \
89
Linkage __rw_facet* \
90
__rw_ct_ ## fid (_RWSTD_SIZE_T ref, const char*) \
91
{ \
92
/* construct an ordinary facet in static memory */
\
93
static union { \
94
void *align_; \
95
char data_ [sizeof (__rw_ ## fid ## _facet)]; \
96
} f; \
97
static __rw_facet* const pf = \
98
new (&f) __rw_ ## fid ## _facet (ref); \
99
/* set the pointer to the facet id */
\
100
__rw_access::_C_get_pid (*pf) = \
101
&(__rw_access::_C_get_id (__rw_ ## fid ## _facet::id)); \
102
return pf; \
103
} \
104
}
/* namespace __rw */
\
105
typedef void __rw_unused_type
106
107
#endif
// _RWSTD_NO_BYNAME_FACET
108
109
110
#ifndef _RWSTD_NO_SPECIALIZED_FACET_ID
111
// provide definitions of explicit specializations of static
112
// template data members to guarantee a single instance of
113
// each in a program when the compiler or linker don't
114
// (e.g., VisualAge C++ on AIX)
115
# define _RWSTD_SPECIALIZE_FACET_ID(Facet, TArgs) \
116
_RWSTD_NAMESPACE (std) { \
117
_RWSTD_SPECIALIZED_CLASS \
118
_RW::__rw_facet_id Facet TArgs:: \
119
id (_RW::__rw_facet_id::_C_Init); \
120
} \
121
typedef void __rw_unused_type
122
#else
// if defined (_RWSTD_NO_SPECIALIZED_FACET_ID)
123
// facet id's will not be explicitly specialized
124
# define _RWSTD_SPECIALIZE_FACET_ID(ignore1, ignore2) \
125
typedef void __rw_unused_type
126
#endif
// _RWSTD_NO_SPECIALIZED_FACET_ID
127
128
129
#define _RWSTD_SPECIALIZE_USE_FACET(fid) \
130
_RWSTD_NAMESPACE (__rw) { \
131
_RWSTD_EXPORT \
132
const __rw_facet* \
133
__rw_get_facet_by_id \
134
(const _STD::locale &__loc, \
135
const __rw_facet_id&, \
136
const __rw_ ## fid ## _facet*) { \
137
return __rw_get_std_facet (__loc, __rw_facet::_C_ ## fid, \
138
__rw_ct_ ## fid); \
139
} \
140
} \
141
typedef void __rw_unused_type
142
143
#endif
// _RWSTD_USE_FACET_H_INCLUDED
_defs.h
access.h
Generated by
1.9.8