48 | | boost::io::ios_flags_saver iflags(os); |
49 | | typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet; |
50 | | typedef std::time_put<CharT> std_ptime_facet; |
51 | | std::ostreambuf_iterator<CharT> oitr(os); |
52 | | if (std::has_facet<custom_ptime_facet>(os.getloc())) |
53 | | std::use_facet<custom_ptime_facet>(os.getloc()).put(oitr, os, os.fill(), p); |
54 | | else { |
55 | | //instantiate a custom facet for dealing with times since the user |
56 | | //has not put one in the stream so far. This is for efficiency |
57 | | //since we would always need to reconstruct for every time period |
58 | | //if the locale did not already exist. Of course this will be overridden |
59 | | //if the user imbues as some later point. |
60 | | custom_ptime_facet* f = new custom_ptime_facet(); |
61 | | std::locale l = std::locale(os.getloc(), f); |
62 | | os.imbue(l); |
63 | | f->put(oitr, os, os.fill(), p); |
| 48 | typename std::basic_ostream<CharT, TraitsT>::sentry no_error_sentry(os); |
| 49 | if (no_error_sentry) { |
| 50 | boost::io::ios_flags_saver iflags(os); |
| 51 | typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet; |
| 52 | typedef std::time_put<CharT> std_ptime_facet; |
| 53 | std::ostreambuf_iterator<CharT> oitr(os); |
| 54 | if (std::has_facet<custom_ptime_facet>(os.getloc())) |
| 55 | std::use_facet<custom_ptime_facet>(os.getloc()).put(oitr, os, os.fill(), p); |
| 56 | else { |
| 57 | //instantiate a custom facet for dealing with times since the user |
| 58 | //has not put one in the stream so far. This is for efficiency |
| 59 | //since we would always need to reconstruct for every time period |
| 60 | //if the locale did not already exist. Of course this will be overridden |
| 61 | //if the user imbues as some later point. |
| 62 | custom_ptime_facet* f = new custom_ptime_facet(); |
| 63 | std::locale l = std::locale(os.getloc(), f); |
| 64 | os.imbue(l); |
| 65 | f->put(oitr, os, os.fill(), p); |
| 66 | } |
115 | | boost::io::ios_flags_saver iflags(os); |
116 | | typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet; |
117 | | typedef std::time_put<CharT> std_time_facet; |
118 | | std::ostreambuf_iterator<CharT> oitr(os); |
119 | | if (std::has_facet<custom_ptime_facet>(os.getloc())) { |
120 | | std::use_facet<custom_ptime_facet>(os.getloc()).put(oitr, os, os.fill(), p); |
| 118 | typename std::basic_ostream<CharT, TraitsT>::sentry no_error_sentry(os); |
| 119 | if (no_error_sentry) { |
| 120 | boost::io::ios_flags_saver iflags(os); |
| 121 | typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet; |
| 122 | typedef std::time_put<CharT> std_time_facet; |
| 123 | std::ostreambuf_iterator<CharT> oitr(os); |
| 124 | if (std::has_facet<custom_ptime_facet>(os.getloc())) { |
| 125 | std::use_facet<custom_ptime_facet>(os.getloc()).put(oitr, os, os.fill(), p); |
| 126 | } |
| 127 | else { |
| 128 | //instantiate a custom facet for dealing with periods since the user |
| 129 | //has not put one in the stream so far. This is for efficiency |
| 130 | //since we would always need to reconstruct for every time period |
| 131 | //if the local did not already exist. Of course this will be overridden |
| 132 | //if the user imbues as some later point. |
| 133 | custom_ptime_facet* f = new custom_ptime_facet(); |
| 134 | std::locale l = std::locale(os.getloc(), f); |
| 135 | os.imbue(l); |
| 136 | f->put(oitr, os, os.fill(), p); |
| 137 | } |
122 | | else { |
123 | | //instantiate a custom facet for dealing with periods since the user |
124 | | //has not put one in the stream so far. This is for efficiency |
125 | | //since we would always need to reconstruct for every time period |
126 | | //if the local did not already exist. Of course this will be overridden |
127 | | //if the user imbues as some later point. |
128 | | custom_ptime_facet* f = new custom_ptime_facet(); |
129 | | std::locale l = std::locale(os.getloc(), f); |
130 | | os.imbue(l); |
131 | | f->put(oitr, os, os.fill(), p); |
132 | | } |
181 | | boost::io::ios_flags_saver iflags(os); |
182 | | typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet; |
183 | | typedef std::time_put<CharT> std_ptime_facet; |
184 | | std::ostreambuf_iterator<CharT> oitr(os); |
185 | | if (std::has_facet<custom_ptime_facet>(os.getloc())) |
186 | | std::use_facet<custom_ptime_facet>(os.getloc()).put(oitr, os, os.fill(), td); |
187 | | else { |
188 | | //instantiate a custom facet for dealing with times since the user |
189 | | //has not put one in the stream so far. This is for efficiency |
190 | | //since we would always need to reconstruct for every time period |
191 | | //if the locale did not already exist. Of course this will be overridden |
192 | | //if the user imbues as some later point. |
193 | | custom_ptime_facet* f = new custom_ptime_facet(); |
194 | | std::locale l = std::locale(os.getloc(), f); |
195 | | os.imbue(l); |
196 | | f->put(oitr, os, os.fill(), td); |
| 187 | typename std::basic_ostream<CharT, Traits>::sentry no_error_sentry(os); |
| 188 | if (no_error_sentry) { |
| 189 | boost::io::ios_flags_saver iflags(os); |
| 190 | typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet; |
| 191 | typedef std::time_put<CharT> std_ptime_facet; |
| 192 | std::ostreambuf_iterator<CharT> oitr(os); |
| 193 | if (std::has_facet<custom_ptime_facet>(os.getloc())) |
| 194 | std::use_facet<custom_ptime_facet>(os.getloc()).put(oitr, os, os.fill(), td); |
| 195 | else { |
| 196 | //instantiate a custom facet for dealing with times since the user |
| 197 | //has not put one in the stream so far. This is for efficiency |
| 198 | //since we would always need to reconstruct for every time period |
| 199 | //if the locale did not already exist. Of course this will be overridden |
| 200 | //if the user imbues as some later point. |
| 201 | custom_ptime_facet* f = new custom_ptime_facet(); |
| 202 | std::locale l = std::locale(os.getloc(), f); |
| 203 | os.imbue(l); |
| 204 | f->put(oitr, os, os.fill(), td); |
| 205 | } |