/usr/include/boost/spirit/home/karma/auxiliary
Edit: /usr/include/boost/spirit/home/karma/auxiliary/attr_cast.hpp (4453B)
// Copyright (c) 2001-2011 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)
#ifndef BOOST_SPIRIT_KARMA_AUXILIARY_ATTR_CAST_HPP
#define BOOST_SPIRIT_KARMA_AUXILIARY_ATTR_CAST_HPP
#if defined(_MSC_VER)
#pragma once
#endif
#include
#include
#include
#include
#include
#include
#include
#include
namespace boost { namespace spirit
{
///////////////////////////////////////////////////////////////////////////
// enables attr_cast<>() pseudo generator
template
struct use_terminal >
: mpl::true_ {};
}}
namespace boost { namespace spirit { namespace karma
{
using spirit::attr_cast;
///////////////////////////////////////////////////////////////////////////
// attr_cast_generator consumes the attribute of subject generator without
// generating anything
///////////////////////////////////////////////////////////////////////////
template
struct attr_cast_generator
: unary_generator >
{
typedef typename result_of::compile::type
subject_type;
typedef mpl::int_ properties;
typedef typename mpl::eval_if<
traits::not_is_unused
, mpl::identity
, traits::attribute_of >::type
transformed_attribute_type;
attr_cast_generator(Subject const& subject)
: subject(subject)
{
// If you got an error_invalid_expression error message here,
// then the expression (Subject) is not a valid spirit karma
// expression.
BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Subject);
}
// If Exposed is given, we use the given type, otherwise all we can do
// is to guess, so we expose our inner type as an attribute and
// deal with the passed attribute inside the parse function.
template
struct attribute
: mpl::if_, Exposed
, transformed_attribute_type>
{};
template
bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
, Attribute const& attr) const
{
typedef traits::transform_attribute<
Attribute const, transformed_attribute_type, domain>
transform;
return compile(subject).generate(
sink, ctx, d, transform::pre(attr));
}
template
info what(Context& context) const
{
return info("attr_cast"
, compile(subject).what(context));
}
Subject subject;
};
///////////////////////////////////////////////////////////////////////////
// Generator generator: make_xxx function (objects)
///////////////////////////////////////////////////////////////////////////
template
struct make_primitive<
tag::stateful_tag, Modifiers>
{
typedef attr_cast_generator result_type;
template
result_type operator()(Terminal const& term, unused_type) const
{
typedef tag::stateful_tag<
Expr, tag::attr_cast, Exposed, Transformed> tag_type;
using spirit::detail::get_stateful_data;
return result_type(get_stateful_data::call(term));
}
};
}}}
#endif