本文整理汇总了C++中std::ios_base::imbue方法的典型用法代码示例。如果您正苦于以下问题:C++ ios_base::imbue方法的具体用法?C++ ios_base::imbue怎么用?C++ ios_base::imbue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::ios_base
的用法示例。
在下文中一共展示了ios_base::imbue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
void LocaleUtils::CLocaleScope::set(std::ios_base &baseStream) {
assert(orgLocale_ == NULL);
orgLocale_ = new (static_cast<void*>(&orgLocaleStorage_)) std::locale(
baseStream.imbue(getCLocale()));
baseStream_ = &baseStream;
}
示例2: get
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& a_ios,
duration_type& dd) const
{
// skip leading whitespace
while(std::isspace(*from) && from != to) {
++from;
}
/* num_get.get() will always consume the first character if it
* is a sign indicator (+/-). Special value strings may begin
* with one of these signs so we'll need a copy of it
* in case num_get.get() fails. */
char_type c = '\0';
// TODO Are these characters somewhere in the locale?
if(*from == '-' || *from == '+') {
c = *from;
}
typedef std::num_get<CharT, InItrT> num_get;
typename duration_type::duration_rep_type val = 0;
std::ios_base::iostate err = std::ios_base::goodbit;
if (std::has_facet<num_get>(a_ios.getloc())) {
from = std::use_facet<num_get>(a_ios.getloc()).get(from, to, a_ios, err, val);
}
else {
num_get* ng = new num_get();
std::locale l = std::locale(a_ios.getloc(), ng);
a_ios.imbue(l);
from = ng->get(from, to, a_ios, err, val);
}
if(err & std::ios_base::failbit) {
typedef typename special_values_parser_type::match_results match_results;
match_results mr;
if(c == '-' || c == '+') { // was the first character consumed?
mr.cache += c;
}
m_sv_parser.match(from, to, mr);
if(mr.current_match == match_results::PARSE_ERROR) {
boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return from); // should never reach
}
dd = duration_type(static_cast<special_values>(mr.current_match));
}
示例3: PdfLocaleImbue
void PdfLocaleImbue(std::ios_base& s)
{
#if USE_CXX_LOCALE
static const std::locale cachedLocale( PdfIOLocale );
try {
s.imbue( cachedLocale );
} catch (const std::runtime_error & e) {
std::ostringstream s;
s << "Failed to set safe locale on stream being used for PDF I/O.";
s << "Locale set was: \"" << PdfIOLocale << "\".";
s << "Error reported by STL std::locale: \"" << e.what() << "\"";
// The info string is copied by PdfError so we're ok to just:
PODOFO_RAISE_ERROR_INFO(
ePdfError_InvalidDeviceOperation,
s.str().c_str()
);
}
#endif
}
示例4: put
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const duration_type& dd) const
{
if (dd.is_special()) {
return do_put_special(next, a_ios, fill_char, dd.get_rep().as_special());
}
typedef std::num_put<CharT, OutItrT> num_put;
if (std::has_facet<num_put>(a_ios.getloc())) {
return std::use_facet<num_put>(a_ios.getloc()).put(next, a_ios, fill_char, dd.get_rep().as_number());
}
else {
num_put* f = new num_put();
std::locale l = std::locale(a_ios.getloc(), f);
a_ios.imbue(l);
return f->put(next, a_ios, fill_char, dd.get_rep().as_number());
}
}