File: icu_concept_check.cpp

package info (click to toggle)
boost1.88 1.88.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 576,932 kB
  • sloc: cpp: 4,149,234; xml: 136,789; ansic: 35,092; python: 33,910; asm: 5,698; sh: 4,604; ada: 1,681; makefile: 1,633; pascal: 1,139; perl: 1,124; sql: 640; yacc: 478; ruby: 271; java: 77; lisp: 24; csh: 6
file content (249 lines) | stat: -rw-r--r-- 12,963 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*
 *
 * Copyright (c) 2003
 * John Maddock
 *
 * Use, modification and distribution are subject to 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)
 *
 */

// 
// This define keep ICU in it's own namespace: helps us to track bugs that would 
// otherwise go unnoticed:
//
#define U_USING_ICU_NAMESPACE 0

#include <boost/regex/config.hpp>

#if defined(BOOST_MSVC)
// this lets us compile at warning level 4 without seeing concept-check related warnings
#  pragma warning(disable:4100)
#endif
#ifdef BOOST_BORLANDC
#pragma option -w-8019 -w-8004 -w-8008
#endif

#ifdef BOOST_HAS_ICU

#include <boost/regex/icu.hpp>
#include <boost/detail/workaround.hpp>
#if !BOOST_WORKAROUND(_MSC_VER, < 1310) && !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__GNUC__, < 3)
#include <boost/regex/concepts.hpp>
#endif

template <class I>
void check_token_iterator(I i)
{
   typedef typename I::value_type value_type;
   typedef typename value_type::value_type char_type;
   typedef std::basic_string<char_type> string_type;

   I j;

   std::vector<string_type> v;

   while (i != j)
   {
      v.push_back(i->str());
      ++i;
   }

}

