Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

Class template basic_formatting_ostream

Boost , Chapter 1. Boost.Log v2 , Utilities

Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Class template basic_formatting_ostream

boost::log::basic_formatting_ostream — Stream wrapper for log records formatting.

Synopsis

// In header: <boost/log/utility/formatting_ostream.hpp>
template<typename CharT, typename TraitsT, typename AllocatorT> 
class basic_formatting_ostream {
public:
  // types
  typedef CharT                                        char_type;       // Character type. 
  typedef TraitsT                                      traits_type;     // Character traits. 
  typedef AllocatorT                                   allocator_type;  // Memory allocator. 
  typedef unspecified                                  streambuf_type;  // Stream buffer type. 
  typedef streambuf_type::string_type                  string_type;     // Target string type. 
  typedef std::basic_ostream< char_type, traits_type > ostream_type;    // Stream type. 
  typedef ostream_type::pos_type                       pos_type;        // Stream position type. 
  typedef ostream_type::off_type                       off_type;        // Stream offset type. 
  typedef ostream_type::int_type                       int_type;        // Integer type for characters. 
  typedef ostream_type::failure                        failure;       
  typedef ostream_type::fmtflags                       fmtflags;      
  typedef ostream_type::iostate                        iostate;       
  typedef ostream_type::openmode                       openmode;      
  typedef ostream_type::seekdir                        seekdir;       
  typedef ostream_type::Init                           Init;          
  typedef ostream_type::event                          event;         
  typedef ostream_type::event_callback                 event_callback;
  // member classes/structs/unions
  class sentry : public sentry {
  public:
    // construct/copy/destruct
    explicit sentry(basic_formatting_ostream &);
    sentry(sentry const &) = delete;
    sentry & operator=(sentry const &) = delete;
    // public member functions
    explicit operator bool() const;
    bool operator!() const;
  };
  // construct/copy/destruct
  basic_formatting_ostream();
  explicit basic_formatting_ostream(string_type &);
  basic_formatting_ostream(basic_formatting_ostream const &) = delete;
  basic_formatting_ostream & 
  operator=(basic_formatting_ostream const &) = delete;
  ~basic_formatting_ostream();
  // public member functions
  void attach(string_type &);
  void detach();
  string_type const & str() const;
  ostream_type & stream();
  ostream_type const & stream() const;
  fmtflags flags() const;
  fmtflags flags(fmtflags);
  fmtflags setf(fmtflags);
  fmtflags setf(fmtflags, fmtflags);
  void unsetf(fmtflags);
  std::streamsize precision() const;
  std::streamsize precision(std::streamsize);
  std::streamsize width() const;
  std::streamsize width(std::streamsize);
  std::locale getloc() const;
  std::locale imbue(std::locale const &);
  long & iword(int);
  void *& pword(int);
  void register_callback(event_callback, int);
  explicit operator bool() const;
  bool operator!() const;
  iostate rdstate() const;
  void clear(iostate = goodbit);
  void setstate(iostate);
  bool good() const;
  bool eof() const;
  bool fail() const;
  bool bad() const;
  iostate exceptions() const;
  void exceptions(iostate);
  ostream_type * tie() const;
  ostream_type * tie(ostream_type *);
  streambuf_type * rdbuf() const;
  basic_formatting_ostream & 
  copyfmt(std::basic_ios< char_type, traits_type > &);
  basic_formatting_ostream & copyfmt(basic_formatting_ostream &);
  char_type fill() const;
  char_type fill(char_type);
  char narrow(char_type, char) const;
  char_type widen(char) const;
  basic_formatting_ostream & flush();
  pos_type tellp();
  basic_formatting_ostream & seekp(pos_type);
  basic_formatting_ostream & seekp(off_type, std::ios_base::seekdir);
  basic_formatting_ostream & put(char_type);
  template<typename OtherCharT> unspecified put(OtherCharT);
  basic_formatting_ostream & write(const char_type *, std::streamsize);
  template<typename OtherCharT> 
    unspecified write(const OtherCharT *, std::streamsize);
  basic_formatting_ostream & operator<<(ios_base_manip);
  basic_formatting_ostream & operator<<(basic_ios_manip);
  basic_formatting_ostream & operator<<(stream_manip);
  basic_formatting_ostream & operator<<(char);
  basic_formatting_ostream & operator<<(const char *);
  basic_formatting_ostream & operator<<(wchar_t);
  basic_formatting_ostream & operator<<(const wchar_t *);
  basic_formatting_ostream & operator<<(char16_t);
  basic_formatting_ostream & operator<<(const char16_t *);
  basic_formatting_ostream & operator<<(char32_t);
  basic_formatting_ostream & operator<<(const char32_t *);
  basic_formatting_ostream & operator<<(bool);
  basic_formatting_ostream & operator<<(signed char);
  basic_formatting_ostream & operator<<(unsigned char);
  basic_formatting_ostream & operator<<(short);
  basic_formatting_ostream & operator<<(unsigned short);
  basic_formatting_ostream & operator<<(int);
  basic_formatting_ostream & operator<<(unsigned int);
  basic_formatting_ostream & operator<<(long);
  basic_formatting_ostream & operator<<(unsigned long);
  basic_formatting_ostream & operator<<(long long);
  basic_formatting_ostream & operator<<(unsigned long long);
  basic_formatting_ostream & operator<<(float);
  basic_formatting_ostream & operator<<(double);
  basic_formatting_ostream & operator<<(long double);
  basic_formatting_ostream & operator<<(const void *);
  basic_formatting_ostream & 
  operator<<(std::basic_streambuf< char_type, traits_type > *);
  // public static functions
  static int xalloc();
  static bool sync_with_stdio(bool = true);
  // protected member functions
  void init_stream();
  // private member functions
  basic_formatting_ostream & 
  formatted_write(const char_type *, std::streamsize);
  template<typename OtherCharT> 
    basic_formatting_ostream & 
    formatted_write(const OtherCharT *, std::streamsize);
  void aligned_write(const char_type *, std::streamsize);
  template<typename OtherCharT> 
    void aligned_write(const OtherCharT *, std::streamsize);
  // public data members
  static constexpr fmtflags boolalpha;
  static constexpr fmtflags dec;
  static constexpr fmtflags fixed;
  static constexpr fmtflags hex;
  static constexpr fmtflags internal;
  static constexpr fmtflags left;
  static constexpr fmtflags oct;
  static constexpr fmtflags right;
  static constexpr fmtflags scientific;
  static constexpr fmtflags showbase;
  static constexpr fmtflags showpoint;
  static constexpr fmtflags skipws;
  static constexpr fmtflags unitbuf;
  static constexpr fmtflags uppercase;
  static constexpr fmtflags adjustfield;
  static constexpr fmtflags basefield;
  static constexpr fmtflags floatfield;
  static constexpr iostate badbit;
  static constexpr iostate eofbit;
  static constexpr iostate failbit;
  static constexpr iostate goodbit;
  static constexpr openmode app;
  static constexpr openmode ate;
  static constexpr openmode binary;
  static constexpr openmode in;
  static constexpr openmode out;
  static constexpr openmode trunc;
  static constexpr seekdir beg;
  static constexpr seekdir cur;
  static constexpr seekdir end;
  static constexpr event erase_event;
  static constexpr event imbue_event;
  static constexpr event copyfmt_event;
};

