C/C++的格式化输出(6)--format分析

来源:互联网 发布:ddos 阿里云 编辑:程序博客网 时间:2024/06/05 15:47
头文件
  • format.hpp 面向用户的,使用时包含该头文件即可
  • format_fwd.hpp 用户前向声明的
  • format_class.hpp 类接口
  • format_implementation.hpp: 成员实现
  • feed_args.hpp 参数传送帮助函数
  • free_funcs.hpp 自由函数定义
  • parsing.hpp 提供解析格式化字符串的代码
  • group.hpp 用于组参数和操纵子的辅助结构
  • exceptions.hpp 这个库用到的异常
  • internals.hpp 流格式状态和格式化项的辅助结构

  • format.hpp
面向用户的,使用时包含该头文件即可
  • format_fwd.hpp
主要是typedef basic_format    format;
  • format_class.hpp
主要是typedef basic_format    format;
namespace boost {
    classbasic_format 
    {
       //两种类型的构造函数,同时调用解析函数进行对格式串解析
       basic_format(const Ch* str=NULL);
       basic_format(const string_type&s);
       // **进行参数绑定,获得参数** //
       template  
       basic_format&  operator%(const T& x);
       //输出:根据格式串和参数进行输出
       friend std::ostream &operator<<( std::ostream& ,const basic_format& );
    private:
       std::vector  items_; //格式串解析后的每一项,以%开始format_item
       std::vector bound_; //是否绑定
       mutable bool    dumped_; //在调用str()或<<操作符后设为true
       string_type     prefix_; //在第一项之前的直接输出的字符串
    }; // classbasic_format
} // namespace boost






0 0