当前位置: 首页>>代码示例>>C++>>正文


C++ ios_base::imbue方法代码示例

本文整理汇总了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;
}
开发者ID:Naoyuki-Yatsuda,项目名称:griddb_nosql,代码行数:7,代码来源:type.cpp

示例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));
        }
开发者ID:toddmallen,项目名称:the_coldest_sea,代码行数:45,代码来源:date_facet.hpp

示例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
}
开发者ID:KenQingjianWu,项目名称:VS2015_Tesseract,代码行数:19,代码来源:PdfLocale.cpp

示例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());
      }

    }
开发者ID:imos,项目名称:icfpc2015,代码行数:21,代码来源:date_facet.hpp


注:本文中的std::ios_base::imbue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。