/usr/include/boost/spirit/home/karma/operator
Edit: /usr/include/boost/spirit/home/karma/operator/optional.hpp (3873B)
// Copyright (c) 2001-2011 Joel de Guzman
// 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_OPERATOR_OPTIONAL_HPP
#define BOOST_SPIRIT_KARMA_OPERATOR_OPTIONAL_HPP
#if defined(_MSC_VER)
#pragma once
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace boost { namespace spirit
{
///////////////////////////////////////////////////////////////////////////
// Enablers
///////////////////////////////////////////////////////////////////////////
template <>
struct use_operator // enables -g
: mpl::true_ {};
}}
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace karma
{
///////////////////////////////////////////////////////////////////////////
template
struct optional : unary_generator >
{
typedef Subject subject_type;
typedef typename subject_type::properties properties;
// Build a boost::optional from the subject's attribute. Note
// that boost::optional may return unused_type if the
// subject's attribute is an unused_type.
template
struct attribute
: traits::build_optional<
typename traits::attribute_of::type
>
{};
optional(Subject const& subject)
: subject(subject) {}
template <
typename OutputIterator, typename Context, typename Delimiter
, typename Attribute>
bool generate(OutputIterator& sink, Context& ctx
, Delimiter const& d, Attribute const& attr) const
{
if (traits::has_optional_value(attr))
subject.generate(sink, ctx, d, traits::optional_value(attr));
return sink_is_good(sink);
}
template
info what(Context& context) const
{
return info("optional", subject.what(context));
}
Subject subject;
};
///////////////////////////////////////////////////////////////////////////
// Generator generators: make_xxx function (objects)
///////////////////////////////////////////////////////////////////////////
template
struct make_composite
: make_unary_composite {};
}}}
namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
template
struct has_semantic_action >
: unary_has_semantic_action {};
///////////////////////////////////////////////////////////////////////////
template
struct handles_container, Attribute, Context
, Iterator>
: mpl::true_ {};
}}}
#endif