Description

Поток для форматирования записей журналов.

Эта обертка потока используется библиотекой для форматирования записей журнала. Он реализует стандартный интерфейс струнного потока с несколькими отличиями:

  • Он не вытекает из стандартных типов.std::basic_ostream,std::basic_iosиstd::ios_base, хотя и пытается реализовать их интерфейсы вплотную. Есть несколько небольших различий, в основном в отношении подписейrdbufиstr, а также поддерживаемых перегрузок оператора вставки. Реальный обернутый поток может быть доступен с помощью методовпотока.

  • По умолчанию значенияboolформатируются с использованием алфавитного представления, а не числового.

  • Поток поддерживает написание строк типов символов, отличающихся от типа символа потока. Поток будет выполнять преобразование кода символов по мере необходимости с использованием встроенной локализации.

  • Поток работает на внешнем струнном объекте, а не на встроенном. Струна может быть присоединена или отсоединена от потока динамически.

Хотяbasic_formatting_ostreamне происходит отstd::basic_ostream, пользователям не требуется добавлять специальные перегрузкиоператора<<для него, поскольку поток по умолчанию будет повторно использовать операторов дляstd::basic_ostream. Однако можно определить специальные перегрузкиоператора<<дляbasic_formatting_ostream, если определенный тип нуждается в специальном форматировании при выходе в журнал.

