1 // Copyright (c) 2001-2011 Hartmut Kaiser 2 // 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 #if !defined(BOOST_SPIRIT_KARMA_BOOL_UTILS_SEP_28_2009_0644PM) 7 #define BOOST_SPIRIT_KARMA_BOOL_UTILS_SEP_28_2009_0644PM 8 9 #if defined(_MSC_VER) 10 #pragma once 11 #endif 12 13 #include <boost/spirit/home/support/char_class.hpp> 14 #include <boost/spirit/home/support/unused.hpp> 15 #include <boost/spirit/home/karma/detail/generate_to.hpp> 16 #include <boost/spirit/home/karma/detail/string_generate.hpp> 17 #include <boost/spirit/home/karma/numeric/detail/numeric_utils.hpp> 18 #include <boost/detail/workaround.hpp> 19 20 namespace boost { namespace spirit { namespace karma 21 { 22 /////////////////////////////////////////////////////////////////////////// 23 // 24 // The bool_inserter template takes care of the boolean to string 25 // conversion. The Policies template parameter is used to allow 26 // customization of the formatting process 27 // 28 /////////////////////////////////////////////////////////////////////////// 29 template <typename T> 30 struct bool_policies; 31 32 template <typename T 33 , typename Policies = bool_policies<T> 34 , typename CharEncoding = unused_type 35 , typename Tag = unused_type> 36 struct bool_inserter 37 { 38 template <typename OutputIterator, typename U> 39 static bool callboost::spirit::karma::bool_inserter40 call (OutputIterator& sink, U b, Policies const& p = Policies()) 41 { 42 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600)) 43 p; // suppresses warning: C4100: 'p' : unreferenced formal parameter 44 #endif 45 return p.template call<bool_inserter>(sink, T(b), p); 46 } 47 48 /////////////////////////////////////////////////////////////////////// 49 // This is the workhorse behind the real generator 50 /////////////////////////////////////////////////////////////////////// 51 template <typename OutputIterator, typename U> 52 static bool call_nboost::spirit::karma::bool_inserter53 call_n (OutputIterator& sink, U b, Policies const& p) 54 { 55 #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600)) 56 p; // suppresses warning: C4100: 'p' : unreferenced formal parameter 57 #endif 58 if (b) 59 return p.template generate_true<CharEncoding, Tag>(sink, b); 60 return p.template generate_false<CharEncoding, Tag>(sink, b); 61 } 62 }; 63 64 }}} 65 66 #endif 67 68