本文整理汇总了C++中std::ios_base::getloc方法的典型用法代码示例。如果您正苦于以下问题:C++ ios_base::getloc方法的具体用法?C++ ios_base::getloc怎么用?C++ ios_base::getloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::ios_base
的用法示例。
在下文中一共展示了ios_base::getloc方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f2
void f2(std::ios_base::event ev, std::ios_base& stream, int index)
{
if (ev == std::ios_base::erase_event)
{
assert(!f1_called);
assert(!f2_called);
assert(!g1_called);
assert(!g2_called);
assert(!g3_called);
assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
assert(index == 5);
f2_called = true;
}
}
示例2: get
iter_type get(iter_type i, iter_type e, std::ios_base& is, std::ios_base::iostate& err,
time_point<Clock, Duration> &tp, const char_type *pattern, const char_type *pat_end) const
{
if (std::has_facet<time_point_units<CharT> >(is.getloc()))
{
time_point_units<CharT> const &facet = std::use_facet<time_point_units<CharT> >(is.getloc());
return get(facet, i, e, is, err, tp, pattern, pat_end);
}
else
{
time_point_units_default<CharT> facet;
return get(facet, i, e, is, err, tp, pattern, pat_end);
}
}
示例3: get
iter_type get(iter_type i, iter_type e, std::ios_base& is, std::ios_base::iostate& err,
time_point<Clock, Duration> &tp) const
{
if (std::has_facet<time_point_units<CharT> >(is.getloc()))
{
time_point_units<CharT> const &facet = std::use_facet<time_point_units<CharT> >(is.getloc());
std::basic_string<CharT> str = facet.get_pattern();
return get(facet, i, e, is, err, tp, str.data(), str.data() + str.size());
}
else
{
time_point_units_default<CharT> facet;
std::basic_string<CharT> str = facet.get_pattern();
return get(facet, i, e, is, err, tp, str.data(), str.data() + str.size());
}
}
示例4: put
iter_type put(time_point_units<CharT> const& units_facet, iter_type s, std::ios_base& ios, char_type fill,
time_point<Clock, Duration> const& tp, const CharT* pattern, const CharT* pat_end) const
{
const std::ctype<char_type>& ct = std::use_facet<std::ctype<char_type> >(ios.getloc());
for (; pattern != pat_end; ++pattern)
{
if (ct.narrow(*pattern, 0) == '%')
{
if (++pattern == pat_end)
{
*s++ = pattern[-1];
break;
}
char fmt = ct.narrow(*pattern, 0);
switch (fmt)
{
case 'd':
{
s = put_duration(s, ios, fill, tp.time_since_epoch());
break;
}
case 'e':
{
s = put_epoch<Clock> (units_facet, s, ios);
break;
}
default:
AUTOBOOST_ASSERT(false && "Boost::Chrono internal error.");
break;
}
}
else
*s++ = *pattern;
}
return s;
}
示例5: put
iter_type put(duration_units<CharT> const& units_facet, iter_type s, std::ios_base& ios, char_type fill,
duration<Rep, Period> const& d, const CharT* pattern, const CharT* pat_end) const
{
const std::ctype<char_type>& ct = std::use_facet<std::ctype<char_type> >(ios.getloc());
for (; pattern != pat_end; ++pattern)
{
if (ct.narrow(*pattern, 0) == '%')
{
if (++pattern == pat_end)
{
*s++ = pattern[-1];
break;
}
char fmt = ct.narrow(*pattern, 0);
switch (fmt)
{
case 'v':
{
s = put_value(s, ios, fill, d);
break;
}
case 'u':
{
s = put_unit(units_facet, s, ios, fill, d);
break;
}
default:
BOOST_ASSERT(false && "Boost::Chrono internal error.");
break;
}
}
else
*s++ = *pattern;
}
return s;
}
示例6: do_put_tm
virtual OutItrT do_put_tm(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const tm& tm_value,
string_type a_format) const
{
// update format string with custom names
if (m_weekday_long_names.size()) {
boost::algorithm::replace_all(a_format,
long_weekday_format,
m_weekday_long_names[tm_value.tm_wday]);
}
if (m_weekday_short_names.size()) {
boost::algorithm::replace_all(a_format,
short_weekday_format,
m_weekday_short_names[tm_value.tm_wday]);
}
if (m_month_long_names.size()) {
boost::algorithm::replace_all(a_format,
long_month_format,
m_month_long_names[tm_value.tm_mon]);
}
if (m_month_short_names.size()) {
boost::algorithm::replace_all(a_format,
short_month_format,
m_month_short_names[tm_value.tm_mon]);
}
// use time_put facet to create final string
const char_type* p_format = a_format.c_str();
return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios,
fill_char,
&tm_value,
p_format,
p_format + a_format.size());
}
示例7: get
InputIterator get(
iter_type b, iter_type e,
std::ios_base& iob,
std::ios_base::iostate& err,
std::tm* tm,
char fmt, char) const
{
err = std::ios_base::goodbit;
const std::ctype<char_type>& ct = std::use_facet<std::ctype<char_type> >(iob.getloc());
switch (fmt)
{
case 'a':
case 'A':
{
std::tm tm2;
std::memset(&tm2, 0, sizeof(std::tm));
that_.get_weekday(b, e, iob, err, &tm2);
//tm->tm_wday = tm2.tm_wday;
}
break;
case 'b':
case 'B':
case 'h':
{
std::tm tm2;
std::memset(&tm2, 0, sizeof(std::tm));
that_.get_monthname(b, e, iob, err, &tm2);
//tm->tm_mon = tm2.tm_mon;
}
break;
// case 'c':
// {
// const string_type& fm = c();
// b = get(b, e, iob, err, tm, fm.data(), fm.data() + fm.size());
// }
// break;
case 'd':
case 'e':
get_day(tm->tm_mday, b, e, err, ct);
break;
case 'D':
{
const char_type fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'};
b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
}
break;
case 'F':
{
const char_type fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'};
b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
}
break;
case 'H':
get_hour(tm->tm_hour, b, e, err, ct);
break;
case 'I':
get_12_hour(tm->tm_hour, b, e, err, ct);
break;
case 'j':
get_day_year_num(tm->tm_yday, b, e, err, ct);
break;
case 'm':
get_month(tm->tm_mon, b, e, err, ct);
break;
case 'M':
get_minute(tm->tm_min, b, e, err, ct);
break;
case 'n':
case 't':
get_white_space(b, e, err, ct);
break;
// case 'p':
// get_am_pm(tm->tm_hour, b, e, err, ct);
// break;
case 'r':
{
const char_type fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'};
b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
}
break;
case 'R':
{
const char_type fm[] = {'%', 'H', ':', '%', 'M'};
b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
}
break;
case 'S':
get_second(tm->tm_sec, b, e, err, ct);
break;
case 'T':
{
const char_type fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
b = get(b, e, iob, err, tm, fm, fm + sizeof(fm)/sizeof(fm[0]));
}
break;
case 'w':
{
get_weekday(tm->tm_wday, b, e, err, ct);
}
//.........这里部分代码省略.........
示例8: put_value
iter_type put_value(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const
{
return std::use_facet<std::num_put<CharT, iter_type> >(ios.getloc()).put(s, ios, fill,
static_cast<long int> (d.count()));
}