|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69527 - in trunk: boost/spirit/home/support libs/spirit/test libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2011-03-03 13:49:31
Author: hkaiser
Date: 2011-03-03 13:49:26 EST (Thu, 03 Mar 2011)
New Revision: 69527
URL: http://svn.boost.org/trac/boost/changeset/69527
Log:
Spirit: fixed compilation issue in attribute handling code
Added:
trunk/libs/spirit/test/qi/pass_container1.cpp (contents, props changed)
trunk/libs/spirit/test/qi/pass_container2.cpp (contents, props changed)
trunk/libs/spirit/test/qi/pass_container3.cpp (contents, props changed)
Removed:
trunk/libs/spirit/test/qi/pass_container.cpp
Text files modified:
trunk/boost/spirit/home/support/attributes.hpp | 8 ++++++--
trunk/libs/spirit/test/Jamfile | 4 +++-
2 files changed, 9 insertions(+), 3 deletions(-)
Modified: trunk/boost/spirit/home/support/attributes.hpp
==============================================================================
--- trunk/boost/spirit/home/support/attributes.hpp (original)
+++ trunk/boost/spirit/home/support/attributes.hpp 2011-03-03 13:49:26 EST (Thu, 03 Mar 2011)
@@ -82,7 +82,9 @@
{
template <typename T, typename Expected>
struct value_type_is_substitute
- : is_substitute<typename T::value_type, typename Expected::value_type>
+ : is_substitute<
+ typename container_value<T>::type
+ , typename container_value<Expected>::type>
{};
}
@@ -121,7 +123,9 @@
{
template <typename T, typename Expected>
struct value_type_is_weak_substitute
- : is_weak_substitute<typename T::value_type, typename Expected::value_type>
+ : is_weak_substitute<
+ typename container_value<T>::type
+ , typename container_value<Expected>::type>
{};
}
Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2011-03-03 13:49:26 EST (Thu, 03 Mar 2011)
@@ -66,7 +66,8 @@
[ run qi/not_predicate.cpp : : : : qi_not_predicate ]
[ run qi/optional.cpp : : : : qi_optional ]
[ run qi/parse_attr.cpp : : : : qi_parse_attr ]
- [ run qi/pass_container.cpp : : : : qi_pass_container ]
+ [ run qi/pass_container1.cpp : : : : qi_pass_container1 ]
+ [ run qi/pass_container2.cpp : : : : qi_pass_container2 ]
[ run qi/permutation.cpp : : : : qi_permutation ]
[ run qi/plus.cpp : : : : qi_plus ]
[ run qi/range_run.cpp : : : : qi_range_run ]
@@ -113,6 +114,7 @@
[ run qi/regression_repeat.cpp : : : : qi_regression_repeat ]
[ run qi/regression_transform_assignment.cpp : : : : qi_regression_transform_assignment ]
[ compile qi/regression_fusion_proto_spirit.cpp : : qi_regression_fusion_proto_spirit ]
+ [ compile qi/pass_container3.cpp : : qi_pass_container3 ]
;
###########################################################################
Deleted: trunk/libs/spirit/test/qi/pass_container.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/pass_container.cpp 2011-03-03 13:49:26 EST (Thu, 03 Mar 2011)
+++ (empty file)
@@ -1,326 +0,0 @@
-// 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)
-
-#include <string>
-#include <vector>
-#include <set>
-#include <map>
-
-#include <boost/detail/lightweight_test.hpp>
-
-#include <boost/spirit/include/qi_operator.hpp>
-#include <boost/spirit/include/qi_char.hpp>
-#include <boost/spirit/include/qi_string.hpp>
-#include <boost/spirit/include/qi_numeric.hpp>
-#include <boost/spirit/include/qi_directive.hpp>
-#include <boost/spirit/include/qi_action.hpp>
-#include <boost/spirit/include/qi_auxiliary.hpp>
-#include <boost/spirit/include/support_argument.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_object.hpp>
-#include <boost/spirit/include/phoenix_stl.hpp>
-#include <boost/fusion/include/std_pair.hpp>
-
-#include <string>
-#include <iostream>
-#include "test.hpp"
-
-using namespace spirit_test;
-
-inline bool compare(std::vector<char> const& v, std::string const& s)
-{
- return v.size() == s.size() && std::equal(v.begin(), v.end(), s.begin());
-}
-
-int main()
-{
- using boost::spirit::qi::char_;
- using boost::spirit::qi::omit;
-
- {
- std::vector<char> v;
- BOOST_TEST(test_attr("a,b,c,d,e,f,g,h", char_ % ',', v) &&
- compare(v, "abcdefgh"));
-
- std::string s;
- BOOST_TEST(test_attr("a,b,c,d,e,f,g,h", char_ % ',', s) &&
- s == "abcdefgh");
-
- BOOST_TEST(test("a,b,c,d,e,f,g,h", char_ % ','));
- BOOST_TEST(test("a,b,c,d,e,f,g,h", omit[char_] % ','));
- }
-
- {
- std::vector<char> v1;
- BOOST_TEST(test_attr("ab,cd,ef,gh", (char_ >> char_) % ',', v1) &&
- compare(v1, "abcdefgh"));
- v1.clear();
- BOOST_TEST(test_attr("ab,cd,ef,gh", (char_ >> omit[char_]) % ',', v1) &&
- compare(v1, "aceg"));
-
- std::string s;
- BOOST_TEST(test_attr("ab,cd,ef,gh", (char_ >> char_) % ',', s) &&
- s == "abcdefgh");
- s.clear();
- BOOST_TEST(test_attr("ab,cd,ef,gh", (char_ >> omit[char_]) % ',', s) &&
- s == "aceg");
-
- std::vector<std::pair<char, char> > v2;
- BOOST_TEST(test_attr("ab,cd,ef,gh", (char_ >> char_) % ',', v2) &&
- v2.size() == 4 &&
- v2[0] == std::make_pair('a', 'b') &&
- v2[1] == std::make_pair('c', 'd') &&
- v2[2] == std::make_pair('e', 'f') &&
- v2[3] == std::make_pair('g', 'h'));
-
- s.clear();
- BOOST_TEST(test_attr("ab,cd,efg", (char_ >> char_) % ',' >> char_, s) &&
- s == "abcdefg");
-
- BOOST_TEST(test("ab,cd,ef,gh", (char_ >> char_) % ','));
- BOOST_TEST(test("ab,cd,ef,gh", (omit[char_ >> char_]) % ','));
- }
-
- {
- std::vector<char> v1;
- BOOST_TEST(test_attr("abc,def,gh", (char_ >> *~char_(',')) % ',', v1) &&
- compare(v1, "abcdefgh"));
- v1.clear();
- BOOST_TEST(test_attr("abc,def,gh", (char_ >> omit[*~char_(',')]) % ',', v1) &&
- compare(v1, "adg"));
- v1.clear();
- BOOST_TEST(test_attr("abc,def,gh", (omit[char_] >> *~char_(',')) % ',', v1) &&
- compare(v1, "bcefh"));
-
- std::string s1;
- BOOST_TEST(test_attr("abc,def,gh", (char_ >> *~char_(',')) % ',', s1) &&
- s1 == "abcdefgh");
- s1.clear();
- BOOST_TEST(test_attr("abc,def,gh", (char_ >> omit[*~char_(',')]) % ',', s1) &&
- s1 == "adg");
- s1.clear();
- BOOST_TEST(test_attr("abc,def,gh", (omit[char_] >> *~char_(',')) % ',', s1) &&
- s1 == "bcefh");
-
- std::vector<std::pair<char, std::vector<char> > > v2;
- BOOST_TEST(test_attr("abc,def,gh", (char_ >> *~char_(',')) % ',', v2) &&
- v2.size() == 3 &&
- v2[0].first == 'a' && compare(v2[0].second, "bc") &&
- v2[1].first == 'd' && compare(v2[1].second, "ef") &&
- v2[2].first == 'g' && compare(v2[2].second, "h"));
-
- std::vector<std::vector<char> > v3;
- BOOST_TEST(test_attr("abc,def,gh", (omit[char_] >> *~char_(',')) % ',', v3) &&
- v3.size() == 3 &&
- compare(v3[0], "bc") && compare(v3[1], "ef") &&
- compare(v3[2], "h"));
-
- std::vector<char> v4;
- BOOST_TEST(test_attr("abc,def,gh", (char_ >> omit[*~char_(',')]) % ',', v4) &&
- v4.size() == 3 &&
- v4[0] == 'a' && v4[1] == 'd' && v4[2] == 'g');
-
- std::vector<std::string> v5;
- BOOST_TEST(test_attr("abc,def,gh", (omit[char_] >> *~char_(',')) % ',', v5) &&
- v5.size() == 3 &&
- v5[0] == "bc" && v5[1] == "ef" && v5[2] == "h");
-
- std::string s2;
- BOOST_TEST(test_attr("abc,def,gh", (char_ >> omit[*~char_(',')]) % ',', s2) &&
- s2.size() == 3 &&
- s2 == "adg");
-
- BOOST_TEST(test("abc,def,gh", (char_ >> *~char_(',')) % ','));
- BOOST_TEST(test("abc,def,gh", (omit[char_ >> *~char_(',')]) % ','));
- }
-
- {
- using boost::spirit::qi::alpha;
- using boost::spirit::qi::digit;
-
- std::vector<char> v1;
- BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> *digit) % ',', v1) &&
- compare(v1, "ab12cd34ef56"));
- v1.clear();
- BOOST_TEST(test_attr("ab12,cd34,ef56", (omit[*alpha] >> *digit) % ',', v1) &&
- compare(v1, "123456"));
- v1.clear();
- BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> omit[*digit]) % ',', v1) &&
- compare(v1, "abcdef"));
-
- std::string s1;
- BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> *digit) % ',', s1) &&
- s1 == "ab12cd34ef56");
- s1.clear();
- BOOST_TEST(test_attr("ab12,cd34,ef56", (omit[*alpha] >> *digit) % ',', s1) &&
- s1 == "123456");
- s1.clear();
- BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> omit[*digit]) % ',', s1) &&
- s1 == "abcdef");
-
- std::vector<std::pair<std::vector<char>, std::vector<char> > > v2;
- BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> *digit) % ',', v2) &&
- v2.size() == 3 &&
- compare(v2[0].first, "ab") && compare(v2[0].second, "12") &&
- compare(v2[1].first, "cd") && compare(v2[1].second, "34") &&
- compare(v2[2].first, "ef") && compare(v2[2].second, "56"));
-
- std::vector<std::pair<std::string, std::string> > v3;
- BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> *digit) % ',', v3) &&
- v3.size() == 3 &&
- v3[0].first == "ab" && v3[0].second == "12" &&
- v3[1].first == "cd" && v3[1].second == "34" &&
- v3[2].first == "ef" && v3[2].second == "56");
-
- std::vector<std::vector<char> > v4;
- BOOST_TEST(test_attr("ab12,cd34,ef56", (omit[*alpha] >> *digit) % ',', v4) &&
- v4.size() == 3 &&
- compare(v4[0], "12") &&
- compare(v4[1], "34") &&
- compare(v4[2], "56"));
-
- BOOST_TEST(test("ab12,cd34,ef56", (*alpha >> *digit) % ','));
- BOOST_TEST(test("ab12,cd34,ef56", omit[*alpha >> *digit] % ','));
- }
-
- {
- std::vector<std::vector<char> > v1;
- BOOST_TEST(test_attr("abc,def,gh", *~char_(',') % ',', v1) &&
- v1.size() == 3 &&
- compare(v1[0], "abc") &&
- compare(v1[1], "def") &&
- compare(v1[2], "gh"));
-
- std::vector<std::string> v2;
- BOOST_TEST(test_attr("abc,def,gh", *~char_(',') % ',', v2) &&
- v2.size() == 3 && v2[0] == "abc" && v2[1] == "def" && v2[2] == "gh");
-
- BOOST_TEST(test("abc,def,gh", *~char_(',') % ','));
- BOOST_TEST(test("abc,def,gh", omit[*~char_(',')] % ','));
- }
-
- {
- std::vector<char> v1;
- BOOST_TEST(test_attr("a", char_ >> -(char_ % ','), v1) &&
- compare(v1, "a"));
- v1.clear();
- BOOST_TEST(test_attr("ab,c", char_ >> -(char_ % ','), v1) &&
- compare(v1, "abc"));
- v1.clear();
- BOOST_TEST(test_attr("a", char_ >> -char_, v1) &&
- compare(v1, "a"));
- v1.clear();
- BOOST_TEST(test_attr("ab", char_ >> -char_, v1) &&
- compare(v1, "ab"));
-
- std::vector<boost::optional<char> > v2;
- BOOST_TEST(test_attr("a", char_ >> -char_, v2) &&
- v2.size() == 2 &&
- boost::get<char>(v2[0]) == 'a' &&
- !v2[1]);
- v2.clear();
- BOOST_TEST(test_attr("ab", char_ >> -char_, v2) &&
- v2.size() == 2 &&
- boost::get<char>(v2[0]) == 'a' &&
- boost::get<char>(v2[1]) == 'b');
-
- std::string s;
- BOOST_TEST(test_attr("a", char_ >> -(char_ % ','), s) &&
- s == "a");
- s.clear();
- BOOST_TEST(test_attr("ab,c", char_ >> -(char_ % ','), s) &&
- s == "abc");
- s.clear();
- BOOST_TEST(test_attr("ab", char_ >> -char_, s) &&
- s == "ab");
- s.clear();
- BOOST_TEST(test_attr("a", char_ >> -char_, s) &&
- s == "a");
-
- BOOST_TEST(test("a", char_ >> -(char_ % ',')));
- BOOST_TEST(test("ab,c", char_ >> -(char_ % ',')));
- BOOST_TEST(test("a", char_ >> -char_));
- BOOST_TEST(test("ab", char_ >> -char_));
- }
-
- {
- using boost::spirit::qi::eps;
-
- std::vector<char> v;
- BOOST_TEST(test_attr("a", char_ >> ((char_ % ',') | eps), v) &&
- compare(v, "a"));
- v.clear();
- BOOST_TEST(test_attr("ab,c", char_ >> ((char_ % ',') | eps), v) &&
- compare(v, "abc"));
-
- std::string s;
- BOOST_TEST(test_attr("a", char_ >> ((char_ % ',') | eps), s) &&
- s == "a");
- s.clear();
- BOOST_TEST(test_attr("ab,c", char_ >> ((char_ % ',') | eps), s) &&
- s == "abc");
-
- BOOST_TEST(test("a", char_ >> ((char_ % ',') | eps)));
- BOOST_TEST(test("ab,c", char_ >> ((char_ % ',') | eps)));
- }
-
- {
- std::vector<char> v1;
- BOOST_TEST(test_attr("abc1,abc2",
- *~char_(',') >> *(',' >> *~char_(',')), v1) &&
- compare(v1, "abc1abc2"));
-
- std::vector<std::string> v2;
- BOOST_TEST(test_attr("abc1,abc2",
- *~char_(',') >> *(',' >> *~char_(',')), v2) &&
- v2.size() == 2 &&
- v2[0] == "abc1" &&
- v2[1] == "abc2");
-
- std::string s;
- BOOST_TEST(test_attr("abc1,abc2",
- *~char_(',') >> *(',' >> *~char_(',')), s) &&
- s == "abc1abc2");
- }
-
- {
- using boost::spirit::qi::alpha;
- using boost::spirit::qi::digit;
-
- std::vector<char> v1;
- BOOST_TEST(test_attr("ab1cd2", *(alpha >> alpha | +digit), v1) &&
- compare(v1, "ab1cd2"));
- v1.clear();
- BOOST_TEST(test_attr("ab1cd2", *(alpha >> alpha | digit), v1) &&
- compare(v1, "ab1cd2"));
-
- std::string s1;
- BOOST_TEST(test_attr("ab1cd2", *(alpha >> alpha | +digit), s1) &&
- s1 == "ab1cd2");
- s1.clear();
- BOOST_TEST(test_attr("ab1cd2", *(alpha >> alpha | digit), s1) &&
- s1 == "ab1cd2");
-
-// doesn't work yet
-// std::vector<std::vector<char> > v2;
-// BOOST_TEST(test_attr("ab1cd123", *(alpha >> alpha | +digit), v2) &&
-// v2.size() == 4 &&
-// compare(v2[0], "ab") &&
-// compare(v2[1], "1") &&
-// compare(v2[2], "cd") &&
-// compare(v2[3], "123"));
-//
-// std::vector<std::string> v3;
-// BOOST_TEST(test_attr("ab1cd123", *(alpha >> alpha | +digit), v3) &&
-// v3.size() == 4 &&
-// v3[0] == "ab" &&
-// v3[1] == "1" &&
-// v3[2] == "cd" &&
-// v3[3] == "123");
- }
- return boost::report_errors();
-}
-
Added: trunk/libs/spirit/test/qi/pass_container1.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/pass_container1.cpp 2011-03-03 13:49:26 EST (Thu, 03 Mar 2011)
@@ -0,0 +1,191 @@
+// 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)
+
+#include <string>
+#include <vector>
+#include <set>
+#include <map>
+
+#include <boost/detail/lightweight_test.hpp>
+
+#include <boost/spirit/include/qi_operator.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_string.hpp>
+#include <boost/spirit/include/qi_numeric.hpp>
+#include <boost/spirit/include/qi_directive.hpp>
+#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/qi_auxiliary.hpp>
+#include <boost/spirit/include/support_argument.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_object.hpp>
+#include <boost/spirit/include/phoenix_stl.hpp>
+#include <boost/fusion/include/std_pair.hpp>
+
+#include <string>
+#include <iostream>
+#include "test.hpp"
+
+using namespace spirit_test;
+
+inline bool compare(std::vector<char> const& v, std::string const& s)
+{
+ return v.size() == s.size() && std::equal(v.begin(), v.end(), s.begin());
+}
+
+int main()
+{
+ using boost::spirit::qi::char_;
+ using boost::spirit::qi::omit;
+
+ {
+ std::vector<char> v;
+ BOOST_TEST(test_attr("a,b,c,d,e,f,g,h", char_ % ',', v) &&
+ compare(v, "abcdefgh"));
+
+ std::string s;
+ BOOST_TEST(test_attr("a,b,c,d,e,f,g,h", char_ % ',', s) &&
+ s == "abcdefgh");
+
+ BOOST_TEST(test("a,b,c,d,e,f,g,h", char_ % ','));
+ BOOST_TEST(test("a,b,c,d,e,f,g,h", omit[char_] % ','));
+ }
+
+ {
+ std::vector<char> v1;
+ BOOST_TEST(test_attr("ab,cd,ef,gh", (char_ >> char_) % ',', v1) &&
+ compare(v1, "abcdefgh"));
+ v1.clear();
+ BOOST_TEST(test_attr("ab,cd,ef,gh", (char_ >> omit[char_]) % ',', v1) &&
+ compare(v1, "aceg"));
+
+ std::string s;
+ BOOST_TEST(test_attr("ab,cd,ef,gh", (char_ >> char_) % ',', s) &&
+ s == "abcdefgh");
+ s.clear();
+ BOOST_TEST(test_attr("ab,cd,ef,gh", (char_ >> omit[char_]) % ',', s) &&
+ s == "aceg");
+
+ std::vector<std::pair<char, char> > v2;
+ BOOST_TEST(test_attr("ab,cd,ef,gh", (char_ >> char_) % ',', v2) &&
+ v2.size() == 4 &&
+ v2[0] == std::make_pair('a', 'b') &&
+ v2[1] == std::make_pair('c', 'd') &&
+ v2[2] == std::make_pair('e', 'f') &&
+ v2[3] == std::make_pair('g', 'h'));
+
+ s.clear();
+ BOOST_TEST(test_attr("ab,cd,efg", (char_ >> char_) % ',' >> char_, s) &&
+ s == "abcdefg");
+
+ BOOST_TEST(test("ab,cd,ef,gh", (char_ >> char_) % ','));
+ BOOST_TEST(test("ab,cd,ef,gh", (omit[char_ >> char_]) % ','));
+ }
+
+ {
+ std::vector<char> v1;
+ BOOST_TEST(test_attr("abc,def,gh", (char_ >> *~char_(',')) % ',', v1) &&
+ compare(v1, "abcdefgh"));
+ v1.clear();
+ BOOST_TEST(test_attr("abc,def,gh", (char_ >> omit[*~char_(',')]) % ',', v1) &&
+ compare(v1, "adg"));
+ v1.clear();
+ BOOST_TEST(test_attr("abc,def,gh", (omit[char_] >> *~char_(',')) % ',', v1) &&
+ compare(v1, "bcefh"));
+
+ std::string s1;
+ BOOST_TEST(test_attr("abc,def,gh", (char_ >> *~char_(',')) % ',', s1) &&
+ s1 == "abcdefgh");
+ s1.clear();
+ BOOST_TEST(test_attr("abc,def,gh", (char_ >> omit[*~char_(',')]) % ',', s1) &&
+ s1 == "adg");
+ s1.clear();
+ BOOST_TEST(test_attr("abc,def,gh", (omit[char_] >> *~char_(',')) % ',', s1) &&
+ s1 == "bcefh");
+
+ std::vector<std::pair<char, std::vector<char> > > v2;
+ BOOST_TEST(test_attr("abc,def,gh", (char_ >> *~char_(',')) % ',', v2) &&
+ v2.size() == 3 &&
+ v2[0].first == 'a' && compare(v2[0].second, "bc") &&
+ v2[1].first == 'd' && compare(v2[1].second, "ef") &&
+ v2[2].first == 'g' && compare(v2[2].second, "h"));
+
+ std::vector<std::vector<char> > v3;
+ BOOST_TEST(test_attr("abc,def,gh", (omit[char_] >> *~char_(',')) % ',', v3) &&
+ v3.size() == 3 &&
+ compare(v3[0], "bc") && compare(v3[1], "ef") &&
+ compare(v3[2], "h"));
+
+ std::vector<char> v4;
+ BOOST_TEST(test_attr("abc,def,gh", (char_ >> omit[*~char_(',')]) % ',', v4) &&
+ v4.size() == 3 &&
+ v4[0] == 'a' && v4[1] == 'd' && v4[2] == 'g');
+
+ std::vector<std::string> v5;
+ BOOST_TEST(test_attr("abc,def,gh", (omit[char_] >> *~char_(',')) % ',', v5) &&
+ v5.size() == 3 &&
+ v5[0] == "bc" && v5[1] == "ef" && v5[2] == "h");
+
+ std::string s2;
+ BOOST_TEST(test_attr("abc,def,gh", (char_ >> omit[*~char_(',')]) % ',', s2) &&
+ s2.size() == 3 &&
+ s2 == "adg");
+
+ BOOST_TEST(test("abc,def,gh", (char_ >> *~char_(',')) % ','));
+ BOOST_TEST(test("abc,def,gh", (omit[char_ >> *~char_(',')]) % ','));
+ }
+
+ {
+ using boost::spirit::qi::alpha;
+ using boost::spirit::qi::digit;
+
+ std::vector<char> v1;
+ BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> *digit) % ',', v1) &&
+ compare(v1, "ab12cd34ef56"));
+ v1.clear();
+ BOOST_TEST(test_attr("ab12,cd34,ef56", (omit[*alpha] >> *digit) % ',', v1) &&
+ compare(v1, "123456"));
+ v1.clear();
+ BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> omit[*digit]) % ',', v1) &&
+ compare(v1, "abcdef"));
+
+ std::string s1;
+ BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> *digit) % ',', s1) &&
+ s1 == "ab12cd34ef56");
+ s1.clear();
+ BOOST_TEST(test_attr("ab12,cd34,ef56", (omit[*alpha] >> *digit) % ',', s1) &&
+ s1 == "123456");
+ s1.clear();
+ BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> omit[*digit]) % ',', s1) &&
+ s1 == "abcdef");
+
+ std::vector<std::pair<std::vector<char>, std::vector<char> > > v2;
+ BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> *digit) % ',', v2) &&
+ v2.size() == 3 &&
+ compare(v2[0].first, "ab") && compare(v2[0].second, "12") &&
+ compare(v2[1].first, "cd") && compare(v2[1].second, "34") &&
+ compare(v2[2].first, "ef") && compare(v2[2].second, "56"));
+
+ std::vector<std::pair<std::string, std::string> > v3;
+ BOOST_TEST(test_attr("ab12,cd34,ef56", (*alpha >> *digit) % ',', v3) &&
+ v3.size() == 3 &&
+ v3[0].first == "ab" && v3[0].second == "12" &&
+ v3[1].first == "cd" && v3[1].second == "34" &&
+ v3[2].first == "ef" && v3[2].second == "56");
+
+ std::vector<std::vector<char> > v4;
+ BOOST_TEST(test_attr("ab12,cd34,ef56", (omit[*alpha] >> *digit) % ',', v4) &&
+ v4.size() == 3 &&
+ compare(v4[0], "12") &&
+ compare(v4[1], "34") &&
+ compare(v4[2], "56"));
+
+ BOOST_TEST(test("ab12,cd34,ef56", (*alpha >> *digit) % ','));
+ BOOST_TEST(test("ab12,cd34,ef56", omit[*alpha >> *digit] % ','));
+ }
+
+ return boost::report_errors();
+}
+
Added: trunk/libs/spirit/test/qi/pass_container2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/pass_container2.cpp 2011-03-03 13:49:26 EST (Thu, 03 Mar 2011)
@@ -0,0 +1,184 @@
+// 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)
+
+#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
+
+#include <string>
+#include <vector>
+#include <set>
+#include <map>
+#include <iostream>
+
+#include <boost/spirit/include/qi_operator.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_string.hpp>
+#include <boost/spirit/include/qi_numeric.hpp>
+#include <boost/spirit/include/qi_directive.hpp>
+#include <boost/spirit/include/qi_action.hpp>
+#include <boost/spirit/include/qi_auxiliary.hpp>
+#include <boost/spirit/include/support_argument.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include <boost/spirit/include/phoenix_object.hpp>
+#include <boost/spirit/include/phoenix_stl.hpp>
+#include <boost/fusion/include/std_pair.hpp>
+
+#include "test.hpp"
+
+using namespace spirit_test;
+
+inline bool compare(std::vector<char> const& v, std::string const& s)
+{
+ return v.size() == s.size() && std::equal(v.begin(), v.end(), s.begin());
+}
+
+int main()
+{
+ using boost::spirit::qi::char_;
+ using boost::spirit::qi::omit;
+
+ {
+ std::vector<std::vector<char> > v1;
+ BOOST_TEST(test_attr("abc,def,gh", *~char_(',') % ',', v1) &&
+ v1.size() == 3 &&
+ compare(v1[0], "abc") &&
+ compare(v1[1], "def") &&
+ compare(v1[2], "gh"));
+
+ std::vector<std::string> v2;
+ BOOST_TEST(test_attr("abc,def,gh", *~char_(',') % ',', v2) &&
+ v2.size() == 3 && v2[0] == "abc" && v2[1] == "def" && v2[2] == "gh");
+
+ BOOST_TEST(test("abc,def,gh", *~char_(',') % ','));
+ BOOST_TEST(test("abc,def,gh", omit[*~char_(',')] % ','));
+ }
+
+ {
+ std::vector<char> v1;
+ BOOST_TEST(test_attr("a", char_ >> -(char_ % ','), v1) &&
+ compare(v1, "a"));
+ v1.clear();
+ BOOST_TEST(test_attr("ab,c", char_ >> -(char_ % ','), v1) &&
+ compare(v1, "abc"));
+ v1.clear();
+ BOOST_TEST(test_attr("a", char_ >> -char_, v1) &&
+ compare(v1, "a"));
+ v1.clear();
+ BOOST_TEST(test_attr("ab", char_ >> -char_, v1) &&
+ compare(v1, "ab"));
+
+ std::vector<boost::optional<char> > v2;
+ BOOST_TEST(test_attr("a", char_ >> -char_, v2) &&
+ v2.size() == 2 &&
+ boost::get<char>(v2[0]) == 'a' &&
+ !v2[1]);
+ v2.clear();
+ BOOST_TEST(test_attr("ab", char_ >> -char_, v2) &&
+ v2.size() == 2 &&
+ boost::get<char>(v2[0]) == 'a' &&
+ boost::get<char>(v2[1]) == 'b');
+
+ std::string s;
+ BOOST_TEST(test_attr("a", char_ >> -(char_ % ','), s) &&
+ s == "a");
+ s.clear();
+ BOOST_TEST(test_attr("ab,c", char_ >> -(char_ % ','), s) &&
+ s == "abc");
+ s.clear();
+ BOOST_TEST(test_attr("ab", char_ >> -char_, s) &&
+ s == "ab");
+ s.clear();
+ BOOST_TEST(test_attr("a", char_ >> -char_, s) &&
+ s == "a");
+
+ BOOST_TEST(test("a", char_ >> -(char_ % ',')));
+ BOOST_TEST(test("ab,c", char_ >> -(char_ % ',')));
+ BOOST_TEST(test("a", char_ >> -char_));
+ BOOST_TEST(test("ab", char_ >> -char_));
+ }
+
+ {
+ using boost::spirit::qi::eps;
+
+ std::vector<char> v;
+ BOOST_TEST(test_attr("a", char_ >> ((char_ % ',') | eps), v) &&
+ compare(v, "a"));
+ v.clear();
+ BOOST_TEST(test_attr("ab,c", char_ >> ((char_ % ',') | eps), v) &&
+ compare(v, "abc"));
+
+ std::string s;
+ BOOST_TEST(test_attr("a", char_ >> ((char_ % ',') | eps), s) &&
+ s == "a");
+ s.clear();
+ BOOST_TEST(test_attr("ab,c", char_ >> ((char_ % ',') | eps), s) &&
+ s == "abc");
+
+ BOOST_TEST(test("a", char_ >> ((char_ % ',') | eps)));
+ BOOST_TEST(test("ab,c", char_ >> ((char_ % ',') | eps)));
+ }
+
+ {
+ std::vector<char> v1;
+ BOOST_TEST(test_attr("abc1,abc2",
+ *~char_(',') >> *(',' >> *~char_(',')), v1) &&
+ compare(v1, "abc1abc2"));
+
+ std::vector<std::string> v2;
+ BOOST_TEST(test_attr("abc1,abc2",
+ *~char_(',') >> *(',' >> *~char_(',')), v2) &&
+ v2.size() == 2 &&
+ v2[0] == "abc1" &&
+ v2[1] == "abc2");
+
+ std::string s;
+ BOOST_TEST(test_attr("abc1,abc2",
+ *~char_(',') >> *(',' >> *~char_(',')), s) &&
+ s == "abc1abc2");
+ }
+
+ {
+ using boost::spirit::qi::alpha;
+ using boost::spirit::qi::digit;
+
+ std::vector<char> v1;
+ BOOST_TEST(test_attr("ab1cd2", *(alpha >> alpha | +digit), v1) &&
+ compare(v1, "ab1cd2"));
+ v1.clear();
+ BOOST_TEST(test_attr("ab1cd2", *(alpha >> alpha | digit), v1) &&
+ compare(v1, "ab1cd2"));
+
+ std::string s1;
+ BOOST_TEST(test_attr("ab1cd2", *(alpha >> alpha | +digit), s1) &&
+ s1 == "ab1cd2");
+ s1.clear();
+ BOOST_TEST(test_attr("ab1cd2", *(alpha >> alpha | digit), s1) &&
+ s1 == "ab1cd2");
+
+// doesn't work yet
+// std::vector<std::vector<char> > v2;
+// BOOST_TEST(test_attr("ab1cd123", *(alpha >> alpha | +digit), v2) &&
+// v2.size() == 4 &&
+// compare(v2[0], "ab") &&
+// compare(v2[1], "1") &&
+// compare(v2[2], "cd") &&
+// compare(v2[3], "123"));
+//
+// std::vector<std::string> v3;
+// BOOST_TEST(test_attr("ab1cd123", *(alpha >> alpha | +digit), v3) &&
+// v3.size() == 4 &&
+// v3[0] == "ab" &&
+// v3[1] == "1" &&
+// v3[2] == "cd" &&
+// v3[3] == "123");
+ }
+
+ {
+ }
+
+ return boost::report_errors();
+}
+
Added: trunk/libs/spirit/test/qi/pass_container3.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/pass_container3.cpp 2011-03-03 13:49:26 EST (Thu, 03 Mar 2011)
@@ -0,0 +1,46 @@
+// 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)
+
+// compilation test only
+
+#include <string>
+#include <vector>
+
+#include <boost/spirit/include/qi.hpp>
+#include <boost/fusion/include/adapt_struct.hpp>
+
+#include <boost/variant.hpp>
+
+//////////////////////////////////////////////////////////////////////////////
+struct ast; // Forward declaration
+
+typedef boost::variant<
+ double, char, int, std::string, boost::recursive_wrapper<ast>
+> ast_element;
+
+struct ast
+{
+ int op;
+ std::vector<ast_element> children;
+ ast() {}
+};
+
+BOOST_FUSION_ADAPT_STRUCT(
+ ast,
+ (int, op)
+ (std::vector<ast_element>, children)
+)
+
+///////////////////////////////////////////////////////////////////////////////
+int main()
+{
+ namespace qi = boost::spirit::qi;
+
+ qi::rule<char const*, ast()> num_expr;
+ num_expr = (*(qi::char_ >> num_expr))[ qi::_1 ];
+
+ return 0;
+}
+
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