// 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_VERBATIM_MAR_02_2007_0303PM) #define BOOST_SPIRIT_KARMA_VERBATIM_MAR_02_2007_0303PM #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once // MS compatible compilers support #pragma once #endif #include #include #include #include #include namespace boost { namespace spirit { namespace karma { /////////////////////////////////////////////////////////////////////////// // The verbatim generator is used for verbatim[...] directives. /////////////////////////////////////////////////////////////////////////// struct verbatim { template struct attribute : traits::attribute_of< karma::domain, typename result_of::right::type, Context > { }; template static bool generate(Component const& component, OutputIterator& sink, Context& ctx, Delimiter const& d, Parameter const& param) { // the verbatim generator simply dispatches to the embedded // generator while supplying unused as the new delimiter // to avoid delimiting down the generator stream typedef typename spirit::result_of::right::type::director director; if (director::generate(spirit::right(component), sink, ctx, unused, param)) { karma::delimit(sink, d); // always do post-delimiting return true; } return false; } template static std::string what(Component const& component, Context const& ctx) { std::string result = "verbatim["; typedef typename spirit::result_of::right::type::director director; result += director::what(spirit::right(component), ctx); result += "]"; return result; } }; }}} #endif