template <class I>
void check_iterator(I i)
{
   typedef typename I::value_type value_type;

   std::vector <value_type> v(i, I());
   (void)v;

}
int main()
{
   // VC6 and VC7 can't cope with the iterator architypes, 
   // don't bother testing as it doesn't work:
#if !BOOST_WORKAROUND(_MSC_VER, < 1310) && !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__GNUC__, < 3)
   boost::function_requires<
      boost::RegexTraitsConcept<
         boost::icu_regex_traits
      >
   >();
   boost::function_requires<
      boost::BoostRegexConcept<
         boost::u32regex
      >
   >();
   //
   // Now test additional function overloads:
   //
   bool b;
   unsigned long buf[2] = { 0, };
   const void* pb = buf;
   typedef boost::bidirectional_iterator_archetype<char> utf8_arch1;
   typedef boost::bidirectional_iterator_archetype<unsigned char> utf8_arch2;
   typedef boost::bidirectional_iterator_archetype<UChar> utf16_arch;
   typedef boost::bidirectional_iterator_archetype<wchar_t> wchar_arch;
   boost::match_results<utf8_arch1> m1;
   boost::match_results<utf8_arch2> m2;
   boost::match_results<utf16_arch> m3;
   boost::match_results<wchar_arch> m4;
   boost::match_results<const char*> cm1;
   boost::match_results<const unsigned char*> cm2;
   boost::match_results<const UChar*> cm3;
   boost::match_results<const wchar_t*> cm4;
   boost::match_results<std::string::const_iterator> sm1;
   boost::match_results<std::wstring::const_iterator> sm2;
   boost::u32regex e1;
   boost::regex_constants::match_flag_type flgs = boost::regex_constants::match_default;
   std::string s1;
   std::wstring s2;
   U_NAMESPACE_QUALIFIER UnicodeString us;
   b = boost::u32regex_match(utf8_arch1(), utf8_arch1(), m1, e1, flgs);
   b = boost::u32regex_match(utf8_arch1(), utf8_arch1(), m1, e1);
   b = boost::u32regex_match(utf8_arch2(), utf8_arch2(), m2, e1, flgs);
   b = boost::u32regex_match(utf8_arch2(), utf8_arch2(), m2, e1);
   b = boost::u32regex_match(utf16_arch(), utf16_arch(), m3, e1, flgs);
   b = boost::u32regex_match(utf16_arch(), utf16_arch(), m3, e1);
   b = boost::u32regex_match(wchar_arch(), wchar_arch(), m4, e1, flgs);
   b = boost::u32regex_match(wchar_arch(), wchar_arch(), m4, e1);
   b = boost::u32regex_match((const char*)(pb), cm1, e1, flgs);
   b = boost::u32regex_match((const char*)(pb), cm1, e1);
   b = boost::u32regex_match((const unsigned char*)(pb), cm2, e1, flgs);
   b = boost::u32regex_match((const unsigned char*)(pb), cm2, e1);
   b = boost::u32regex_match((const UChar*)(pb), cm3, e1, flgs);
   b = boost::u32regex_match((const UChar*)(pb), cm3, e1);
   b = boost::u32regex_match((const wchar_t*)(pb), cm4, e1, flgs);
   b = boost::u32regex_match((const wchar_t*)(pb), cm4, e1);
   b = boost::u32regex_match(s1, sm1, e1, flgs);
   b = boost::u32regex_match(s1, sm1, e1);
   b = boost::u32regex_match(s2, sm2, e1, flgs);
   b = boost::u32regex_match(s2, sm2, e1);
   b = boost::u32regex_match(us, cm3, e1, flgs);
   b = boost::u32regex_match(us, cm3, e1);

   b = boost::u32regex_search(utf8_arch1(), utf8_arch1(), m1, e1, flgs);
   b = boost::u32regex_search(utf8_arch1(), utf8_arch1(), m1, e1);
   b = boost::u32regex_search(utf8_arch2(), utf8_arch2(), m2, e1, flgs);
   b = boost::u32regex_search(utf8_arch2(), utf8_arch2(), m2, e1);
   b = boost::u32regex_search(utf16_arch(), utf16_arch(), m3, e1, flgs);
   b = boost::u32regex_search(utf16_arch(), utf16_arch(), m3, e1);
   b = boost::u32regex_search(wchar_arch(), wchar_arch(), m4, e1, flgs);
   b = boost::u32regex_search(wchar_arch(), wchar_arch(), m4, e1);
   b = boost::u32regex_search((const char*)(pb), cm1, e1, flgs);
   b = boost::u32regex_search((const char*)(pb), cm1, e1);
   b = boost::u32regex_search((const unsigned char*)(pb), cm2, e1, flgs);
   b = boost::u32regex_search((const unsigned char*)(pb), cm2, e1);
   b = boost::u32regex_search((const UChar*)(pb), cm3, e1, flgs);
   b = boost::u32regex_search((const UChar*)(pb), cm3, e1);
   b = boost::u32regex_search((const wchar_t*)(pb), cm4, e1, flgs);
   b = boost::u32regex_search((const wchar_t*)(pb), cm4, e1);
   b = boost::u32regex_search(s1, sm1, e1, flgs);
   b = boost::u32regex_search(s1, sm1, e1);
   b = boost::u32regex_search(s2, sm2, e1, flgs);
   b = boost::u32regex_search(s2, sm2, e1);
   b = boost::u32regex_search(us, cm3, e1, flgs);
   b = boost::u32regex_search(us, cm3, e1);
   boost::output_iterator_archetype<char> out1 = boost::detail::dummy_constructor();
   out1 = boost::u32regex_replace(out1, utf8_arch1(), utf8_arch1(), e1, (const char*)(pb), flgs);
   boost::output_iterator_archetype<unsigned char> out2 = boost::detail::dummy_constructor();
   out2 = boost::u32regex_replace(out2, utf8_arch2(), utf8_arch2(), e1, (const unsigned char*)(pb), flgs);
   boost::output_iterator_archetype<UChar> out3 = boost::detail::dummy_constructor();
   out3 = boost::u32regex_replace(out3, utf16_arch(), utf16_arch(), e1, (const UChar*)(pb), flgs);
   boost::output_iterator_archetype<wchar_t> out4 = boost::detail::dummy_constructor();
   out4 = boost::u32regex_replace(out4, wchar_arch(), wchar_arch(), e1, (const wchar_t*)(pb), flgs);

   out1 = boost::u32regex_replace(out1, utf8_arch1(), utf8_arch1(), e1, s1, flgs);
   out2 = boost::u32regex_replace(out2, utf8_arch2(), utf8_arch2(), e1, s1, flgs);
   out3 = boost::u32regex_replace(out3, utf16_arch(), utf16_arch(), e1, s1, flgs);
   out4 = boost::u32regex_replace(out4, wchar_arch(), wchar_arch(), e1, s1, flgs);
   out1 = boost::u32regex_replace(out1, utf8_arch1(), utf8_arch1(), e1, s2, flgs);
   out2 = boost::u32regex_replace(out2, utf8_arch2(), utf8_arch2(), e1, s2, flgs);
   out3 = boost::u32regex_replace(out3, utf16_arch(), utf16_arch(), e1, s2, flgs);
   out4 = boost::u32regex_replace(out4, wchar_arch(), wchar_arch(), e1, s2, flgs);
   out1 = boost::u32regex_replace(out1, utf8_arch1(), utf8_arch1(), e1, us, flgs);
   out2 = boost::u32regex_replace(out2, utf8_arch2(), utf8_arch2(), e1, us, flgs);
   out3 = boost::u32regex_replace(out3, utf16_arch(), utf16_arch(), e1, us, flgs);
   out4 = boost::u32regex_replace(out4, wchar_arch(), wchar_arch(), e1, us, flgs);
   // string overloads:
   s1 = boost::u32regex_replace(s1, e1, (const char*)(pb), flgs);
   s2 = boost::u32regex_replace(s2, e1, (const wchar_t*)(pb), flgs);
   s1 = boost::u32regex_replace(s1, e1, s1, flgs);
   s2 = boost::u32regex_replace(s2, e1, s2, flgs);
   s1 = boost::u32regex_replace(s1, e1, (const char*)(pb));
   s2 = boost::u32regex_replace(s2, e1, (const wchar_t*)(pb));
   s1 = boost::u32regex_replace(s1, e1, s1);
   s2 = boost::u32regex_replace(s2, e1, s2);

   std::vector<int> subs1;
   int subs2[2] = { 1, 2 };

   check_token_iterator(boost::make_u32regex_token_iterator((const char*)(pb), e1, 0, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator((const char*)(pb), e1, 0));
   check_token_iterator(boost::make_u32regex_token_iterator((const char*)(pb), e1));
   check_token_iterator(boost::make_u32regex_token_iterator((const UChar*)(pb), e1, 0, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator((const UChar*)(pb), e1, 0));
   check_token_iterator(boost::make_u32regex_token_iterator((const UChar*)(pb), e1));
   check_token_iterator(boost::make_u32regex_token_iterator((const wchar_t*)(pb), e1, 0, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator((const wchar_t*)(pb), e1, 0));
   check_token_iterator(boost::make_u32regex_token_iterator((const wchar_t*)(pb), e1));
   check_token_iterator(boost::make_u32regex_token_iterator(s1, e1, 0, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator(s1, e1, 0));
   check_token_iterator(boost::make_u32regex_token_iterator(s1, e1));
   check_token_iterator(boost::make_u32regex_token_iterator(s2, e1, 0, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator(s2, e1, 0));
   check_token_iterator(boost::make_u32regex_token_iterator(s2, e1));
   check_token_iterator(boost::make_u32regex_token_iterator(us, e1, 0, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator(us, e1, 0));
   check_token_iterator(boost::make_u32regex_token_iterator(us, e1));

   check_token_iterator(boost::make_u32regex_token_iterator((const char*)(pb), e1, subs2, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator((const char*)(pb), e1, subs2));
   check_token_iterator(boost::make_u32regex_token_iterator((const UChar*)(pb), e1, subs2, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator((const UChar*)(pb), e1, subs2));
   check_token_iterator(boost::make_u32regex_token_iterator((const wchar_t*)(pb), e1, subs2, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator((const wchar_t*)(pb), e1, subs2));
   check_token_iterator(boost::make_u32regex_token_iterator(s1, e1, subs2, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator(s1, e1, subs2));
   check_token_iterator(boost::make_u32regex_token_iterator(s2, e1, subs2, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator(s2, e1, subs2));
   check_token_iterator(boost::make_u32regex_token_iterator(us, e1, subs2, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator(us, e1, subs2));

   check_token_iterator(boost::make_u32regex_token_iterator((const char*)(pb), e1, subs1, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator((const char*)(pb), e1, subs1));
   check_token_iterator(boost::make_u32regex_token_iterator((const UChar*)(pb), e1, subs1, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator((const UChar*)(pb), e1, subs1));
   check_token_iterator(boost::make_u32regex_token_iterator((const wchar_t*)(pb), e1, subs1, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator((const wchar_t*)(pb), e1, subs1));
   check_token_iterator(boost::make_u32regex_token_iterator(s1, e1, subs1, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator(s1, e1, subs1));
   check_token_iterator(boost::make_u32regex_token_iterator(s2, e1, subs1, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator(s2, e1, subs1));
   check_token_iterator(boost::make_u32regex_token_iterator(us, e1, subs1, boost::regex_constants::match_default));
   check_token_iterator(boost::make_u32regex_token_iterator(us, e1, subs1));

   check_iterator(boost::make_u32regex_iterator((const char*)(pb), e1, boost::regex_constants::match_default));
   check_iterator(boost::make_u32regex_iterator((const char*)(pb), e1));
   check_iterator(boost::make_u32regex_iterator((const UChar*)(pb), e1, boost::regex_constants::match_default));
   check_iterator(boost::make_u32regex_iterator((const UChar*)(pb), e1));
   check_iterator(boost::make_u32regex_iterator((const wchar_t*)(pb), e1, boost::regex_constants::match_default));
   check_iterator(boost::make_u32regex_iterator((const wchar_t*)(pb), e1));
   check_iterator(boost::make_u32regex_iterator(s1, e1, boost::regex_constants::match_default));
   check_iterator(boost::make_u32regex_iterator(s2, e1));
   check_iterator(boost::make_u32regex_iterator(us, e1));

#endif   
   return 0;
}

#else

int main()
{
   return 0;
}

#endif