Skip to main content
added 13 characters in body
Source Link
zaufi
  • 7.2k
  • 30
  • 35

The simplest way is to imheritinherit std::streambuf and override just two methods:

  • std::streamsize xsputn(const char_type* s, std::streamsize n) – to append a given buffer with size provided to your internal buffer, std::string for exampleexample;
  • int_type overflow(int_type c) to append a single char to your internal buffer.

Your streambuf can be construnctedconstructed from whatever you want (DB connection for example). After append something into the internal buffer you may try to split it into lines and push something into DB (or just buffer an SQL statements to execute later).

To use it: just attach your streambufstreambuf to any std::ostream using constructor.

Simple! I've done something like this to output strings to syslog – everything works fine with any custom operator<< for user defined classes.

The simplest way is to imherit std::streambuf and override just two methods:

  • std::streamsize xsputn(const char_type* s, std::streamsize n) – to append a given buffer with size provided to your internal std::string for example
  • int_type overflow(int_type c) to append a single char to your internal buffer.

Your streambuf can be construncted from whatever you want (DB connection for example). After append something into the internal buffer you may try to split it into lines and push something into DB (or just buffer an SQL statements to execute later).

To use it just attach your streambuf to any std::ostream using constructor.

Simple! I've done something like this to output strings to syslog – everything works fine with any custom operator<< for user defined classes.

The simplest way is to inherit std::streambuf and override just two methods:

  • std::streamsize xsputn(const char_type* s, std::streamsize n) – to append a given buffer with size provided to your internal buffer, std::string for example;
  • int_type overflow(int_type c) to append a single char to your internal buffer.

Your streambuf can be constructed from whatever you want (DB connection for example). After append something into the internal buffer you may try to split it into lines and push something into DB (or just buffer an SQL statements to execute later).

To use it: just attach your streambuf to any std::ostream using constructor.

Simple! I've done something like this to output strings to syslog – everything works fine with any custom operator<< for user defined classes.

added 1 characters in body
Source Link
zaufi
  • 7.2k
  • 30
  • 35

The simplest way is to imherit std::streambuf and override just two methods:

  • std::streamsize xsputn(const char_type* s, std::streamsize n) – to append a given buffer with size provided to your internal std::string for example
  • int_type overflow(int_type c) to append a single char to your internal buffer.

Your streambuf can be construncted from whatever you want (DB connection for example). After append something into the internal buffer you may try to split it into lines and push something into DB (or just buffer an SQL statements to execute later).

To use it just attach your streambuf to any std::ostream using constructor or imbue() rigth after creation.

Simple! I've done something like this to output strings to syslog – everything works fine with any custom operator<< for user defined classes.

The simplest way is to imherit std::streambuf and override just two methods:

  • std::streamsize xsputn(const char_type* s, std::streamsize n) – to append a given buffer with size provided to your internal std::string for example
  • int_type overflow(int_type c) to append a single char to your internal buffer.

Your streambuf can be construncted from whatever you want (DB connection for example). After append something into the internal buffer you may try to split it into lines and push something into DB (or just buffer an SQL statements to execute later).

To use it just attach your streambuf to any std::ostream using constructor or imbue() rigth after creation.

Simple! I've done something like this to output strings to syslog – everything works fine with any custom operator<< for user defined classes.

The simplest way is to imherit std::streambuf and override just two methods:

  • std::streamsize xsputn(const char_type* s, std::streamsize n) – to append a given buffer with size provided to your internal std::string for example
  • int_type overflow(int_type c) to append a single char to your internal buffer.

Your streambuf can be construncted from whatever you want (DB connection for example). After append something into the internal buffer you may try to split it into lines and push something into DB (or just buffer an SQL statements to execute later).

To use it just attach your streambuf to any std::ostream using constructor.

Simple! I've done something like this to output strings to syslog – everything works fine with any custom operator<< for user defined classes.

added 1 characters in body
Source Link
zaufi
  • 7.2k
  • 30
  • 35

The simplest way is to imherit std::streambufstd::streambuf and override just two methods:

  • std::streamsize xsputn(const char_type* s, std::streamsize n) – to append a given buffer with size provided to your internal std::string for example
  • int_type overflow(int_type c) to append a single char to your internal buffer.

Your streambuf can be construncted from whatever you want (DB connection for example). After append something into the internal buffer you may try to split it into lines and push something into DB (or just buffer an SQL statements to execute later).

To use it just attach youyour streambuf to any std::ostream using constructor or imbue() rigth after creation.

Simple! I've done something like this to output strings to syslog – everything works fine with any custom operator<< for user defined classes.

The simplest way is to imherit std::streambuf and override just two methods:

  • std::streamsize xsputn(const char_type* s, std::streamsize n) – to append a given buffer with size provided to your internal std::string for example
  • int_type overflow(int_type c) to append a single char to your internal buffer.

Your streambuf can be construncted from whatever you want (DB connection for example). After append something into the internal buffer you may try to split it into lines and push something into DB (or just buffer an SQL statements to execute later).

To use it just attach you streambuf to any std::ostream using constructor or imbue() rigth after creation.

Simple! I've done something like this to output strings to syslog – everything works fine with any custom operator<< for user defined classes.

The simplest way is to imherit std::streambuf and override just two methods:

  • std::streamsize xsputn(const char_type* s, std::streamsize n) – to append a given buffer with size provided to your internal std::string for example
  • int_type overflow(int_type c) to append a single char to your internal buffer.

Your streambuf can be construncted from whatever you want (DB connection for example). After append something into the internal buffer you may try to split it into lines and push something into DB (or just buffer an SQL statements to execute later).

To use it just attach your streambuf to any std::ostream using constructor or imbue() rigth after creation.

Simple! I've done something like this to output strings to syslog – everything works fine with any custom operator<< for user defined classes.

Loading
Source Link
zaufi
  • 7.2k
  • 30
  • 35
Loading