lite xformat - A C++ printf/scanf style IO library
This is a header only library that provides functions for prinf/scanf style IO using iostreams. It also provides tool for conversion of values to/from strings.
- The following are the design goals for xprintf() / xscanf() :
- The syntax should be intuitive and should resemble the printf()/scanf() syntax as much as possible but without sacrificing usability or performance.
- The added overhead should be as minimal as possible.
- The format string should provide the possibility of adding user defined format fields.
- In order to achieve a good performance the following has been done:
- The creation/destruction of
sentry objects are minimized because they usually contain
unlock() call to ensure thread safety.
- Retrieving locale and facets from the streams are minimized because the functions that retrieve these objects usually contain
unlock() calls. To achieve this, the stream locale and all the necessary facets, and locale specific characters are retained in a cache object that is associated with each stream object. The cache object is updated using an stream event handler.
- There is only one extra virtual function call per each argument. This is to allow for more inlining of function calls.
- The basic_conversion class maintains an stream object. This avoids repeated construction/destruction of the stream object per each conversion and thus avoids a lot of unnecessary overhead when performing a large number of conversions (e.g., when reading an input file).
- Using the xprintf() / xscanf() functions are about 5 times faster that using the boost::format
- Add detailed benchmark