1 | /*============================================================================= |
---|
2 | Phoenix V1.2.1 |
---|
3 | Copyright (c) 2001-2003 Joel de Guzman |
---|
4 | |
---|
5 | Use, modification and distribution is subject to the Boost Software |
---|
6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
7 | http://www.boost.org/LICENSE_1_0.txt) |
---|
8 | ==============================================================================*/ |
---|
9 | #include <iostream> |
---|
10 | #include <vector> |
---|
11 | #include <algorithm> |
---|
12 | #include <string> |
---|
13 | #include <boost/detail/lightweight_test.hpp> |
---|
14 | |
---|
15 | #include <boost/config.hpp> |
---|
16 | #ifdef BOOST_NO_STRINGSTREAM |
---|
17 | #include <strstream> |
---|
18 | #define SSTREAM strstream |
---|
19 | std::string GETSTRING(std::strstream& ss) |
---|
20 | { |
---|
21 | ss << ends; |
---|
22 | std::string rval = ss.str(); |
---|
23 | ss.freeze(false); |
---|
24 | return rval; |
---|
25 | } |
---|
26 | #else |
---|
27 | #include <sstream> |
---|
28 | #define GETSTRING(ss) ss.str() |
---|
29 | #define SSTREAM stringstream |
---|
30 | #endif |
---|
31 | |
---|
32 | //#define PHOENIX_LIMIT 15 |
---|
33 | #include <boost/spirit/phoenix/primitives.hpp> |
---|
34 | #include <boost/spirit/phoenix/composite.hpp> |
---|
35 | #include <boost/spirit/phoenix/operators.hpp> |
---|
36 | #include <boost/spirit/phoenix/special_ops.hpp> |
---|
37 | |
---|
38 | using namespace phoenix; |
---|
39 | using namespace std; |
---|
40 | |
---|
41 | /////////////////////////////////////////////////////////////////////////////// |
---|
42 | int |
---|
43 | main() |
---|
44 | { |
---|
45 | int i100 = 100; |
---|
46 | string hello = "hello"; |
---|
47 | const char* world = " world"; |
---|
48 | |
---|
49 | /////////////////////////////////////////////////////////////////////////////// |
---|
50 | // |
---|
51 | // IO streams |
---|
52 | // |
---|
53 | /////////////////////////////////////////////////////////////////////////////// |
---|
54 | vector<int> v; |
---|
55 | v.push_back(1); |
---|
56 | v.push_back(2); |
---|
57 | v.push_back(3); |
---|
58 | v.push_back(4); |
---|
59 | v.push_back(5); |
---|
60 | |
---|
61 | char const* msg = "cout assert\n"; |
---|
62 | (cout << arg1)(msg); |
---|
63 | (cout << val(hello) << world << ", you da man!\n")(); |
---|
64 | for_each(v.begin(), v.end(), cout << arg1 << ','); |
---|
65 | cout << endl; |
---|
66 | |
---|
67 | #ifdef __BORLANDC__ // *** See special_ops.hpp why *** |
---|
68 | (cout << arg1 << "this is it, shukz:" << hex_ << arg2 << endl_ << endl_)(msg, i100); |
---|
69 | #else |
---|
70 | (cout << arg1 << "this is it, shukz:" << hex << arg2 << endl << endl)(msg, i100); |
---|
71 | #endif |
---|
72 | int in; |
---|
73 | int out = 12345; |
---|
74 | SSTREAM sstr; |
---|
75 | (sstr << arg1)(out); |
---|
76 | (sstr >> arg1)(in); |
---|
77 | BOOST_TEST(in == out); |
---|
78 | |
---|
79 | /////////////////////////////////////////////////////////////////////////////// |
---|
80 | // |
---|
81 | // End asserts |
---|
82 | // |
---|
83 | /////////////////////////////////////////////////////////////////////////////// |
---|
84 | |
---|
85 | return boost::report_errors(); |
---|
86 | } |
---|