basic_formatting_ostream public construct/copy/destruct

  1. basic_formatting_ostream;

    Конструктор по умолчанию. Создает пустую запись, которая эквивалентна недействительной ручке записи. Возможности потока не доступны после строительства.

    Пост-условия:

    !* это == истинно

  • эксплицитноbasic_formatting_ostreamstring_type&str;

    Инициирующий конструктор. Прикрепляет струну к построенному потоку. Струна будет использоваться для хранения отформатированных символов.

    Параметры:

    Постусловия:

    !* это == ложно

  • basic_formatting_ostreambasic_formatting_ostreamconst&, что=удалить;
    Копировать конструктор (закрыто)
  • basic_formatting_ostream&оператор=basic_formatting_ostreamconst&, что=удалить;
    Назначение (закрыто]
  • ~basic_formatting_ostream;

    Деструктор. Уничтожает запись, выпускает любые поглотители и значения атрибутов, которые были задействованы в обработке этой записи.

  • basic_formatting_ostream public member functions

    1. voidприкрепитьstring_type&str;

      Привязывает поток к струне. Струна будет использоваться для хранения отформатированных символов.

      Параметры:

      Струнный буфер для крепления.

    2. пустотаотсоединить;

      Отделяет поток от струны. Любые буферизованные данные смываются в строку.

    3. строка_типconst&strconst;

      Возвращение:

      Ссылка на прилагаемую строку. Струна должна быть прикреплена перед вызовом этого метода.

    4. ostream_type&;

      Ссылка на обернутый поток

    5. ostream_typeconst&const;

      Ссылка на обернутый поток

  • флагифлагиконст;
  • fmtflagsфлагиfmtflags;
  • fmtflagssetffmtflags;
  • fmtflagssetffmtflagsf,fmtflagsмаска;
  • voidunsetffmtflags;
  • std::потоковаяточностьконст;
  • std::StreamsizePrecisionstd::Streamsizep;
  • std::потоковаяширинаконст;
  • std::streamsizewidthstd::streamsizew;
  • std::localegetlocconst;
  • std::localeimbuestd::localeconst&loc;
  • длинный&iwordintиндекс;
  • void*&pwordint];
  • voidregister_callbackevent_callbackfn,int];
  • эксплицитныйоператорбоолконст;
  • booloperator!const;
  • iostaterdstateconst;
  • voidcleariostate=goodbit;
  • voidsetstateiostate;
  • boolgoodconst;
  • booleofconst;
  • boolfailconst;
  • boolbadconst;
  • iostateисключенияconst;
  • voidИсключенияiostate;
  • ostream_type*tieconst;
  • ostream_type*tieostream_typestrm;
  • streambuf_type*rdbufconst;
  • basic_formatting_ostream&copyfmtstd::basic_ios<char_type,traits_type>&rhs;
  • basic_formatting_ostream&copyfmtbasic_formatting_ostream&rhs;
  • char_typefillconst;
  • char_typefill
  • charузкоchar_typech,chardefconst;
  • char_typeрасширяетcharch]const;
  • basic_formatting_ostream&flush;
  • pos_typeTellp;
  • basic_formatting_ostream&seekppos_typepos;
  • basic_formatting_ostream&seekpoff_typeoff,std::ios_base::seekdirdir;
  • basic_formatting_ostream&putchar_typec;
  • шаблон<имя типаOtherCharT>неуточненныйпоставитьc;
  • basic_formatting_ostream&writeconstchar_typep,std::streamsize;
  • шаблон<имя типаOtherCharT>неуказанныйнапишитеconst*p,std::потоковыйразмер;
    ;;;;;[12
  • basic_formatting_ostream&оператор<<ios_base_manipманип;
  • basic_formatting_ostream&оператор<<basic_ios_manipманип;
  • basic_formatting_ostream&оператор<<stream_manipманип];
  • basic_formatting_ostream&оператор<<charc];
  • basic_formatting_ostream&оператор<<constcharp;;
  • basic_formatting_ostream&оператор<<wchar_tc;
  • basic_formatting_ostream&оператор<<constwchar_t*p;
  • basic_formatting_ostream&оператор<<char16_t];
  • basic_formatting_ostream&оператор<<constchar16_tp;;
  • basic_formatting_ostream&оператор<<char32_tc;
  • basic_formatting_ostream&оператор<<constchar32_tp;
  • basic_formatting_ostream&оператор<<значение];
  • basic_formatting_ostream&оператор<<подписанchar];
  • basic_formatting_ostream&оператор<<unsignedchar];
  • basic_formatting_ostream&оператор<<короткоезначение;
  • basic_formatting_ostream&оператор<<unsignedshort];
  • basic_formatting_ostream&оператор<<int];
  • basic_formatting_ostream&оператор<<unsignedint];
  • basic_formatting_ostream&оператор<<длинноезначение];
  • basic_formatting_ostream&оператор<<unsignedlong];
  • basic_formatting_ostream&оператор<<longlong];
  • basic_formatting_ostream&оператор<<unsignedlonglong];
  • basic_formatting_ostream&оператор<<float];
  • basic_formatting_ostream&оператор<<двойноезначение;
  • basic_formatting_ostream&оператор<<longdoubleзначение;
  • basic_formatting_ostream&оператор<<constvoid*];
  • basic_formatting_ostream&операторstd::basic_streambuf<char_type,traits_type>*buf;
  • basic_formatting_ostream public static functions

    1. статическийintxalloc;
    2. статическийboolsync_with_stdioboolsync=истинный;

    basic_formatting_ostream protected member functions

    1. voidinit_stream;

    basic_formatting_ostream private member functions

    1. basic_formatting_ostream&formated_writeconstchar_typep,std::streamsizeразмер;
    2. шаблон<имя типаOtherCharT>basic_formatting_ostream&отформатированный_writeconst*p,std::потоковыйразмер;
    3. voidaligned_writeconstchar_typep,std::streamsizeразмер;
    4. шаблон<имя типаOtherCharT>voidвыровненный_writeconststd::потоковыйразмер;

    PrevUpHomeNext

    Статья Class template basic_formatting_ostream раздела Chapter 1. Boost.Log v2 Utilities может быть полезна для разработчиков на c++ и boost.




    Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



    :: Главная :: Utilities ::


    реклама


    ©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
    Top.Mail.Ru

    Время компиляции файла: 2024-08-30 11:47:00
    2025-05-20 02:26:48/0.0080990791320801/0