|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67688 - trunk/boost/spirit/home/support/utree
From: hartmut.kaiser_at_[hidden]
Date: 2011-01-05 16:06:13
Author: hkaiser
Date: 2011-01-05 16:06:11 EST (Wed, 05 Jan 2011)
New Revision: 67688
URL: http://svn.boost.org/trac/boost/changeset/67688
Log:
Spirit: more utree fixes
Text files modified:
trunk/boost/spirit/home/support/utree/utree_traits.hpp | 50 ++++++++++++++++-----------------------
1 files changed, 21 insertions(+), 29 deletions(-)
Modified: trunk/boost/spirit/home/support/utree/utree_traits.hpp
==============================================================================
--- trunk/boost/spirit/home/support/utree/utree_traits.hpp (original)
+++ trunk/boost/spirit/home/support/utree/utree_traits.hpp 2011-01-05 16:06:11 EST (Wed, 05 Jan 2011)
@@ -209,36 +209,28 @@
template <>
struct assign_to_container_from_value<utree, utree::list_type>
- {
- static void call(utree const& val, utree& attr)
- {
- if (attr.empty())
- attr = val;
- else
- push_back(attr, val);
- }
- };
+ : assign_to_container_from_value<utree, utree>
+ {};
+ // If the destination is a utree_list, we need to force the right hand side
+ // value into a new sub-node, always, no questions asked.
template <>
struct assign_to_container_from_value<utree::list_type, utree>
{
static void call(utree const& val, utree& attr)
{
- if (attr.empty())
- attr = val;
- else
- push_back(attr, val);
+ push_back(attr, val);
}
};
+ // If both, the right hand side and the left hand side are utree_lists
+ // we have a lhs rule which has a single rule exposing a utree_list as its
+ // rhs (optionally wrapped into a directive or other unary parser). In this
+ // case we do not create a new sub-node.
template <>
struct assign_to_container_from_value<utree::list_type, utree::list_type>
- {
- static void call(utree const& val, utree& attr)
- {
- push_back(attr, val);
- }
- };
+ : assign_to_container_from_value<utree, utree>
+ {};
///////////////////////////////////////////////////////////////////////////
// this specialization makes sure strings get assigned as a whole and are
@@ -322,7 +314,7 @@
{
return boost::get<utf8_string_range_type>(attr);
}
-
+
static bool is_valid(utree const& attr)
{
switch (traits::which(attr))
@@ -341,17 +333,17 @@
};
}
- template <>
+ template <>
struct attribute_as<std::string, utree>
: detail::attribute_as_string_type
{};
- template <>
+ template <>
struct attribute_as<utf8_string_type, utree>
: detail::attribute_as_string_type
{};
- template <>
+ template <>
struct attribute_as<utf8_string_range_type, utree>
: detail::attribute_as_string_type
{};
@@ -367,7 +359,7 @@
{
return boost::get<utf8_symbol_range_type>(attr);
}
-
+
static bool is_valid(utree const& attr)
{
switch (traits::which(attr))
@@ -528,7 +520,7 @@
qi::rule<IteratorA, T1, T2, T3, T4>, Context, IteratorB
>::type>
{};
-
+
template <
typename IteratorA, typename IteratorB, typename Context
, typename T1, typename T2, typename T3, typename T4>
@@ -538,7 +530,7 @@
qi::grammar<IteratorA, T1, T2, T3, T4>, Context, IteratorB
>::type>
{};
-
+
template <
typename IteratorA, typename IteratorB, typename Context
, typename T1, typename T2, typename T3, typename T4>
@@ -558,7 +550,7 @@
karma::grammar<IteratorA, T1, T2, T3, T4>, Context, IteratorB
>::type>
{};
-
+
///////////////////////////////////////////////////////////////////////////
// the specialization below tells Spirit how to handle utree if it is used
// with an optional component
@@ -1057,7 +1049,7 @@
}
};
- #if 0
+#if 0
// If a rule takes an utree attribute and that utree instance holds nothing
// more than a list, we dereference this to simplify attribute handling
// down the stream, i.e. ( ( 1 2 3 ) ) --> ( 1 2 3 ).
@@ -1077,7 +1069,7 @@
struct transform_attribute<utree const&, utree, karma::domain>
: transform_attribute<utree const, utree, karma::domain>
{};
- #endif
+#endif
}}}
#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk