|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67484 - in trunk/boost: detail spirit/home/karma/char spirit/home/karma/string spirit/home/lex spirit/home/lex/qi spirit/home/qi/char spirit/home/qi/detail spirit/home/qi/string spirit/home/support spirit/home/support/utree
From: admin_at_[hidden]
Date: 2010-12-28 20:37:33
Author: wash
Date: 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
New Revision: 67484
URL: http://svn.boost.org/trac/boost/changeset/67484
Log:
Added the get_c_string function back in (it dispatches to the get_c_string_impl
CP). Fixed utree::list_type attribute so that only non-list utree nodes are wrapped in lists (this was the original behavior we wanted).
Text files modified:
trunk/boost/detail/container_fwd.hpp | 6 ++
trunk/boost/spirit/home/karma/char/char.hpp | 2
trunk/boost/spirit/home/karma/string/lit.hpp | 4 +-
trunk/boost/spirit/home/lex/argument.hpp | 2
trunk/boost/spirit/home/lex/qi/state_switcher.hpp | 6 +-
trunk/boost/spirit/home/qi/char/char.hpp | 4 +-
trunk/boost/spirit/home/qi/detail/attributes.hpp | 10 ++--
trunk/boost/spirit/home/qi/string/lit.hpp | 4 +-
trunk/boost/spirit/home/support/string_traits.hpp | 52 ++++++++++++++++++++------
trunk/boost/spirit/home/support/utree/utree_traits.hpp | 79 +++++++++------------------------------
10 files changed, 80 insertions(+), 89 deletions(-)
Modified: trunk/boost/detail/container_fwd.hpp
==============================================================================
--- trunk/boost/detail/container_fwd.hpp (original)
+++ trunk/boost/detail/container_fwd.hpp 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
@@ -68,7 +68,11 @@
template <class charT> struct char_traits;
#endif
- template <class T> class complex;
+ #if BOOST_CLANG
+ template <class T> struct complex;
+ #else
+ template <class T> class complex;
+ #endif
}
// gcc 3.4 and greater
Modified: trunk/boost/spirit/home/karma/char/char.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/char/char.hpp (original)
+++ trunk/boost/spirit/home/karma/char/char.hpp 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
@@ -262,7 +262,7 @@
typedef spirit::char_class::convert<char_encoding> convert_type;
char_type const* definition =
- (char_type const*)traits::get_c_string<String>::call(str);
+ (char_type const*)traits::get_c_string(str);
char_type ch = convert_type::to(Tag(), *definition++);
while (ch)
{
Modified: trunk/boost/spirit/home/karma/string/lit.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/string/lit.hpp (original)
+++ trunk/boost/spirit/home/karma/string/lit.hpp 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
@@ -166,9 +166,9 @@
using spirit::traits::get_c_string;
if (!detail::string_compare(
- get_c_string<extracted_string_type>::call(
+ get_c_string(
traits::extract_from<attribute_type>(attr, context))
- , get_c_string<string_type>::call(str_), char_encoding(), Tag()))
+ , get_c_string(str_), char_encoding(), Tag()))
{
return false;
}
Modified: trunk/boost/spirit/home/lex/argument.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/argument.hpp (original)
+++ trunk/boost/spirit/home/lex/argument.hpp 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
@@ -101,7 +101,7 @@
typedef typename context_type::state_name_type string;
fusion::at_c<4>(env.args()).set_state_name(
- traits::get_c_string<string>::call(actor_.eval(env)));
+ traits::get_c_string(actor_.eval(env)));
}
state_setter(Actor const& actor)
Modified: trunk/boost/spirit/home/lex/qi/state_switcher.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/qi/state_switcher.hpp (original)
+++ trunk/boost/spirit/home/lex/qi/state_switcher.hpp 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
@@ -136,7 +136,7 @@
template <typename State>
reset_state_on_exit(Iterator& it_, State state_)
: it(it_)
- , state(detail::set_lexer_state(it_, traits::get_c_string<State>::call(state_)))
+ , state(detail::set_lexer_state(it_, traits::get_c_string(state_)))
{}
~reset_state_on_exit()
@@ -184,7 +184,7 @@
template <typename String>
state_switcher_context(
state_switcher_context<Subject, String> const& rhs)
- : subject(rhs.subject), state(traits::get_c_string<String>::call(rhs.state)) {}
+ : subject(rhs.subject), state(traits::get_c_string(rhs.state)) {}
template <typename Iterator, typename Context
, typename Skipper, typename Attribute>
@@ -226,7 +226,7 @@
template <typename Terminal>
result_type operator()(Terminal const& term, unused_type) const
{
- return result_type(traits::get_c_string<const_string>::call(fusion::at_c<0>(term.args)));
+ return result_type(traits::get_c_string(fusion::at_c<0>(term.args)));
}
};
Modified: trunk/boost/spirit/home/qi/char/char.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/char/char.hpp (original)
+++ trunk/boost/spirit/home/qi/char/char.hpp 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
@@ -277,7 +277,7 @@
), cannot_convert_string, (String));
in_type const* definition =
- (in_type const*)traits::get_c_string<String>::call(str);
+ (in_type const*)traits::get_c_string(str);
in_type ch = *definition++;
while (ch)
{
@@ -337,7 +337,7 @@
), cannot_convert_string, (String));
char_type const* definition =
- (char_type const*)traits::get_c_string<String>::call(str);
+ (char_type const*)traits::get_c_string(str);
char_type ch = *definition++;
while (ch)
{
Modified: trunk/boost/spirit/home/qi/detail/attributes.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/detail/attributes.hpp (original)
+++ trunk/boost/spirit/home/qi/detail/attributes.hpp 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
@@ -76,18 +76,18 @@
{};
template <typename Exposed, typename Transformed>
- struct transform_attribute<boost::optional<Exposed>, Transformed
- , typename disable_if<is_same<boost::optional<Exposed>, Transformed> >::type>
+ struct transform_attribute<optional<Exposed>, Transformed
+ , typename disable_if<is_same<optional<Exposed>, Transformed> >::type>
{
typedef Transformed& type;
- static Transformed& pre(boost::optional<Exposed>& val)
+ static Transformed& pre(optional<Exposed>& val)
{
if (!val)
val = Transformed();
return boost::get<Transformed>(val);
}
- static void post(boost::optional<Exposed>&, Transformed const&) {}
- static void fail(boost::optional<Exposed>& val)
+ static void post(optional<Exposed>&, Transformed const&) {}
+ static void fail(optional<Exposed>& val)
{
val = none_t(); // leave optional uninitialized if rhs failed
}
Modified: trunk/boost/spirit/home/qi/string/lit.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/string/lit.hpp (original)
+++ trunk/boost/spirit/home/qi/string/lit.hpp 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
@@ -199,7 +199,7 @@
{
typename spirit::detail::get_encoding<Modifiers,
spirit::char_encoding::standard>::type encoding;
- return result_type(traits::get_c_string<String>::call(str), encoding);
+ return result_type(traits::get_c_string(str), encoding);
}
};
@@ -235,7 +235,7 @@
template <typename String>
result_type op(String const& str, mpl::true_) const
{
- return result_type(traits::get_c_string<String>::call(str), encoding());
+ return result_type(traits::get_c_string(str), encoding());
}
};
}}}
Modified: trunk/boost/spirit/home/support/string_traits.hpp
==============================================================================
--- trunk/boost/spirit/home/support/string_traits.hpp (original)
+++ trunk/boost/spirit/home/support/string_traits.hpp 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
@@ -124,10 +124,10 @@
// Get the C string from a string
///////////////////////////////////////////////////////////////////////////
template <typename String>
- struct get_c_string;
+ struct get_c_string_impl;
template <typename String>
- struct get_c_string
+ struct get_c_string_impl
{
typedef typename char_type_of<String>::type char_type;
@@ -146,36 +146,36 @@
// Forwarder that strips const
template <typename T>
- struct get_c_string<T const>
+ struct get_c_string_impl<T const>
{
- static typename get_c_string<T>::char_type const* call (T const str)
+ static typename get_c_string_impl<T>::char_type const* call (T const str)
{
- return get_c_string<T>::call(str);
+ return get_c_string_impl<T>::call(str);
}
};
// Forwarder that strips references
template <typename T>
- struct get_c_string<T&>
+ struct get_c_string_impl<T&>
{
- static typename get_c_string<T>::char_type const* call (T& str)
+ static typename get_c_string_impl<T>::char_type const* call (T& str)
{
- return get_c_string<T>::call(str);
+ return get_c_string_impl<T>::call(str);
}
};
// Forwarder that strips const references
template <typename T>
- struct get_c_string<T const&>
+ struct get_c_string_impl<T const&>
{
- static typename get_c_string<T>::char_type const* call (T const& str)
+ static typename get_c_string_impl<T>::char_type const* call (T const& str)
{
- return get_c_string<T>::call(str);
+ return get_c_string_impl<T>::call(str);
}
};
template <typename T, typename Traits, typename Allocator>
- struct get_c_string<std::basic_string<T, Traits, Allocator> >
+ struct get_c_string_impl<std::basic_string<T, Traits, Allocator> >
{
typedef T char_type;
@@ -191,6 +191,34 @@
return str.c_str();
}
};
+
+ template <typename T>
+ typename get_c_string_impl<T*>::char_type const*
+ get_c_string (T* str)
+ {
+ return get_c_string_impl<T*>::call(str);
+ }
+
+ template <typename T>
+ typename get_c_string_impl<T const*>::char_type const*
+ get_c_string (T const* str)
+ {
+ return get_c_string_impl<T const*>::call(str);
+ }
+
+ template <typename String>
+ typename get_c_string_impl<String>::char_type const*
+ get_c_string (String& str)
+ {
+ return get_c_string_impl<String>::call(str);
+ }
+
+ template <typename String>
+ typename get_c_string_impl<String>::char_type const*
+ get_c_string (String const& str)
+ {
+ return get_c_string_impl<String>::call(str);
+ }
///////////////////////////////////////////////////////////////////////////
// Get the begin/end iterators from a string
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 2010-12-28 20:37:28 EST (Tue, 28 Dec 2010)
@@ -48,6 +48,12 @@
{
static int call(utree const& u) { return u.which(); }
};
+
+ template <>
+ struct variant_which<utree::list_type>
+ {
+ static int call(utree::list_type const& u) { return u.which(); }
+ };
///////////////////////////////////////////////////////////////////////////
// this specialization lets Spirit know that typed basic_strings
@@ -72,10 +78,10 @@
///////////////////////////////////////////////////////////////////////////
// these specializations extract a c string from a utree typed string
template <typename String>
- struct get_c_string;
+ struct get_c_string_impl;
template <typename T, utree_type::info I>
- struct get_c_string<spirit::basic_string<iterator_range<T const*>, I> >
+ struct get_c_string_impl<spirit::basic_string<iterator_range<T const*>, I> >
{
typedef T char_type;
@@ -93,7 +99,7 @@
};
template <utree_type::info I>
- struct get_c_string<spirit::basic_string<std::string, I> >
+ struct get_c_string_impl<spirit::basic_string<std::string, I> >
{
typedef char char_type;
@@ -162,7 +168,7 @@
iterator_type;
// make sure the attribute is a list, at least an empty one
- if (traits::which(attr) != utree_type::list_type)
+ if (attr.empty())
attr = utree::list;
iterator_type end = traits::end(val);
@@ -184,73 +190,30 @@
{
static void call(utree const& val, utree& attr)
{
- if (traits::which(val) != utree_type::list_type)
+ if (attr.empty())
attr = val;
else {
typedef utree::const_iterator iterator_type;
- // make sure the attribute is a list, at least an empty one
- if (traits::which(attr) != utree_type::list_type)
- attr = utree::list;
-
iterator_type end = traits::end(val);
for (iterator_type i = traits::begin(val); i != end; traits::next(i))
push_back(attr, traits::deref(i));
}
}
};
-
- ///////////////////////////////////////////////////////////////////////////
- //
- template <typename Attribute>
- struct transform_attribute<utree::list_type, Attribute, qi::domain>
- {
- typedef Attribute type;
-
- static Attribute pre(utree::list_type&) { return Attribute(); }
-
- static void post(utree::list_type& attr, Attribute const& val)
- {
- push_back(attr, val);
- }
-
- static void fail(utree::list_type&) {}
- };
-
- template <typename Attribute>
- struct transform_attribute<utree::list_type&, Attribute, qi::domain>
- : transform_attribute<utree::list_type, Attribute, qi::domain>
- {};
template <>
- struct transform_attribute<utree, utree::list_type, qi::domain>
+ struct assign_to_container_from_value<utree, utree::list_type>
{
- typedef utree::list_type type;
-
- static utree::list_type pre(utree&) { return utree::list_type(); }
-
- static void post(utree& attr, utree::list_type const& val)
+ static void call(utree const& val, utree& attr)
{
- typedef utree::list_type::const_iterator iterator_type;
-
- // make sure the attribute is a list, at least an empty one
- if (traits::which(attr) != utree_type::list_type)
- attr = utree::list;
-
- iterator_type end = traits::end(val);
- for (iterator_type i = traits::begin(val); i != end; traits::next(i))
- attr.push_back(traits::deref(i));
+ if (attr.empty())
+ attr = val;
+ else
+ push_back(attr, val);
}
-
- // fail() will be called by Qi rule's if the rhs failed parsing
- static void fail(utree&) {}
};
- template <>
- struct transform_attribute<utree&, utree::list_type, qi::domain>
- : transform_attribute<utree, utree::list_type, qi::domain>
- {};
-
///////////////////////////////////////////////////////////////////////////
// this specialization makes sure strings get assigned as a whole and are
// not converted into a utree list
@@ -315,10 +278,6 @@
if (attr.empty())
attr.assign(first, last);
else {
- // make sure the attribute is a list, at least an empty one
- if (traits::which(attr) != utree_type::list_type)
- attr = utree::list;
-
for (Iterator i = first; i != last; ++i)
push_back(attr, traits::deref(i));
}
@@ -355,7 +314,7 @@
}
};
}
-
+
template <>
struct attribute_as<std::string, utree>
: detail::attribute_as_string_type
@@ -571,7 +530,7 @@
karma::grammar<OutputIterator, T1, T2, T3, T4>
>::type>
{};
-
+
///////////////////////////////////////////////////////////////////////////
// the specialization below tells Spirit how to handle utree if it is used
// with an optional component
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