summaryrefslogtreecommitdiff
path: root/boost/log/expressions/formatter.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/log/expressions/formatter.hpp')
-rw-r--r--boost/log/expressions/formatter.hpp215
1 files changed, 214 insertions, 1 deletions
diff --git a/boost/log/expressions/formatter.hpp b/boost/log/expressions/formatter.hpp
index 09eb57c0d5..5dc6a5b132 100644
--- a/boost/log/expressions/formatter.hpp
+++ b/boost/log/expressions/formatter.hpp
@@ -15,6 +15,8 @@
#ifndef BOOST_LOG_EXPRESSIONS_FORMATTER_HPP_INCLUDED_
#define BOOST_LOG_EXPRESSIONS_FORMATTER_HPP_INCLUDED_
+#include <locale>
+#include <ostream>
#include <boost/ref.hpp>
#include <boost/move/core.hpp>
#include <boost/move/utility.hpp>
@@ -53,10 +55,80 @@ class stream_ref :
public reference_wrapper< StreamT >
{
public:
+ typedef typename StreamT::char_type char_type;
+ typedef typename StreamT::traits_type traits_type;
+ typedef typename StreamT::allocator_type allocator_type;
+ typedef typename StreamT::streambuf_type streambuf_type;
+ typedef typename StreamT::string_type string_type;
+ typedef typename StreamT::ostream_type ostream_type;
+ typedef typename StreamT::pos_type pos_type;
+ typedef typename StreamT::off_type off_type;
+ typedef typename StreamT::int_type int_type;
+
+ typedef typename StreamT::failure failure;
+ typedef typename StreamT::fmtflags fmtflags;
+ typedef typename StreamT::iostate iostate;
+ typedef typename StreamT::openmode openmode;
+ typedef typename StreamT::seekdir seekdir;
+ typedef typename StreamT::Init Init;
+
+ typedef typename StreamT::event event;
+ typedef typename StreamT::event_callback event_callback;
+
+ typedef typename StreamT::sentry sentry;
+
+ static BOOST_CONSTEXPR_OR_CONST fmtflags boolalpha = StreamT::boolalpha;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags dec = StreamT::dec;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags fixed = StreamT::fixed;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags hex = StreamT::hex;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags internal = StreamT::internal;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags left = StreamT::left;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags oct = StreamT::oct;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags right = StreamT::right;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags scientific = StreamT::scientific;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags showbase = StreamT::showbase;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags showpoint = StreamT::showpoint;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags skipws = StreamT::skipws;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags unitbuf = StreamT::unitbuf;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags uppercase = StreamT::uppercase;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags adjustfield = StreamT::adjustfield;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags basefield = StreamT::basefield;
+ static BOOST_CONSTEXPR_OR_CONST fmtflags floatfield = StreamT::floatfield;
+
+ static BOOST_CONSTEXPR_OR_CONST iostate badbit = StreamT::badbit;
+ static BOOST_CONSTEXPR_OR_CONST iostate eofbit = StreamT::eofbit;
+ static BOOST_CONSTEXPR_OR_CONST iostate failbit = StreamT::failbit;
+ static BOOST_CONSTEXPR_OR_CONST iostate goodbit = StreamT::goodbit;
+
+ static BOOST_CONSTEXPR_OR_CONST openmode app = StreamT::app;
+ static BOOST_CONSTEXPR_OR_CONST openmode ate = StreamT::ate;
+ static BOOST_CONSTEXPR_OR_CONST openmode binary = StreamT::binary;
+ static BOOST_CONSTEXPR_OR_CONST openmode in = StreamT::in;
+ static BOOST_CONSTEXPR_OR_CONST openmode out = StreamT::out;
+ static BOOST_CONSTEXPR_OR_CONST openmode trunc = StreamT::trunc;
+
+ static BOOST_CONSTEXPR_OR_CONST seekdir beg = StreamT::beg;
+ static BOOST_CONSTEXPR_OR_CONST seekdir cur = StreamT::cur;
+ static BOOST_CONSTEXPR_OR_CONST seekdir end = StreamT::end;
+
+ static BOOST_CONSTEXPR_OR_CONST event erase_event = StreamT::erase_event;
+ static BOOST_CONSTEXPR_OR_CONST event imbue_event = StreamT::imbue_event;
+ static BOOST_CONSTEXPR_OR_CONST event copyfmt_event = StreamT::copyfmt_event;
+
+
BOOST_FORCEINLINE explicit stream_ref(StreamT& strm) : reference_wrapper< StreamT >(strm)
{
}
+#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+ template< typename T >
+ BOOST_FORCEINLINE StreamT& operator<< (T&& val) const
+ {
+ StreamT& strm = this->get();
+ strm << static_cast< T&& >(val);
+ return strm;
+ }
+#else
template< typename T >
BOOST_FORCEINLINE StreamT& operator<< (T& val) const
{
@@ -72,8 +144,149 @@ public:
strm << val;
return strm;
}
+#endif
+
+ BOOST_FORCEINLINE void attach(string_type& str) const { this->get().attach(str); }
+ BOOST_FORCEINLINE void detach() const { this->get().detach(); }
+ BOOST_FORCEINLINE string_type const& str() const { return this->get().str(); }
+ BOOST_FORCEINLINE ostream_type& stream() const { return this->get().stream(); }
+ BOOST_FORCEINLINE fmtflags flags() const { return this->get().flags(); }
+ BOOST_FORCEINLINE fmtflags flags(fmtflags f) const { return this->get().flags(f); }
+ BOOST_FORCEINLINE fmtflags setf(fmtflags f) const { return this->get().setf(f); }
+ BOOST_FORCEINLINE fmtflags setf(fmtflags f, fmtflags mask) const { return this->get().setf(f, mask); }
+ BOOST_FORCEINLINE void unsetf(fmtflags f) const { this->get().unsetf(f); }
+
+ BOOST_FORCEINLINE std::streamsize precision() const { return this->get().precision(); }
+ BOOST_FORCEINLINE std::streamsize precision(std::streamsize p) const { return this->get().precision(p); }
+
+ BOOST_FORCEINLINE std::streamsize width() const { return this->get().width(); }
+ BOOST_FORCEINLINE std::streamsize width(std::streamsize w) const { return this->get().width(w); }
+
+ BOOST_FORCEINLINE std::locale getloc() const { return this->get().getloc(); }
+ BOOST_FORCEINLINE std::locale imbue(std::locale const& loc) const { return this->get().imbue(loc); }
+
+ static BOOST_FORCEINLINE int xalloc() { return StreamT::xalloc(); }
+ BOOST_FORCEINLINE long& iword(int index) const { return this->get().iword(index); }
+ BOOST_FORCEINLINE void*& pword(int index) const { return this->get().pword(index); }
+
+ BOOST_FORCEINLINE void register_callback(event_callback fn, int index) const { this->get().register_callback(fn, index); }
+
+ static BOOST_FORCEINLINE bool sync_with_stdio(bool sync = true) { return StreamT::sync_with_stdio(sync); }
+
+ BOOST_EXPLICIT_OPERATOR_BOOL()
+ BOOST_FORCEINLINE bool operator! () const { return !this->get(); }
+
+ BOOST_FORCEINLINE iostate rdstate() const { return this->get().rdstate(); }
+ BOOST_FORCEINLINE void clear(iostate state = goodbit) const { this->get().clear(state); }
+ BOOST_FORCEINLINE void setstate(iostate state) const { this->get().setstate(state); }
+ BOOST_FORCEINLINE bool good() const { return this->get().good(); }
+ BOOST_FORCEINLINE bool eof() const { return this->get().eof(); }
+ BOOST_FORCEINLINE bool fail() const { return this->get().fail(); }
+ BOOST_FORCEINLINE bool bad() const { return this->get().bad(); }
+
+ BOOST_FORCEINLINE iostate exceptions() const { return this->get().exceptions(); }
+ BOOST_FORCEINLINE void exceptions(iostate s) const { this->get().exceptions(s); }
+
+ BOOST_FORCEINLINE ostream_type* tie() const { return this->get().tie(); }
+ BOOST_FORCEINLINE ostream_type* tie(ostream_type* strm) const { return this->get().tie(strm); }
+
+ BOOST_FORCEINLINE streambuf_type* rdbuf() const { return this->get().rdbuf(); }
+
+ BOOST_FORCEINLINE StreamT& copyfmt(std::basic_ios< char_type, traits_type >& rhs) const { return this->get().copyfmt(rhs); }
+ BOOST_FORCEINLINE StreamT& copyfmt(StreamT& rhs) const { return this->get().copyfmt(rhs); }
+
+ BOOST_FORCEINLINE char_type fill() const { return this->get().fill(); }
+ BOOST_FORCEINLINE char_type fill(char_type ch) const { return this->get().fill(ch); }
+
+ BOOST_FORCEINLINE char narrow(char_type ch, char def) const { return this->get().narrow(ch, def); }
+ BOOST_FORCEINLINE char_type widen(char ch) const { return this->get().widen(ch); }
+
+ BOOST_FORCEINLINE StreamT& flush() const { return this->get().flush(); }
+
+ BOOST_FORCEINLINE pos_type tellp() const { return this->get().tellp(); }
+ BOOST_FORCEINLINE StreamT& seekp(pos_type pos) const { return this->get().seekp(pos); }
+ BOOST_FORCEINLINE StreamT& seekp(off_type off, std::ios_base::seekdir dir) const { return this->get().seekp(off, dir); }
+
+ template< typename CharT >
+ BOOST_FORCEINLINE typename boost::log::aux::enable_if_streamable_char_type< CharT, StreamT& >::type
+ put(CharT c) const { return this->get().put(c); }
+
+ template< typename CharT >
+ BOOST_FORCEINLINE typename boost::log::aux::enable_if_streamable_char_type< CharT, StreamT& >::type
+ write(const CharT* p, std::streamsize size) const { return this->get().write(p, size); }
};
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::boolalpha;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::dec;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::fixed;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::hex;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::internal;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::left;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::oct;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::right;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::scientific;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::showbase;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::showpoint;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::skipws;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::unitbuf;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::uppercase;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::adjustfield;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::basefield;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::floatfield;
+
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::badbit;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::eofbit;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::failbit;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::goodbit;
+
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::app;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::ate;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::binary;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::in;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::out;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::trunc;
+
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::seekdir stream_ref< StreamT >::beg;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::seekdir stream_ref< StreamT >::cur;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::seekdir stream_ref< StreamT >::end;
+
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::event stream_ref< StreamT >::erase_event;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::event stream_ref< StreamT >::imbue_event;
+template< typename StreamT >
+BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::event stream_ref< StreamT >::copyfmt_event;
+
//! Default log record message formatter
struct message_formatter
{
@@ -84,7 +297,7 @@ struct message_formatter
}
template< typename StreamT >
- result_type operator() (record_view const& rec, StreamT& strm) const
+ BOOST_FORCEINLINE result_type operator() (record_view const& rec, StreamT& strm) const
{
boost::log::visit< expressions::tag::message::value_type >(m_MessageName, rec, boost::log::bind_output(strm));
}