Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_time_put.cc
Go to the documentation of this file.
1
29#include <streambuf>
30#include <rw/_iosbase.h>
31#include <loc/_ctype.h>
32
33
35
36
37// defined in time_put.cpp
38_RWSTD_EXPORT char*
39__rw_put_time (const __rw_facet*, char*, _RWSTD_SIZE_T,
40 _STD::ios_base&, char, const _RWSTD_C::tm*,
41 char, char, int, int);
42
43#ifndef _RWSTD_NO_WCHAR_T
44
45// defined in time_put.cpp
46_RWSTD_EXPORT wchar_t*
47__rw_put_time (const __rw_facet*, wchar_t*, _RWSTD_SIZE_T,
48 _STD::ios_base&, wchar_t, const _RWSTD_C::tm*,
49 char, char, int, int);
50
51#endif // _RWSTD_NO_WCHAR_T
52
53} // namespace __rw
54
55
57
58
59template <class _CharT, class _OutputIter>
60_RW::__rw_facet_id time_put<_CharT, _OutputIter>::id;
61
62
63// outlined to avoid generating a vtable in each translation unit
64// that uses the class
65template <class _CharT, class _InputIter>
66/* virtual */ time_put<_CharT, _InputIter>::
67~time_put ()
68{
69 // no-op
70}
71
72
73template <class _CharT, class _OutputIter /* = ostreambuf_iterator<_CharT> */ >
74/* virtual */ typename time_put<_CharT, _OutputIter>::iter_type
75time_put<_CharT, _OutputIter>::
76do_put (iter_type __it, ios_base &__flags, char_type __fill,
77 const tm *__tmb, char __fmt, char __modifier /* = 0 */) const
78{
79 char_type __buf [256];
80
81 const char_type *__end =
82 _RW::__rw_put_time (this, __buf + 0, sizeof __buf / sizeof *__buf,
83 __flags, __fill, __tmb, __fmt, __modifier, -1, -1);
84
85 // number of fill chars to pad with
86 streamsize __pad = __flags.width () - streamsize (__end - __buf);
87
88 // adjustfield bits (left, internal, or the default right)
89 const int __adj = __flags.flags () & _RWSTD_IOS_ADJUSTFIELD;
90
91 if (__pad > 0 && _RWSTD_IOS_LEFT != __adj) {
92
93 // right justify unless left justification requested
94 for (; __pad--; ++__it)
95 *__it = __fill;
96 }
97
98 for (const char_type *__p = __buf; __p != __end; ++__p, ++__it) {
99 *__it = *__p;
100 }
101
102 // left justify if necessary
103 for (; __pad-- > 0; ++__it)
104 *__it = __fill;
105
106 return __it;
107}
108
109
110template <class _CharT, class _OutputIter /* = ostreambuf_iterator<_CharT> */ >
111typename time_put<_CharT, _OutputIter>::iter_type
112time_put<_CharT, _OutputIter>::
113put (iter_type __it, ios_base &__flags, char_type __fill, const tm *__tmb,
114 const char_type *__pat, const char_type *__end) const
115{
116 _RWSTD_ASSERT (0 != __pat);
117
118 if (!__end) // convenience extension
119 __end = __pat + char_traits<char_type>::length (__pat);
120
121 const ctype<char_type> &__ctp =
122 _RWSTD_USE_FACET (ctype<char_type>, __flags.getloc ());
123
124 for (; __pat != __end; ++__pat) {
125
126 if ('%' == __ctp.narrow (*__pat, 0) && __pat + 1 < __end) {
127
128 char __fmtmod = __ctp.narrow (*++__pat, 0); // format modifier
129 char __fmt; // format specifier
130
131 if ('E' == __fmtmod) {
132
133 __fmt = __ctp.narrow (__pat [1], 0);
134
135 switch (__fmt) {
136 // check valid format modifiers
137 case 'c': case 'C': case 'x': case 'X': case 'y': case 'Y':
138 ++__pat;
139 break;
140
141 case '\0':
142 break;
143
144 default:
145 __fmt = 0; // `pat' doesn't point to a valid format
146 }
147 }
148 else if ('O' == __fmtmod) {
149
150 __fmt = __ctp.narrow (__pat [1], 0);
151
152 switch (__fmt) {
153 // check valid format modifiers
154 case 'd': case 'e': case 'H': case 'I': case 'm': case 'M':
155 case 'S': case 'u': case 'U': case 'V': case 'w': case 'W':
156 case 'y':
157 ++__pat;
158 break;
159
160 case '\0':
161 break;
162
163 default:
164 __fmt = 0; // `pat' doesn't point to a valid format
165 }
166 }
167 else {
168 __fmt = __fmtmod;
169 __fmtmod = 0;
170 }
171
172 if (char (-1) != __fmt) {
173 __it = do_put (__it, __flags, __fill, __tmb, __fmt, __fmtmod);
174 continue;
175 }
176 }
177
178 *__it = *__pat;
179 ++__it;
180 }
181
182 return __it;
183}
184
185
186// outlined to avoid generating a vtable in each translation unit
187// that uses the class
188template <class _CharT, class _OutputIter>
189/* virtual */ time_put_byname<_CharT, _OutputIter>::
190~time_put_byname ()
191{
192 // no-op
193}
194
195
196} // namespace std
#define _RWSTD_IOS_ADJUSTFIELD
Definition _defs.h:792
#define _RWSTD_EXPORT
Definition _defs.h:485
#define _RWSTD_USE_FACET(type, arg)
Definition _defs.h:949
#define _RWSTD_IOS_LEFT
Definition _defs.h:771
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _RWSTD_ASSERT(ignore)
Definition _defs.h:1108
Definition json.h:5363