Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
format-string.cpp File Reference

Go to the source code of this file.

Description

Implementation for printf-style formatting, based on boost::format.

This file holds the generic implementation of our format frontend, which actually just invokes boost::format. The corresponding header format-string.hpp provides some template functions and classes, either invoking a custom string conversion, or passing primitive values down unaltered.

Here, we define explicit specialisations for the frontend to invoke, which in turn just pass on the given argument value to the embedded boost::format object, which in turn dumps the formatted result into an embedded string stream.

To avoid exposing boost::format in the frontend header, we use an opaque buffer of appropriate size to piggyback the formatter object.

Warning
unfortunately this requires a hard coded buffer size constant in the front-end, which we define there manually, based on the current implementation layout found in the boost libraries. If Boost eventually changes the implementation, the assertion in our constructor will trigger.
See also
FormatString_test

Definition in file format-string.cpp.

#include "lib/error.hpp"
#include "lib/format-util.hpp"
#include "lib/format-string.hpp"
#include <boost/static_assert.hpp>
#include <boost/format.hpp>
#include <iostream>

Functions

 LUMIERA_ERROR_DEFINE (FORMAT_SYNTAX,"Syntax error in format string for boost::format")
 
std::ostream & operator<< (std::ostream &os, _Fmt const &fmt)
 send the formatted buffer directly to the output stream. More...
 

Namespaces

 util