• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ std::ios_base类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中std::ios_base的典型用法代码示例。如果您正苦于以下问题:C++ ios_base类的具体用法?C++ ios_base怎么用?C++ ios_base使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ios_base类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: callback

void callback(std::ios_base::event ev, std::ios_base& strm, int idx)
    {
    if (ev == std::ios_base::erase_event)
        {
        try
            {
            delete static_cast<NewFormat*>(strm.pword(idx));

            strm.pword(idx) = 0;
            }
        catch (...)
            { }
        }
    else if (ev == std::ios_base::copyfmt_event)
        {
        NewFormat* old(static_cast<NewFormat*>(strm.pword(idx)));

        if (old != 0)
            {
            try
                {
                strm.pword(idx) = new NewFormat(*old);
                }
            catch (std::bad_alloc&)
                { }
            }
        }
    }
开发者ID:Ablu,项目名称:freeorion,代码行数:28,代码来源:iomanip.hpp


示例2: replace_pword

void replace_pword(std::ios_base& iob, int idx, const T& x) {
    iob.register_callback(callback<NewFormat>, idx);

    NewFormat* new_format(new NewFormat(x));
    OldFormat* old_format(static_cast<OldFormat*>(iob.pword(idx)));
    iob.pword(idx) = new_format;
    delete old_format;
}
开发者ID:ilelann,项目名称:adobe_source_libraries,代码行数:8,代码来源:iomanip.hpp


示例3: my_ios_callback

// Stream format gets copied or destroyed
static void my_ios_callback(std::ios_base::event ev, std::ios_base & s, int i)
{
	print_context *p = static_cast<print_context *>(s.pword(i));
	if (ev == std::ios_base::erase_event) {
		delete p;
		s.pword(i) = nullptr;
	} else if (ev == std::ios_base::copyfmt_event && p != nullptr)
		s.pword(i) = p->duplicate();
}
开发者ID:feelpp,项目名称:feelpp,代码行数:10,代码来源:operators.cpp


示例4: cleanup

void cleanup(std::ios_base::event evt, std::ios_base& str, int idx)
{
    if (str.iword(separatorEnabled()) && evt == std::ios_base::erase_event)
    {
        void*& p = str.pword(idx);
        delete static_cast<std::string*>(p);
        str.iword(separatorEnabled()) = false; 
    }
}
开发者ID:CCJY,项目名称:coliru,代码行数:9,代码来源:main.cpp


示例5: put

    OutItrT put(OutItrT a_next, 
                std::ios_base& a_ios, 
                char_type a_fill, 
                const time_type& a_time) const 
    {
      if (a_time.is_special()) { 
        return do_put_special(a_next, a_ios, a_fill, 
                              a_time.date().as_special());
      }
      string_type format(m_format);
      string_type frac_str;
      if (format.find(seconds_with_fractional_seconds_format)) {
        // replace %s with %S.nnn 
        frac_str = 
          fractional_seconds_as_string(a_time.time_of_day(), false);
        char_type sep = std::use_facet<std::numpunct<char_type> >(a_ios.getloc()).decimal_point();
        
        string_type replace_string(seconds_format);
        replace_string += sep;
        replace_string += frac_str;
        boost::algorithm::replace_all(format, 
                                      seconds_with_fractional_seconds_format, 
                                      replace_string);
      }
      if (format.find(fractional_seconds_format)) {
        // replace %f with nnnnnnn
        if (!frac_str.size()) {
          frac_str = fractional_seconds_as_string(a_time.time_of_day(), false);
        }
        boost::algorithm::replace_all(format,
                                      fractional_seconds_format, 
                                      frac_str);
      }

      if (format.find(fractional_seconds_or_none_format)) {
        // replace %F with nnnnnnn or nothing if fs == 0
        frac_str = 
          fractional_seconds_as_string(a_time.time_of_day(), true);
        if (frac_str.size()) {
          char_type sep = std::use_facet<std::numpunct<char_type> >(a_ios.getloc()).decimal_point();
          string_type replace_string;
          replace_string += sep;
          replace_string += frac_str;
          boost::algorithm::replace_all(format,
                                        fractional_seconds_or_none_format, 
                                        replace_string);
        }
        else {
          boost::algorithm::erase_all(format,
                                      fractional_seconds_or_none_format);
        }
      }

      return do_put_tm(a_next, a_ios, a_fill, 
                       to_tm(a_time), format);
    }
