Tomographer  v1.0a
Tomographer C++ Framework Documentation
fmt.h File Reference

(v1.0a)

Utilities for formatting strings. More...

#include <cstdio>
#include <cstdarg>
#include <chrono>
#include <string>
#include <sstream>
#include <iostream>
#include <tomographer/tools/util.h>
+ Include dependency graph for fmt.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Tomographer::Tools::bad_fmts_format
 Exception for bad printf format. More...
 

Namespaces

 Tomographer
 Base namespace for the Tomographer project.
 
 Tomographer::Tools
 Various useful tools.
 

Macros

#define streamstr(tokens)
 Utility macro to format stream tokens to a std::string. More...
 
#define streamcstr(tokens)   streamstr(tokens).c_str()
 Utility macro to format stream tokens to a C string. More...
 

Functions

std::string Tomographer::Tools::vfmts (const char *fmt, va_list vl)
 printf- formatting to a std::string, with va_list pointer More...
 
std::string Tomographer::Tools::fmts (const char *fmt,...)
 printf- format to a std::string More...
 
std::string Tomographer::Tools::fmt_duration (double seconds)
 Format a number of seconds into a human-readable string. More...
 
template<typename Rep , typename Period >
std::string Tomographer::Tools::fmt_duration (std::chrono::duration< Rep, Period > dt)
 Format a std::chrono::duration into a human-readable string. More...
 

Detailed Description

Utilities for formatting strings.

Definition in file fmt.h.

Macro Definition Documentation

#define streamcstr (   tokens)    streamstr(tokens).c_str()

Utility macro to format stream tokens to a C string.

Shorthand for:

1 streamstr( tokens ).c_str()

Definition at line 155 of file fmt.h.

#define streamstr (   tokens)
Value:
dynamic_cast<std::ostringstream&>( \
std::ostringstream().seekp(0) << tokens \
).str() \

Utility macro to format stream tokens to a std::string.

Usage example:

1 Eigen::VectorXd x = ...;
2 std::string s = streamstr("x is = " << x.transpose());

This is typically useful if you want to feed in C++ objects to a printf()-like function.

Definition at line 143 of file fmt.h.