1 /*
2 *
3 * Copyright (c) 2003
4 * John Maddock
5 *
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 *
10 */
11
12 //
13 // This define keep ICU in it's own namespace: helps us to track bugs that would
14 // otherwise go unnoticed:
15 //
16 #define U_USING_ICU_NAMESPACE 0
17
18 #include <boost/regex/config.hpp>
19
20 #if defined(BOOST_MSVC)
21 // this lets us compile at warning level 4 without seeing concept-check related warnings
22 # pragma warning(disable:4100)
23 #endif
24 #ifdef __BORLANDC__
25 #pragma option -w-8019 -w-8004 -w-8008
26 #endif
27
28 #ifdef BOOST_HAS_ICU
29
30 #include <boost/regex/icu.hpp>
31 #include <boost/detail/workaround.hpp>
32 #if !BOOST_WORKAROUND(_MSC_VER, < 1310) && !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__GNUC__, < 3)
33 #include <boost/regex/concepts.hpp>
34 #endif
35
36
main()37 int main()
38 {
39 // VC6 and VC7 can't cope with the iterator architypes,
40 // don't bother testing as it doesn't work:
41 #if !BOOST_WORKAROUND(_MSC_VER, < 1310) && !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__GNUC__, < 3)
42 boost::function_requires<
43 boost::RegexTraitsConcept<
44 boost::icu_regex_traits
45 >
46 >();
47 boost::function_requires<
48 boost::BoostRegexConcept<
49 boost::u32regex
50 >
51 >();
52 //
53 // Now test additional function overloads:
54 //
55 bool b;
56 unsigned long buf[2] = { 0, };
57 const void* pb = buf;
58 typedef boost::bidirectional_iterator_archetype<char> utf8_arch1;
59 typedef boost::bidirectional_iterator_archetype<unsigned char> utf8_arch2;
60 typedef boost::bidirectional_iterator_archetype<UChar> utf16_arch;
61 typedef boost::bidirectional_iterator_archetype<wchar_t> wchar_arch;
62 boost::match_results<utf8_arch1> m1;
63 boost::match_results<utf8_arch2> m2;
64 boost::match_results<utf16_arch> m3;
65 boost::match_results<wchar_arch> m4;
66 boost::match_results<const char*> cm1;
67 boost::match_results<const unsigned char*> cm2;
68 boost::match_results<const UChar*> cm3;
69 boost::match_results<const wchar_t*> cm4;
70 boost::match_results<std::string::const_iterator> sm1;
71 boost::match_results<std::wstring::const_iterator> sm2;
72 boost::u32regex e1;
73 boost::regex_constants::match_flag_type flgs = boost::regex_constants::match_default;
74 std::string s1;
75 std::wstring s2;
76 U_NAMESPACE_QUALIFIER UnicodeString us;
77 b = boost::u32regex_match(utf8_arch1(), utf8_arch1(), m1, e1, flgs);
78 b = boost::u32regex_match(utf8_arch1(), utf8_arch1(), m1, e1);
79 b = boost::u32regex_match(utf8_arch2(), utf8_arch2(), m2, e1, flgs);
80 b = boost::u32regex_match(utf8_arch2(), utf8_arch2(), m2, e1);
81 b = boost::u32regex_match(utf16_arch(), utf16_arch(), m3, e1, flgs);
82 b = boost::u32regex_match(utf16_arch(), utf16_arch(), m3, e1);
83 b = boost::u32regex_match(wchar_arch(), wchar_arch(), m4, e1, flgs);
84 b = boost::u32regex_match(wchar_arch(), wchar_arch(), m4, e1);
85 b = boost::u32regex_match((const char*)(pb), cm1, e1, flgs);
86 b = boost::u32regex_match((const char*)(pb), cm1, e1);
87 b = boost::u32regex_match((const unsigned char*)(pb), cm2, e1, flgs);
88 b = boost::u32regex_match((const unsigned char*)(pb), cm2, e1);
89 b = boost::u32regex_match((const UChar*)(pb), cm3, e1, flgs);
90 b = boost::u32regex_match((const UChar*)(pb), cm3, e1);
91 b = boost::u32regex_match((const wchar_t*)(pb), cm4, e1, flgs);
92 b = boost::u32regex_match((const wchar_t*)(pb), cm4, e1);
93 b = boost::u32regex_match(s1, sm1, e1, flgs);
94 b = boost::u32regex_match(s1, sm1, e1);
95 b = boost::u32regex_match(s2, sm2, e1, flgs);
96 b = boost::u32regex_match(s2, sm2, e1);
97 b = boost::u32regex_match(us, cm3, e1, flgs);
98 b = boost::u32regex_match(us, cm3, e1);
99
100 b = boost::u32regex_search(utf8_arch1(), utf8_arch1(), m1, e1, flgs);
101 b = boost::u32regex_search(utf8_arch1(), utf8_arch1(), m1, e1);
102 b = boost::u32regex_search(utf8_arch2(), utf8_arch2(), m2, e1, flgs);
103 b = boost::u32regex_search(utf8_arch2(), utf8_arch2(), m2, e1);
104 b = boost::u32regex_search(utf16_arch(), utf16_arch(), m3, e1, flgs);
105 b = boost::u32regex_search(utf16_arch(), utf16_arch(), m3, e1);
106 b = boost::u32regex_search(wchar_arch(), wchar_arch(), m4, e1, flgs);
107 b = boost::u32regex_search(wchar_arch(), wchar_arch(), m4, e1);
108 b = boost::u32regex_search((const char*)(pb), cm1, e1, flgs);
109 b = boost::u32regex_search((const char*)(pb), cm1, e1);
110 b = boost::u32regex_search((const unsigned char*)(pb), cm2, e1, flgs);
111 b = boost::u32regex_search((const unsigned char*)(pb), cm2, e1);
112 b = boost::u32regex_search((const UChar*)(pb), cm3, e1, flgs);
113 b = boost::u32regex_search((const UChar*)(pb), cm3, e1);
114 b = boost::u32regex_search((const wchar_t*)(pb), cm4, e1, flgs);
115 b = boost::u32regex_search((const wchar_t*)(pb), cm4, e1);
116 b = boost::u32regex_search(s1, sm1, e1, flgs);
117 b = boost::u32regex_search(s1, sm1, e1);
118 b = boost::u32regex_search(s2, sm2, e1, flgs);
119 b = boost::u32regex_search(s2, sm2, e1);
120 b = boost::u32regex_search(us, cm3, e1, flgs);
121 b = boost::u32regex_search(us, cm3, e1);
122 boost::output_iterator_archetype<char> out1 = boost::detail::dummy_constructor();
123 out1 = boost::u32regex_replace(out1, utf8_arch1(), utf8_arch1(), e1, (const char*)(pb), flgs);
124 boost::output_iterator_archetype<unsigned char> out2 = boost::detail::dummy_constructor();
125 out2 = boost::u32regex_replace(out2, utf8_arch2(), utf8_arch2(), e1, (const unsigned char*)(pb), flgs);
126 boost::output_iterator_archetype<UChar> out3 = boost::detail::dummy_constructor();
127 out3 = boost::u32regex_replace(out3, utf16_arch(), utf16_arch(), e1, (const UChar*)(pb), flgs);
128 boost::output_iterator_archetype<wchar_t> out4 = boost::detail::dummy_constructor();
129 out4 = boost::u32regex_replace(out4, wchar_arch(), wchar_arch(), e1, (const wchar_t*)(pb), flgs);
130
131 out1 = boost::u32regex_replace(out1, utf8_arch1(), utf8_arch1(), e1, s1, flgs);
132 out2 = boost::u32regex_replace(out2, utf8_arch2(), utf8_arch2(), e1, s1, flgs);
133 out3 = boost::u32regex_replace(out3, utf16_arch(), utf16_arch(), e1, s1, flgs);
134 out4 = boost::u32regex_replace(out4, wchar_arch(), wchar_arch(), e1, s1, flgs);
135 out1 = boost::u32regex_replace(out1, utf8_arch1(), utf8_arch1(), e1, s2, flgs);
136 out2 = boost::u32regex_replace(out2, utf8_arch2(), utf8_arch2(), e1, s2, flgs);
137 out3 = boost::u32regex_replace(out3, utf16_arch(), utf16_arch(), e1, s2, flgs);
138 out4 = boost::u32regex_replace(out4, wchar_arch(), wchar_arch(), e1, s2, flgs);
139 out1 = boost::u32regex_replace(out1, utf8_arch1(), utf8_arch1(), e1, us, flgs);
140 out2 = boost::u32regex_replace(out2, utf8_arch2(), utf8_arch2(), e1, us, flgs);
141 out3 = boost::u32regex_replace(out3, utf16_arch(), utf16_arch(), e1, us, flgs);
142 out4 = boost::u32regex_replace(out4, wchar_arch(), wchar_arch(), e1, us, flgs);
143 // string overloads:
144 s1 = boost::u32regex_replace(s1, e1, (const char*)(pb), flgs);
145 s2 = boost::u32regex_replace(s2, e1, (const wchar_t*)(pb), flgs);
146 s1 = boost::u32regex_replace(s1, e1, s1, flgs);
147 s2 = boost::u32regex_replace(s2, e1, s2, flgs);
148 s1 = boost::u32regex_replace(s1, e1, (const char*)(pb));
149 s2 = boost::u32regex_replace(s2, e1, (const wchar_t*)(pb));
150 s1 = boost::u32regex_replace(s1, e1, s1);
151 s2 = boost::u32regex_replace(s2, e1, s2);
152
153 #endif
154 return 0;
155 }
156
157 #endif
158