// Copyright (c) 2001-2008 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(BOOST_SPIRIT_KARMA_SPACE_MAR_06_2007_0934PM) #define BOOST_SPIRIT_KARMA_SPACE_MAR_06_2007_0934PM #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once // MS compatible compilers support #pragma once #endif #include #include #include #include #include #include #include #include #include namespace boost { namespace spirit { namespace karma { /////////////////////////////////////////////////////////////////////////// // // space // generates a single character from the associated parameter // /////////////////////////////////////////////////////////////////////////// template struct any_space_char { template struct attribute { typedef Char type; }; typedef typename Tag::char_set char_set; typedef typename Tag::char_class char_class_; // space has a parameter attached template static bool generate(Component const& /*component*/, OutputIterator& sink, Context& /*ctx*/, Delimiter const& d, Parameter const& ch) { using spirit::char_class::classify; BOOST_ASSERT(classify::is(char_class_(), ch)); detail::generate_to(sink, ch); karma::delimit(sink, d); // always do post-delimiting return true; } // this space has no parameter attached, just generate a single ' ' template static bool generate(Component const&, OutputIterator& sink, Context&, Delimiter const& d, unused_type) { detail::generate_to(sink, ' '); // generate a single space karma::delimit(sink, d); // always do post-delimiting return true; } template static std::string what(Component const& component, Context const& ctx) { return "any-space"; } }; /////////////////////////////////////////////////////////////////////////// // // space(...) // generates a single space character given by a literal it was // initialized from // /////////////////////////////////////////////////////////////////////////// template struct literal_space_char { template struct attribute { typedef unused_type type; }; // any_char has a parameter attached template static bool generate(Component const& component, OutputIterator& sink, Context& /*ctx*/, Delimiter const& d, Parameter const& /*param*/) { detail::generate_to(sink, fusion::at_c<0>(component.elements)); karma::delimit(sink, d); // always do post-delimiting return true; } template static std::string what(Component const& component, Context const& ctx) { return std::string("space('") + spirit::detail::to_narrow_char( fusion::at_c<0>(component.elements)) + "')"; } }; }}} // namespace boost::spirit::karma #endif // !defined(BOOST_SPIRIT_KARMA_CHAR_FEB_21_2007_0543PM)