ANN: coutf library (alpha)

O

Oliver Schoenborn

alpha version of coutf library available at

http://noptrlib.sf.net/utils/coutf/

It provides printf-like output to streams (similar to boost::format):

- almost identical to using printf
- fast and simple, provides all essential aspect of printf formatting,
and more (type safety, object output, etc)
- almost no performance hit compared to direct output to std::eek:streams
- holds in one short header file, so no linking etc

Compared to boost::format it is
- more function-like, easier to read, much faster
- but not as comprehensive (e.g. no padding, no support for wchar_t (yet))
- holds in one short header file, no dependencies on boost

Example:

std::string name = "foo";
Time time; // defaults to current time
const float radius=560.456; // approx. m
coutf("Out: %s %s %4.1fs", name, time, radius, endl);

prints to std::cout

Out: foo 12:30pm 560.5 (newline and flush)

Have fun!
Oliver
 
M

Marcin Kalicinski

It provides printf-like output to streams (similar to boost::format):
http://noptrlib.sf.net/utils/coutf/

Reading your webpage I ran into this:

assuming "printf" stands for "print function", "coutf" makes a lot of sense,
being sort of a "cout function"

Printf does not stand for "print function", but for "print formatted".

cheers,
M.
 
R

Rapscallion

Oliver said:
alpha version of coutf library available at

http://noptrlib.sf.net/utils/coutf/

It provides printf-like output to streams (similar to boost::format):

- almost identical to using printf
- fast and simple, provides all essential aspect of printf formatting,
and more (type safety, object output, etc)
- almost no performance hit compared to direct output to std::eek:streams
- holds in one short header file, so no linking etc

Compared to boost::format it is
- more function-like, easier to read, much faster
- but not as comprehensive (e.g. no padding, no support for wchar_t (yet))
- holds in one short header file, no dependencies on boost

Example:

std::string name = "foo";
Time time; // defaults to current time
const float radius=560.456; // approx. m
coutf("Out: %s %s %4.1fs", name, time, radius, endl);

prints to std::cout

Out: foo 12:30pm 560.5 (newline and flush)

Very good! The interface is much cleaner and easier than Boost's
(strange operator% overloadings). Another advantage is that there are
no dependencies to other libraries. Question: Can I coutf my own
classes?

R.C.
 
O

Oliver Schoenborn

Rapscallion said:
Oliver said:
alpha version of coutf library available at

http://noptrlib.sf.net/utils/coutf/

It provides printf-like output to streams (similar to boost::format):

- almost identical to using printf
- fast and simple, provides all essential aspect of printf

formatting, and more (type safety, object output, etc)
[...snip...]

Very good! The interface is much cleaner and easier than Boost's
(strange operator% overloadings). Another advantage is that there are
no dependencies to other libraries. Question: Can I coutf my own
classes?

R.C.

Yep, with the usual magic necessary: i.e., as long as you define an
operator<<(std::eek:stream&, const YourClass&).

Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top