开发者ID:dmm,项目名称:cegis,代码行数:56,代码来源:time_facet.hpp


示例6: d

 format_parser::format_parser(std::ios_base &ios,void *cookie,void (*imbuer)(void *,std::locale const &)) : 
     ios_(ios),
     d(new data)
 {
     d->position=std::numeric_limits<unsigned>::max();
     d->precision=ios.precision();
     d->flags = ios.flags();
     d->info=ios_info::get(ios);
     d->saved_locale = ios.getloc();
     d->restore_locale=false;
     d->cookie = cookie;
     d->imbuer = imbuer;
 }
开发者ID:Kaoschuks,项目名称:cppcms,代码行数:13,代码来源:format.cpp


示例7: put_duration

 iter_type put_duration(iter_type i, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const
 {
   if (std::has_facet<duration_put<CharT> >(ios.getloc()))
   {
     duration_put<CharT> const &facet = std::use_facet<duration_put<CharT> >(ios.getloc());
     return facet.put(i, ios, fill, d);
   }
   else
   {
     duration_put<CharT> facet;
     return facet.put(i, ios, fill, d);
   }
 }
开发者ID:c-zheng,项目名称:autowiring,代码行数:13,代码来源:time_point_put.hpp


示例8: set_stream_state

bool logstream_base::set_stream_state(std::ios_base& dest, int& dstchar) {
     std::ios_base::fmtflags setval = initset.flags();
     std::ios_base::fmtflags clrval = initclear.flags();
     std::ios_base::fmtflags mask = setval ^ (~clrval);
     dest.setf(clrval, mask);
     if (initset.precision() == initclear.precision()) {
         dest.precision(initset.precision());
     }
     if (initset.width() == initclear.width()) {
         dest.width(initset.width());
     }
     dstchar = fillchar;
     return fillset;
}
开发者ID:delta1766,项目名称:logging-log4cxx,代码行数:14,代码来源:logstream.cpp


示例9: get_duration

 iter_type get_duration(iter_type i, iter_type e, std::ios_base& is, std::ios_base::iostate& err,
     duration<Rep, Period>& d) const
 {
   if (std::has_facet<duration_get<CharT> >(is.getloc()))
   {
     duration_get<CharT> const &facet = std::use_facet<duration_get<CharT> >(is.getloc());
     return get_duration(facet, i, e, is, err, d);
   }
   else
   {
     duration_get<CharT> facet;
     return get_duration(facet, i, e, is, err, d);
   }
 }
开发者ID:ALuehmann,项目名称:labstreaminglayer,代码行数:14,代码来源:time_point_get.hpp


示例10: put_unit

 iter_type put_unit(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const
 {
   if (std::has_facet<duration_units<CharT> >(ios.getloc()))
   {
     duration_units<CharT> const&facet = std::use_facet<duration_units<CharT> >(
         ios.getloc());
     return put_unit(facet, s, ios, fill, d);
   }
   else
   {
     duration_units_default<CharT> facet;
     return put_unit(facet, s, ios, fill, d);
   }
 }
开发者ID:AsherBond,项目名称:PDAL,代码行数:14,代码来源:duration_put.hpp


示例11: put

 iter_type put(iter_type i, std::ios_base& ios, char_type fill, time_point<Clock, Duration> const& tp, const CharT* pattern,
     const CharT* pat_end) const
 {
   if (std::has_facet<time_point_units<CharT> >(ios.getloc()))
   {
     time_point_units<CharT> const &facet =
         std::use_facet<time_point_units<CharT> >(ios.getloc());
     return put(facet, i, ios, fill, tp, pattern, pat_end);
   }
   else
   {
     time_point_units_default<CharT> facet;
     return put(facet, i, ios, fill, tp, pattern, pat_end);
   }
 }
开发者ID:c-zheng,项目名称:autowiring,代码行数:15,代码来源:time_point_put.hpp


示例12: set_print_context

// Set print_context associated with stream, retain options
static void set_print_context(std::ios_base & s, const print_context & c)
{
	int i = my_ios_index();
	long flags = s.iword(i);
	if (!(flags & callback_registered)) {
		s.register_callback(my_ios_callback, i);
		s.iword(i) = flags | callback_registered;
	}
	print_context *p = static_cast<print_context *>(s.pword(i));
	unsigned options = p ? p->options : c.options;
	delete p;
	p = c.duplicate();
	p->options = options;
	s.pword(i) = p;
}
开发者ID:feelpp,项目名称:feelpp,代码行数:16,代码来源:operators.cpp


示例13: 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


示例14: put

 iter_type put(iter_type s, std::ios_base& ios, char_type fill, duration<Rep, Period> const& d) const
 {
   if (std::has_facet<duration_units<CharT> >(ios.getloc()))
   {
     duration_units<CharT> const&facet = std::use_facet<duration_units<CharT> >(
         ios.getloc());
     std::basic_string<CharT> str = facet.get_pattern();
     return put(facet, s, ios, fill, d, str.data(), str.data() + str.size());
   }
   else
   {
     duration_units_default<CharT> facet;
     std::basic_string<CharT> str = facet.get_pattern();
     return put(facet, s, ios, fill, d, str.data(), str.data() + str.size());
   }
 }
开发者ID:AsherBond,项目名称:PDAL,代码行数:16,代码来源:duration_put.hpp


示例15: 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


示例16: get

 InputIterator get(
   iter_type b, iter_type e,
   std::ios_base& iob,
   std::ios_base::iostate& err, std::tm* tm,
   const char_type* fmtb, const char_type* fmte) const
 {
   const std::ctype<char_type>& ct = std::use_facet<std::ctype<char_type> >(iob.getloc());
   err = std::ios_base::goodbit;
   while (fmtb != fmte && err == std::ios_base::goodbit)
   {
       if (b == e)
       {
           err = std::ios_base::failbit;
           break;
       }
       if (ct.narrow(*fmtb, 0) == '%')
       {
           if (++fmtb == fmte)
           {
               err = std::ios_base::failbit;
               break;
           }
           char cmd = ct.narrow(*fmtb, 0);
           char opt = '\0';
           if (cmd == 'E' || cmd == '0')
           {
               if (++fmtb == fmte)
               {
                   err = std::ios_base::failbit;
                   break;
               }
               opt = cmd;
               cmd = ct.narrow(*fmtb, 0);
           }
           b = get(b, e, iob, err, tm, cmd, opt);
           ++fmtb;
       }
       else if (ct.is(std::ctype_base::space, *fmtb))
       {
           for (++fmtb; fmtb != fmte && ct.is(std::ctype_base::space, *fmtb); ++fmtb)
               ;
           for (        ;    b != e    && ct.is(std::ctype_base::space, *b);    ++b)
               ;
       }
       else if (ct.toupper(*b) == ct.toupper(*fmtb))
       {
           ++b;
           ++fmtb;
       }
       else
           err = std::ios_base::failbit;
   }
   if (b == e)
       err |= std::ios_base::eofbit;
   return b;
 }
开发者ID:AlexMioMio,项目名称:boost,代码行数:56,代码来源:time_point_io.hpp


示例17: 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


示例18: f3

void f3(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(!f3_called);
        assert(stream.getloc().name() == "C");
        assert(index == 6);
        f3_called = true;
    }
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:12,代码来源:dtor.pass.cpp


示例19: f3

void f3(std::ios_base::event ev, std::ios_base& stream, int index)
{
    if (ev == std::ios_base::imbue_event)
    {
        assert(!f1_called);
        assert(!f2_called);
        assert(!f3_called);
        assert(stream.getloc().name() == LOCALE_en_US_UTF_8);
        assert(index == 6);
        f3_called = true;
    }
}
开发者ID:32bitmicro,项目名称:riscv-libcxx,代码行数:12,代码来源:imbue.pass.cpp


示例20: 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类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ std::iostream类代码示例发布时间:2022-05-31
下一篇:
C++ std::ios类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap